diff --git a/app-modules/service-management/database/migrations/2023_09_01_143524_create_service_request_types_table.php b/app-modules/service-management/database/migrations/2023_09_01_143524_create_service_request_types_table.php index 964e2ec271..ca90214d59 100644 --- a/app-modules/service-management/database/migrations/2023_09_01_143524_create_service_request_types_table.php +++ b/app-modules/service-management/database/migrations/2023_09_01_143524_create_service_request_types_table.php @@ -43,7 +43,12 @@ public function up(): void { Schema::create('service_request_types', function (Blueprint $table) { $table->uuid('id')->primary(); + $table->string('name'); + $table->boolean('has_enabled_feedback_collection')->default(false); + $table->boolean('has_enabled_csat')->default(false); + $table->boolean('has_enabled_nps')->default(false); + $table->timestamps(); $table->softDeletes(); }); diff --git a/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/CreateServiceRequestType.php b/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/CreateServiceRequestType.php index f4d7b71e5a..0e8fcc719d 100644 --- a/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/CreateServiceRequestType.php +++ b/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/CreateServiceRequestType.php @@ -36,7 +36,11 @@ namespace AdvisingApp\ServiceManagement\Filament\Resources\ServiceRequestTypeResource\Pages; +use Filament\Forms\Get; use Filament\Forms\Form; +use Filament\Forms\Components\Group; +use Filament\Forms\Components\Toggle; +use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; use Filament\Resources\Pages\CreateRecord; use AdvisingApp\ServiceManagement\Filament\Resources\ServiceRequestTypeResource; @@ -49,10 +53,26 @@ public function form(Form $form): Form { return $form ->schema([ - TextInput::make('name') - ->label('Name') - ->required() - ->string(), + Section::make() + ->columns() + ->schema([ + TextInput::make('name') + ->label('Name') + ->required() + ->string(), + Group::make() + ->schema([ + Toggle::make('has_enabled_feedback_collection') + ->label('Enable feedback collection') + ->live(), + Toggle::make('has_enabled_csat') + ->label('CSAT') + ->visible(fn (Get $get) => $get('has_enabled_feedback_collection')), + Toggle::make('has_enabled_nps') + ->label('NPS') + ->visible(fn (Get $get) => $get('has_enabled_feedback_collection')), + ]), + ]), ]); } diff --git a/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/EditServiceRequestType.php b/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/EditServiceRequestType.php index 5b09d7f5f2..1941f5d486 100644 --- a/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/EditServiceRequestType.php +++ b/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/EditServiceRequestType.php @@ -36,8 +36,12 @@ namespace AdvisingApp\ServiceManagement\Filament\Resources\ServiceRequestTypeResource\Pages; +use Filament\Forms\Get; use Filament\Forms\Form; use Filament\Actions\DeleteAction; +use Filament\Forms\Components\Group; +use Filament\Forms\Components\Toggle; +use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; use Filament\Resources\Pages\EditRecord; use AdvisingApp\ServiceManagement\Filament\Resources\ServiceRequestTypeResource; @@ -50,10 +54,26 @@ public function form(Form $form): Form { return $form ->schema([ - TextInput::make('name') - ->label('Name') - ->required() - ->string(), + Section::make() + ->columns() + ->schema([ + TextInput::make('name') + ->label('Name') + ->required() + ->string(), + Group::make() + ->schema([ + Toggle::make('has_enabled_feedback_collection') + ->label('Enable feedback collection') + ->live(), + Toggle::make('has_enabled_csat') + ->label('CSAT') + ->visible(fn (Get $get) => $get('has_enabled_feedback_collection')), + Toggle::make('has_enabled_nps') + ->label('NPS') + ->visible(fn (Get $get) => $get('has_enabled_feedback_collection')), + ]), + ]), ]); } diff --git a/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/ViewServiceRequestType.php b/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/ViewServiceRequestType.php index f86d50187c..36a8254f6c 100644 --- a/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/ViewServiceRequestType.php +++ b/app-modules/service-management/src/Filament/Resources/ServiceRequestTypeResource/Pages/ViewServiceRequestType.php @@ -38,6 +38,7 @@ use Filament\Actions\EditAction; use Filament\Infolists\Infolist; +use Filament\Infolists\Components\Group; use Filament\Resources\Pages\ViewRecord; use Filament\Infolists\Components\Section; use Filament\Infolists\Components\TextEntry; @@ -54,6 +55,7 @@ public function infolist(Infolist $infolist): Infolist return $infolist ->schema([ Section::make() + ->columns() ->schema([ TextEntry::make('name') ->label('Name'), @@ -62,8 +64,25 @@ public function infolist(Infolist $infolist): Infolist ->hidden(fn (ServiceRequestType $record) => ! $record->form) ->url(fn (ServiceRequestType $record) => $record->form ? ServiceRequestFormResource::getUrl('edit', ['record' => $record?->form]) : null) ->color('primary'), - ]) - ->columns(), + Group::make() + ->schema([ + TextEntry::make('has_enabled_feedback_collection') + ->hiddenLabel() + ->state('Feedback collection') + ->badge() + ->color(fn (ServiceRequestType $record) => $record->has_enabled_feedback_collection ? 'success' : 'gray'), + TextEntry::make('has_enabled_csat') + ->hiddenLabel() + ->state('CSAT') + ->badge() + ->color(fn (ServiceRequestType $record) => $record->has_enabled_csat ? 'success' : 'gray'), + TextEntry::make('has_enabled_nps') + ->hiddenLabel() + ->state('NPS') + ->badge() + ->color(fn (ServiceRequestType $record) => $record->has_enabled_nps ? 'success' : 'gray'), + ]), + ]), ]); } diff --git a/app-modules/service-management/src/Models/ServiceRequestType.php b/app-modules/service-management/src/Models/ServiceRequestType.php index 1e682f1c9c..1c173bdd4c 100644 --- a/app-modules/service-management/src/Models/ServiceRequestType.php +++ b/app-modules/service-management/src/Models/ServiceRequestType.php @@ -57,6 +57,15 @@ class ServiceRequestType extends BaseModel implements Auditable protected $fillable = [ 'name', + 'has_enabled_feedback_collection', + 'has_enabled_csat', + 'has_enabled_nps', + ]; + + protected $casts = [ + 'has_enabled_feedback_collection' => 'boolean', + 'has_enabled_csat' => 'boolean', + 'has_enabled_nps' => 'boolean', ]; public function serviceRequests(): HasManyThrough