diff --git a/lang/ar/booking.php b/lang/ar/booking.php index d853b3a..be88c89 100644 --- a/lang/ar/booking.php +++ b/lang/ar/booking.php @@ -65,6 +65,12 @@ return [ 'limit_message' => 'ملاحظة: يمكنك حجز استشارة واحدة كحد أقصى في اليوم.', 'user_booked' => 'حجزك', + // Logged-in user on guest page + 'logged_in_title' => 'لديك حساب بالفعل', + 'logged_in_message' => 'كمستخدم مسجل، يمكنك حجز الاستشارات مباشرة من لوحة التحكم الخاصة بك بطريقة أسهل وتتبع أفضل.', + 'go_to_dashboard' => 'احجز من حسابي', + 'or_logout' => 'أو قم بتسجيل الخروج للمتابعة كضيف', + // Guest booking 'guest_intro' => 'اطلب موعد استشارة. لا حاجة لإنشاء حساب - ما عليك سوى ملء بياناتك أدناه.', 'guest_name' => 'الاسم الكامل', diff --git a/lang/en/booking.php b/lang/en/booking.php index 2a68035..8ae42e2 100644 --- a/lang/en/booking.php +++ b/lang/en/booking.php @@ -65,6 +65,12 @@ return [ 'limit_message' => 'Note: You can book a maximum of 1 consultation per day.', 'user_booked' => 'Your booking', + // Logged-in user on guest page + 'logged_in_title' => 'You Already Have an Account', + 'logged_in_message' => 'As a registered user, you can book consultations directly from your dashboard with a simpler process and better tracking.', + 'go_to_dashboard' => 'Book from My Account', + 'or_logout' => 'Or log out to continue as a guest', + // Guest booking 'guest_intro' => 'Request a consultation appointment. No account required - simply fill in your details below.', 'guest_name' => 'Full Name', diff --git a/resources/views/livewire/pages/booking.blade.php b/resources/views/livewire/pages/booking.blade.php index 5b9bb9c..ca34d87 100644 --- a/resources/views/livewire/pages/booking.blade.php +++ b/resources/views/livewire/pages/booking.blade.php @@ -35,11 +35,13 @@ new #[Layout('components.layouts.public')] class extends Component public bool $showConfirmation = false; + public bool $isLoggedIn = false; + public function mount(): void { - // Redirect logged-in users to client booking + // Check if user is logged in - show friendly message instead of booking form if (auth()->check()) { - $this->redirect(route('client.consultations.book')); + $this->isLoggedIn = true; return; } @@ -195,24 +197,55 @@ new #[Layout('components.layouts.public')] class extends Component {{ __('booking.request_consultation') }} - @if(session('success')) - - {{ session('success') }} - - @endif + @if($isLoggedIn) + {{-- Logged-in user message --}} +
+
+
+ +
+ + {{ __('booking.logged_in_title') }} + +

+ {{ __('booking.logged_in_message') }} +

+
- @if(!$selectedDate || !$selectedTime) - {{-- Step 1: Calendar Selection --}} - -

{{ __('booking.guest_intro') }}

-
+
+ + + {{ __('booking.go_to_dashboard') }} + +
-

- {{ __('booking.select_date_time') }} -

- - +

+ {{ __('booking.or_logout') }} +

+
@else + @if(session('success')) + + {{ session('success') }} + + @endif + + @if(!$selectedDate || !$selectedTime) + {{-- Step 1: Calendar Selection --}} + +

{{ __('booking.guest_intro') }}

+
+ +

+ {{ __('booking.select_date_time') }} +

+ + + @else {{-- Step 2+: Contact Form & Confirmation --}}
@@ -332,5 +365,6 @@ new #[Layout('components.layouts.public')] class extends Component @enderror @endif + @endif @endif
diff --git a/tests/Feature/Public/GuestBookingTest.php b/tests/Feature/Public/GuestBookingTest.php index 65a14a4..d801a45 100644 --- a/tests/Feature/Public/GuestBookingTest.php +++ b/tests/Feature/Public/GuestBookingTest.php @@ -19,12 +19,15 @@ test('guest can view booking page', function () { ->assertSee(__('booking.request_consultation')); }); -test('logged in user is redirected to client booking', function () { +test('logged in user sees message to book from dashboard', function () { $user = User::factory()->client()->create(); $this->actingAs($user) ->get(route('booking')) - ->assertRedirect(route('client.consultations.book')); + ->assertOk() + ->assertSee(__('booking.logged_in_title')) + ->assertSee(__('booking.logged_in_message')) + ->assertSee(__('booking.go_to_dashboard')); }); test('guest booking page shows calendar', function () {