diff --git a/frontend/src/lib/components/account/EditRequestModal.svelte b/frontend/src/lib/components/account/EditRequestModal.svelte index 33cb05e..3de9b94 100644 --- a/frontend/src/lib/components/account/EditRequestModal.svelte +++ b/frontend/src/lib/components/account/EditRequestModal.svelte @@ -1,5 +1,5 @@ - - - Booking Confirmed - Crussell - - -
- {#if loading} -
-
- - -
- - - - - - - -
- {:else if error} - - - Error - - -

{error}

- -
-
- {:else if booking} -
-
- - - -
-

Booking Confirmed!

-

Your appointment has been successfully booked

-
- - - - Appointment Details - - -
-
-
Date
-
{formatDate(booking.start_time)}
-
-
-
Time
-
{formatTime(booking.start_time)}
-
-
- -
-
Estimated Duration
-
{formatDuration(totalDuration)}
-
- -
-
Services
-
- {#each booking.services as service (service.id)} -
-
-
{service.service_name}
-
- {service.duration_minutes} mins -
-
-
- {formatPounds(service.price)} -
-
- {/each} -
-
- -
-
Total
-
{formatPounds(totalPrice)}
-
-
-
- - - - Payment - - - {#if booking.deposit_required} - {#if hasPaidDeposit()} -
- - - -
-
Deposit Paid
-
- Your deposit of {formatPounds(booking.deposit_amount ?? 0)} has been paid -
-
-
- {#if paymentSummary && paymentSummary.remaining_amount > 0} -
-
- Remaining Balance - {formatPence(paymentSummary.remaining_amount)} -
-

- You can pay the remaining balance on the day of your appointment -

-
- {/if} - {:else} -
-
-
-
-
Deposit Required
-
- To secure your booking, please pay a deposit of {formatPounds( - booking.deposit_amount ?? 0 - )} -
-
-
- {formatPounds(booking.deposit_amount ?? 0)} -
-
- {#if booking.deposit_deadline} -
- Please pay before {formatDeadline(booking.deposit_deadline)} -
- {/if} -
- - -
- {/if} - {:else} -
-
-

- You can pay on the day, but if you'd prefer you can pay ahead here -

-
- - {#if hasPaidAnything()} -
- - - -
-
Paid
-
- {formatPence(paymentSummary?.paid_amount ?? 0)} paid -
-
-
- {#if paymentSummary && paymentSummary.total_vat_amount > 0} -
-
- Net amount - {formatPence(paymentSummary.total_net_amount)} -
-
- VAT - {formatPence(paymentSummary.total_vat_amount)} -
-
- Total paid - {formatPence(paymentSummary.paid_amount)} -
-
- {/if} - {:else} - - {/if} -
- {/if} -
-
- -
- - -
- {/if} -
diff --git a/frontend/src/routes/gdpr/+page.svelte b/frontend/src/routes/gdpr/+page.svelte index ce140e7..92fa06a 100644 --- a/frontend/src/routes/gdpr/+page.svelte +++ b/frontend/src/routes/gdpr/+page.svelte @@ -1,6 +1,7 @@ + Your Personal Data — Crussell diff --git a/frontend/src/routes/login/+page.svelte b/frontend/src/routes/login/+page.svelte index 84a9dfc..a183024 100644 --- a/frontend/src/routes/login/+page.svelte +++ b/frontend/src/routes/login/+page.svelte @@ -270,6 +270,10 @@ + Leave a Tip - Crussell diff --git a/frontend/src/routes/prices/+page.svelte b/frontend/src/routes/prices/+page.svelte index 361aa30..b3683fe 100644 --- a/frontend/src/routes/prices/+page.svelte +++ b/frontend/src/routes/prices/+page.svelte @@ -4,7 +4,7 @@ import { Button } from '$lib/components/ui/button/index.js'; import { Skeleton } from '$lib/components/ui/skeleton/index.js'; import { toast } from 'svelte-sonner'; - import { authStore } from '$lib/stores/auth.svelte'; + import { apiFetch } from '$lib/utils/api'; import { formatDuration } from '$lib/utils/format'; type Service = { @@ -23,12 +23,9 @@ async function fetchServices() { servicesLoading = true; try { - const response = await fetch('/api/services', { + const response = await apiFetch('/api/services', { method: 'GET', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${authStore.currentToken}` - } + headers: { 'Content-Type': 'application/json' } }); if (response.ok) { diff --git a/frontend/src/routes/schedule/+page.svelte b/frontend/src/routes/schedule/+page.svelte index 09dac95..1997441 100644 --- a/frontend/src/routes/schedule/+page.svelte +++ b/frontend/src/routes/schedule/+page.svelte @@ -2,6 +2,7 @@ import { goto } from '$app/navigation'; import { resolve } from '$app/paths'; import { authStore } from '$lib/stores/auth.svelte'; + import { apiFetch } from '$lib/utils/api'; import { ensureBusinessInfo, getBusinessInfo } from '$lib/stores/businessInfo.svelte'; import { browser } from '$app/environment'; import { toast } from 'svelte-sonner'; @@ -39,11 +40,8 @@ loading = true; try { const today = new Date().toLocaleDateString('en-CA', { timeZone: 'Europe/London' }); - const response = await fetch(`/api/bookings?start_date=${today}&per_page=50&page=1`, { - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${authStore.currentToken}` - } + const response = await apiFetch(`/api/bookings?start_date=${today}&per_page=50&page=1`, { + headers: { 'Content-Type': 'application/json' } }); if (!response.ok) { toast.error('Failed to load bookings'); @@ -180,6 +178,30 @@ } + + + + {#if pageState === 'loading'}
diff --git a/frontend/src/routes/tip/+page.svelte b/frontend/src/routes/tip/+page.svelte index d8f1881..0167aab 100644 --- a/frontend/src/routes/tip/+page.svelte +++ b/frontend/src/routes/tip/+page.svelte @@ -2,6 +2,7 @@ import { goto } from '$app/navigation'; import { browser } from '$app/environment'; import { authStore } from '$lib/stores/auth.svelte'; + import { apiFetch } from '$lib/utils/api'; import { SvelteDate } from 'svelte/reactivity'; import { toast } from 'svelte-sonner'; import { Button } from '$lib/components/ui/button'; @@ -131,12 +132,9 @@ try { const amountInPence = Math.round(tipAmount * 100); - const response = await fetch(`/api/bookings/${booking.id}/tip`, { + const response = await apiFetch(`/api/bookings/${booking.id}/tip`, { method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${authStore.currentToken}` - }, + headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ amount: amountInPence, card_token: 'placeholder' @@ -192,11 +190,7 @@ error = null; try { - const response = await fetch('/api/bookings', { - headers: { - Authorization: `Bearer ${authStore.currentToken}` - } - }); + const response = await apiFetch('/api/bookings'); if (!response.ok) { throw new Error('Failed to load your bookings'); @@ -231,11 +225,7 @@ } // Fetch full booking details (includes payments for tips tracking) - const detailsResp = await fetch(`/api/bookings/${pastBooking.id}`, { - headers: { - Authorization: `Bearer ${authStore.currentToken}` - } - }); + const detailsResp = await apiFetch(`/api/bookings/${pastBooking.id}`); if (!detailsResp.ok) { throw new Error('Failed to load booking details'); @@ -251,6 +241,27 @@ + Leave a Tip - Crussell diff --git a/frontend/src/routes/today/+page.svelte b/frontend/src/routes/today/+page.svelte index 663cfd4..5622375 100644 --- a/frontend/src/routes/today/+page.svelte +++ b/frontend/src/routes/today/+page.svelte @@ -83,6 +83,10 @@