Skip to content

Commit f184059

Browse files
feat: add beneficiary details slide-over with extended data schema
- Introduced a new `beneficiary_details` action to display detailed beneficiary information in a slide-over. - Loaded missing relationships and provided extended schema for beneficiary details, including residence, age, income, and aggressor data. - Added supplementary modal footer actions for viewing full beneficiary details. - Synced translations for new fields in Romanian and Spanish language files.
1 parent 0ffa183 commit f184059

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed

app/Filament/Organizations/Resources/Cases/Pages/InterventionPlan/ViewCaseInterventionPlan.php

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,99 @@ protected function getHeaderActions(): array
122122
];
123123
}
124124

125+
/**
126+
* Înregistrată pentru FAB / wire:click fără a apărea în header (vezi {@see openBeneficiaryDetailsSlideOver}).
127+
*/
128+
protected function beneficiary_detailsAction(): Action
129+
{
130+
$record = $this->getRecord();
131+
132+
if ($record instanceof Beneficiary) {
133+
$record->loadMissing([
134+
'details',
135+
'aggressors',
136+
'flowPresentation',
137+
'legal_residence.city',
138+
'legal_residence.county',
139+
'effective_residence.city',
140+
'effective_residence.county',
141+
]);
142+
}
143+
144+
return Action::make('beneficiary_details')
145+
->record($record)
146+
->slideOver()
147+
->modalHeading(__('case.view.identity_page.fab_beneficiary_details'))
148+
->modalSubmitAction(false)
149+
->modalCancelActionLabel(__('general.action.close'))
150+
->schema([
151+
TextEntry::make('full_name')
152+
->label(__('intervention_plan.labels.beneficiary_full_name'))
153+
->placeholder(''),
154+
TextEntry::make('created_at')
155+
->label(__('case.view.case_created_at'))
156+
->formatStateUsing(fn (mixed $state): string => self::formatDateState($state))
157+
->placeholder(''),
158+
TextEntry::make('age')
159+
->label(__('field.age'))
160+
->state(fn (Beneficiary $r): string => $r->age !== null ? (string) $r->age : ''),
161+
TextEntry::make('civil_status')
162+
->label(__('field.civil_status'))
163+
->state(fn (Beneficiary $r): string => self::formatEnumLabel($r->civil_status)),
164+
TextEntry::make('children_total_count')
165+
->label(__('field.children_total_count'))
166+
->placeholder(''),
167+
TextEntry::make('children_under_18_care_count')
168+
->label(__('field.children_under_18_care_count'))
169+
->placeholder(''),
170+
TextEntry::make('legal_residence_city')
171+
->label(__('field.legal_residence_city'))
172+
->state(fn (Beneficiary $r): string => $r->legal_residence?->city?->name ?? ''),
173+
TextEntry::make('effective_residence_city')
174+
->label(__('field.effective_residence_city'))
175+
->state(fn (Beneficiary $r): string => $r->effective_residence?->city?->name ?? ''),
176+
TextEntry::make('details.studies')
177+
->label(__('field.studies'))
178+
->state(fn (Beneficiary $r): string => self::formatEnumLabel($r->details?->studies)),
179+
TextEntry::make('details.occupation')
180+
->label(__('field.occupation'))
181+
->state(fn (Beneficiary $r): string => self::formatEnumLabel($r->details?->occupation)),
182+
TextEntry::make('details.net_income')
183+
->label(__('field.net_income'))
184+
->state(function (Beneficiary $r): string {
185+
$income = $r->details?->net_income;
186+
187+
return blank($income) ? '' : "{$income} RON";
188+
}),
189+
TextEntry::make('details.homeownership')
190+
->label(__('field.homeownership'))
191+
->state(fn (Beneficiary $r): string => self::formatEnumLabel($r->details?->homeownership)),
192+
TextEntry::make('aggressor_relationship')
193+
->label(__('field.aggressor_relationship'))
194+
->state(fn (Beneficiary $r): string => self::formatEnumLabel($r->aggressors->first()?->relationship)),
195+
TextEntry::make('aggressor_legal_history')
196+
->label(__('field.aggressor_legal_history'))
197+
->state(function (Beneficiary $r): string {
198+
$aggressor = $r->aggressors->first();
199+
200+
return self::formatCollectionLabels($aggressor?->legal_history);
201+
}),
202+
TextEntry::make('flowPresentation.presentation_mode')
203+
->label(__('field.presentation_mode'))
204+
->state(fn (Beneficiary $r): string => self::formatEnumLabel($r->flowPresentation?->presentation_mode)),
205+
TextEntry::make('flowPresentation.act_location')
206+
->label(__('field.act_location'))
207+
->state(fn (Beneficiary $r): string => self::formatCollectionLabels($r->flowPresentation?->act_location)),
208+
])
209+
->extraModalFooterActions([
210+
Action::make('view_full_beneficiary')
211+
->label(__('case.view.view_full_beneficiary'))
212+
->url(fn (): string => CaseResource::getUrl('view', ['record' => $this->getRecord()]))
213+
->button()
214+
->close(),
215+
]);
216+
}
217+
125218
public function openBeneficiaryDetailsSlideOver(): void
126219
{
127220
$this->mountAction('beneficiary_details');
@@ -191,7 +284,7 @@ private static function formatAddress(Beneficiary $record): string
191284
$parts = array_filter([
192285
$addr->address,
193286
$addr->city?->name,
194-
$addr->county ? __('field.county') . ' ' . $addr->county->name : null,
287+
$addr->county ? __('field.county').' '.$addr->county->name : null,
195288
]);
196289

197290
return implode(', ', $parts);

lang/es/case.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
'see_plan_details' => 'Ver detalles del plan',
4141
'view_full_plan' => 'Ver plan completo',
4242
'view_full_beneficiary' => 'Ver detalles completos',
43+
'case_created_at' => 'Fecha de creación del caso',
4344
'identity' => 'Datos de identidad',
4445
'identity_page' => [
4546
'download_sheet' => 'Descargar ficha',

lang/ro/case.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
'see_plan_details' => 'Vezi detalii plan',
5757
'view_full_plan' => 'Vezi plan complet',
5858
'view_full_beneficiary' => 'Vezi detalii complete',
59+
'case_created_at' => 'Data creării cazului',
5960
'identity' => 'Date identitate',
6061
'identity_page' => [
6162
'download_sheet' => 'Descarcă fișă',

0 commit comments

Comments
 (0)