Commit 45a76a04 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix receptionist registration wizard — full rewrite of broken business logic

Problems fixed:
- MissingRulesException crash on step 4 (empty rules passed to validate())
- Guardian was never actually created as Person + Guardian record
- Guardian was never linked to participant via guardian_participant pivot
- Enrollment in program never happened (service didn't handle program_id)
- medical_notes was passed at wrong level (it's on people table, not participants)
- relation 'guardian' missing from validation (exists in DB CHECK constraint)

Now the wizard properly:
1. Creates guardian Person + Guardian record (or reuses existing)
2. Creates participant Person record with all fields (phone, national_id, medical_notes)
3. Creates Participant via ParticipantService with guardian linked
4. Attaches guardian via guardian_participant pivot
5. Enrolls in program via EnrollmentService (auto-finds/creates group)
6. Added participant phone + national_id fields to step 2
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 2fadfa10
...@@ -188,13 +188,13 @@ class="inline-flex items-center gap-2 px-6 py-3 min-h-16 bg-blue-600 text-white ...@@ -188,13 +188,13 @@ class="inline-flex items-center gap-2 px-6 py-3 min-h-16 bg-blue-600 text-white
{{-- Step 2: Participant Info --}} {{-- Step 2: Participant Info --}}
@if($currentStep === 2) @if($currentStep === 2)
<div> <div>
<h2 class="text-lg font-semibold text-gray-800 mb-6">{{ __('بيانات المشترك') }}</h2> <h2 class="text-lg font-semibold text-gray-800 mb-6">{{ __('بيانات المشترك (اللاعب)') }}</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-5"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-5">
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('الاسم بالعربية') }} <span class="text-red-500">*</span></label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ __('الاسم بالعربية') }} <span class="text-red-500">*</span></label>
<input type="text" wire:model="participant_name_ar" <input type="text" wire:model="participant_name_ar"
class="w-full px-4 py-3 min-h-16 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-lg" class="w-full px-4 py-3 min-h-16 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-lg"
placeholder="{{ __('اسم المشترك') }}"> placeholder="{{ __('اسم اللاعب / المشترك') }}">
@error('participant_name_ar') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror @error('participant_name_ar') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div> </div>
...@@ -202,7 +202,7 @@ class="w-full px-4 py-3 min-h-16 border border-gray-300 rounded-lg focus:ring-2 ...@@ -202,7 +202,7 @@ class="w-full px-4 py-3 min-h-16 border border-gray-300 rounded-lg focus:ring-2
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('الاسم بالإنجليزية') }}</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ __('الاسم بالإنجليزية') }}</label>
<input type="text" wire:model="participant_name" dir="ltr" <input type="text" wire:model="participant_name" dir="ltr"
class="w-full px-4 py-3 min-h-16 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-lg" class="w-full px-4 py-3 min-h-16 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-lg"
placeholder="Participant name"> placeholder="Player / participant name">
</div> </div>
<div> <div>
...@@ -235,6 +235,22 @@ class="w-full px-4 py-3 min-h-16 border border-gray-300 rounded-lg focus:ring-2 ...@@ -235,6 +235,22 @@ class="w-full px-4 py-3 min-h-16 border border-gray-300 rounded-lg focus:ring-2
@error('participant_gender') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror @error('participant_gender') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div> </div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('رقم هاتف المشترك') }}</label>
<input type="tel" wire:model="participant_phone" dir="ltr"
class="w-full px-4 py-3 min-h-16 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-lg"
placeholder="01xxxxxxxxx">
@error('participant_phone') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('الرقم القومي للمشترك') }}</label>
<input type="text" wire:model="participant_national_id" dir="ltr"
class="w-full px-4 py-3 min-h-16 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-lg"
placeholder="00000000000000" maxlength="14">
@error('participant_national_id') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div class="sm:col-span-2"> <div class="sm:col-span-2">
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('ملاحظات طبية') }}</label> <label class="block text-sm font-medium text-gray-700 mb-1">{{ __('ملاحظات طبية') }}</label>
<textarea wire:model="participant_medical_notes" rows="3" <textarea wire:model="participant_medical_notes" rows="3"
...@@ -386,7 +402,7 @@ class="inline-flex items-center gap-2 px-6 py-3 min-h-16 bg-blue-600 text-white ...@@ -386,7 +402,7 @@ class="inline-flex items-center gap-2 px-6 py-3 min-h-16 bg-blue-600 text-white
{{-- Participant Summary --}} {{-- Participant Summary --}}
<div class="p-4 bg-gray-50 rounded-xl border border-gray-200"> <div class="p-4 bg-gray-50 rounded-xl border border-gray-200">
<div class="flex items-center justify-between mb-3"> <div class="flex items-center justify-between mb-3">
<h3 class="font-semibold text-gray-700">{{ __('المشترك') }}</h3> <h3 class="font-semibold text-gray-700">{{ __('المشترك (اللاعب)') }}</h3>
<button wire:click="goToStep(2)" class="text-sm text-blue-600 hover:text-blue-800">{{ __('تعديل') }}</button> <button wire:click="goToStep(2)" class="text-sm text-blue-600 hover:text-blue-800">{{ __('تعديل') }}</button>
</div> </div>
<div class="grid grid-cols-2 gap-3 text-sm"> <div class="grid grid-cols-2 gap-3 text-sm">
...@@ -402,6 +418,18 @@ class="inline-flex items-center gap-2 px-6 py-3 min-h-16 bg-blue-600 text-white ...@@ -402,6 +418,18 @@ class="inline-flex items-center gap-2 px-6 py-3 min-h-16 bg-blue-600 text-white
<span class="text-gray-500">{{ __('الجنس') }}:</span> <span class="text-gray-500">{{ __('الجنس') }}:</span>
<span class="font-medium text-gray-800 ms-1">{{ $participant_gender === 'male' ? __('ذكر') : __('أنثى') }}</span> <span class="font-medium text-gray-800 ms-1">{{ $participant_gender === 'male' ? __('ذكر') : __('أنثى') }}</span>
</div> </div>
@if($participant_phone)
<div>
<span class="text-gray-500">{{ __('الهاتف') }}:</span>
<span class="font-medium text-gray-800 ms-1" dir="ltr">{{ $participant_phone }}</span>
</div>
@endif
@if($participant_national_id)
<div>
<span class="text-gray-500">{{ __('الرقم القومي') }}:</span>
<span class="font-medium text-gray-800 ms-1" dir="ltr">{{ $participant_national_id }}</span>
</div>
@endif
@if($participant_medical_notes) @if($participant_medical_notes)
<div class="col-span-2"> <div class="col-span-2">
<span class="text-gray-500">{{ __('ملاحظات طبية') }}:</span> <span class="text-gray-500">{{ __('ملاحظات طبية') }}:</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment