Skip to content

Commit

Permalink
resend invitation action
Browse files Browse the repository at this point in the history
  • Loading branch information
alexPopaCode4 committed Apr 7, 2024
1 parent 2342ec5 commit 819b005
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace App\Filament\Resources\OrganisationResource\Actions;

use App\Models\Organisation;
use Filament\Pages\Actions\Action;

class ResendInvitationAction extends Action
{
public static function getDefaultName(): ?string
{
return 'resend_invitation';
}

protected function setUp(): void
{
parent::setUp();

$this->color('secondary');

$this->action(function (Organisation $record, Action $action) {
$record->users->first()->sendWelcomeNotification();
$action->success();
});

$this->requiresConfirmation();

$this->label(__('organisation.action.resend_invitation.button'));

$this->modalHeading(__('organisation.action.resend_invitation.heading'));
$this->modalSubheading(__('organisation.action.resend_invitation.subheading'));
$this->modalButton(__('organisation.action.resend_invitation.button'));

$this->successNotificationTitle(__('organisation.action.resend_invitation.success'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Filament\Resources\OrganisationResource;
use App\Filament\Resources\OrganisationResource\Actions\ActivateOrganisationAction;
use App\Filament\Resources\OrganisationResource\Actions\DeactivateOrganisationAction;
use App\Filament\Resources\OrganisationResource\Actions\ResendInvitationAction;
use App\Models\Organisation;
use Filament\Pages\Actions\DeleteAction;
use Filament\Pages\Actions\EditAction;
Expand All @@ -28,6 +29,10 @@ protected function getActions(): array
->visible(fn (Organisation $record) => auth()->user()->isPlatformAdmin() && $record->isInactive())
->record($this->getRecord()),

ResendInvitationAction::make()
->visible(fn (Organisation $record) => auth()->user()->isPlatformAdmin() && $record->isGuest())
->record($this->getRecord()),

DeactivateOrganisationAction::make()
->visible(fn (Organisation $record) => auth()->user()->isPlatformAdmin() && $record->isActive())
->record($this->getRecord()),
Expand Down
5 changes: 5 additions & 0 deletions app/Models/Organisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ public function isInactive(): bool
return $this->status->is(OrganisationStatus::inactive);
}

public function isGuest(): bool
{
return $this->status->is(OrganisationStatus::guest);
}

public function routeNotificationForMail(?Notification $notification = null): string
{
return data_get($this->contact_person, ['email'], $this->email);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('organisations', function (Blueprint $table) {
$table->string('status')
->default(App\Enum\OrganisationStatus::guest->value)
->change();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('organisations', function (Blueprint $table) {
$table->string('status')
->default(App\Enum\OrganisationStatus::inactive->value)
->change();
});
}
};
6 changes: 6 additions & 0 deletions lang/ro/organisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,11 @@
'success' => 'Organizația a fost dezactivată cu succes.',
],
],
'resend_invitation' => [
'button' => 'Retrimite invitație',
'heading' => 'Retrimite invitație',
'subheading' => 'Ești sigur că vrei să retrimit invitația?',
'success' => 'Invitația a fost retimisă.',
],
],
];

0 comments on commit 819b005

Please sign in to comment.