User Details {#if selectedUser}
ID: {selectedUser.id}
{/if}
{#if selectedUser} {selectedUser.accountRole} {/if}
{#if selectedUser}

Personal Information

Full Name
{formatUserName( selectedUser.fullName, selectedUser.previousFirstName, selectedUser.previousLastName )}
Email
{selectedUser.email || '—'}
Phone
{selectedUser.phone || '—'}
Date of Birth
{#if selectedUser.dateOfBirth} {(() => { const dob = new SvelteDate(selectedUser.dateOfBirth); const dateStr = dob.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); const today = new SvelteDate(); let age = today.getFullYear() - dob.getFullYear(); const m = today.getMonth() - dob.getMonth(); if (m < 0 || (m === 0 && today.getDate() < dob.getDate())) age--; return `${dateStr} (${age})`; })()} {:else} — {/if}
First Visit
{#if customerRelationship?.firstVisitDate} {new SvelteDate(customerRelationship.firstVisitDate).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })} {:else} — {/if}
Last Visit
{#if customerRelationship?.lastVisitDate} {new SvelteDate(customerRelationship.lastVisitDate).toLocaleDateString('en-US', { weekday: 'short', day: 'numeric', month: 'short', year: 'numeric' })} {:else} — {/if}
{#if selectedUser.profilePicUrl}
Profile Picture
Profile
{/if} {#if selectedUser.notes}
Staff Notes
{selectedUser.notes}
{/if}

Booking History ({totalBookings})

{#if bookingUserHistory.length === 0 && !loadingBookings}
No bookings found
{:else if bookingUserHistory.length > 0}
{#each bookingUserHistory as booking (booking.id)}
{(() => { const date = parseWallClockDate(booking.start_time); const dateStr = date.toLocaleDateString('en-US', { weekday: 'long', day: 'numeric', month: 'short' }); const timeStr = date.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true }); return `${dateStr} at ${timeStr}`; })()}
{booking.status.replace('_', ' ')} {#if booking.deposit_required} {#if booking.status === 'pending'} Will Require Deposit {:else if (booking.status === 'confirmed' || booking.status === 'in_progress') && !booking.deposit_paid} Deposit Due {:else if booking.deposit_paid} Deposit Paid {/if} {/if} {booking.services.map((s) => s.service_name).join(', ')}
£{booking.total_amount.toFixed(2)}
{/each}
{#if totalBookingPages > 1}
Page {currentBookingPage} of {totalBookingPages}
{/if} {/if}
{#if loadingRelationship}

Customer Relationship

{#each range(5) as i (i)}
{/each}
{:else if customerRelationship}

Customer Relationship

Total Spend
£{customerRelationship.totalSpend.toFixed(2)}
Total Saved
£{customerRelationship.totalSaved.toFixed(2)}
Total Tips
£{customerRelationship.totalTips.toFixed(2)}
Total Visits
{customerRelationship.totalVisits}
Customer For
{customerRelationship.customerFor || '—'}
{#if giftCardBalance !== null && giftCardBalance > 0}
Gift Card Balance
£{giftCardBalance.toFixed(2)}
{/if} {#if customerRelationship.topServices && customerRelationship.topServices.length > 0}
Most Booked Services
{#each customerRelationship.topServices as service (service.name)} {service.name} ({service.count}) {/each}
{/if}
{/if}

Loyalty & Referrals

Loyalty Stamps
{selectedUser.loyaltyStamps}
Referral Code
{selectedUser.referralCode}
Referrals Made
{selectedUser.referralCodeUses}
{#if hasEligiblePatchTests}

Patch Tests

Record patch test completion to allow this user to book services requiring one.

{/if}
{/if}
{#if selectedUser} { fetchUserDetails(); }} /> {/if}