refactor: account modals with auto-select and formatting

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-05-29 16:09:05 +01:00
co-authored by Sisyphus
parent fc69fec361
commit 91999d8244
2 changed files with 7 additions and 7 deletions
@@ -302,8 +302,8 @@
function isDateUnavailable(date: DateValue): boolean { function isDateUnavailable(date: DateValue): boolean {
const d = date as CalendarDate; const d = date as CalendarDate;
const jsDate = d.toDate(getLocalTimeZone()); const jsDate = d.toDate(getLocalTimeZone());
const now = new Date(); const now = new SvelteDate();
const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate()); const todayStart = new SvelteDate(now.getFullYear(), now.getMonth(), now.getDate());
if (jsDate < todayStart) return true; if (jsDate < todayStart) return true;
if (d.compare(minDate) < 0 || d.compare(maxCalendarDate) > 0) return true; if (d.compare(minDate) < 0 || d.compare(maxCalendarDate) > 0) return true;
if (!workingHours) return true; if (!workingHours) return true;
@@ -378,7 +378,7 @@
$effect(() => { $effect(() => {
if (editMode === 'services') { if (editMode === 'services') {
// Fetch hours for the booking's current date to calculate remaining time // Fetch hours for the booking's current date to calculate remaining time
const bookingDate = new Date(booking.start_time); const bookingDate = new SvelteDate(booking.start_time);
const calDate = new CalendarDate( const calDate = new CalendarDate(
bookingDate.getFullYear(), bookingDate.getFullYear(),
bookingDate.getMonth() + 1, bookingDate.getMonth() + 1,
@@ -581,7 +581,7 @@
function calculateRemainingTime(): number { function calculateRemainingTime(): number {
if (!workingHours || !availableHours) return 0; if (!workingHours || !availableHours) return 0;
const bookingDate = new Date(booking.start_time); const bookingDate = new SvelteDate(booking.start_time);
const dateStr = `${bookingDate.getFullYear()}-${String(bookingDate.getMonth() + 1).padStart(2, '0')}-${String(bookingDate.getDate()).padStart(2, '0')}`; const dateStr = `${bookingDate.getFullYear()}-${String(bookingDate.getMonth() + 1).padStart(2, '0')}-${String(bookingDate.getDate()).padStart(2, '0')}`;
const dayWH = workingHours[dateStr]; const dayWH = workingHours[dateStr];
@@ -34,7 +34,7 @@
); );
let isFutureBooking = $derived( let isFutureBooking = $derived(
selectedBooking ? new Date(selectedBooking.start_time) > new Date() : false selectedBooking ? new SvelteDate(selectedBooking.start_time) > new SvelteDate() : false
); );
let hasPayments = $derived( let hasPayments = $derived(
@@ -260,7 +260,7 @@
</div> </div>
{#if selectedBooking} {#if selectedBooking}
{@const isPastBooking = new Date(selectedBooking.start_time) < new Date()} {@const isPastBooking = new SvelteDate(selectedBooking.start_time) < new SvelteDate()}
{@const isUnpaid = selectedBooking.amount_due > 0} {@const isUnpaid = selectedBooking.amount_due > 0}
{@const showChip = !isPastBooking || isUnpaid} {@const showChip = !isPastBooking || isUnpaid}
{@const isConfirmedOrLater = ['confirmed', 'in_progress', 'completed'].includes( {@const isConfirmedOrLater = ['confirmed', 'in_progress', 'completed'].includes(
@@ -449,7 +449,7 @@
Payment History Payment History
</h3> </h3>
<div class="space-y-3"> <div class="space-y-3">
{#each selectedBooking.payments as payment (payment.id)} {#each selectedBooking.payments as payment, index (index)}
<div class="rounded-md border border-gray-300 bg-white p-3"> <div class="rounded-md border border-gray-300 bg-white p-3">
<div class="flex items-start justify-between"> <div class="flex items-start justify-between">
<div class="flex-1"> <div class="flex-1">