diff --git a/frontend/src/routes/admin/+page.svelte b/frontend/src/routes/admin/+page.svelte index 67dd571..8a1ba8b 100644 --- a/frontend/src/routes/admin/+page.svelte +++ b/frontend/src/routes/admin/+page.svelte @@ -961,6 +961,28 @@ showServiceModal = true; } + /** Calculate hours between start and end time */ + function calculateHours(startTime: string, endTime: string): string { + // Convert formatted times to 24-hour format for calculation + const start = timeToInputValue(startTime); + const end = timeToInputValue(endTime); + + const [startHours, startMinutes] = start.split(':').map(Number); + const [endHours, endMinutes] = end.split(':').map(Number); + + const startTotalMinutes = startHours * 60 + startMinutes; + const endTotalMinutes = endHours * 60 + endMinutes; + + const diffMinutes = endTotalMinutes - startTotalMinutes; + const hours = Math.floor(diffMinutes / 60); + const minutes = diffMinutes % 60; + + if (minutes === 0) { + return `${hours}`; + } + return `${hours}.${minutes === 30 ? '5' : Math.round((minutes / 60) * 10)}`; + } + // Fetch services on component mount $effect(() => { if (pageState === 'authorized') { @@ -1151,8 +1173,26 @@ - Image Upload - Upload images for the portfolio or other uses. +
+
+ Image Upload + Upload images for the portfolio or other uses. +
+ +
@@ -1205,8 +1245,31 @@
- Users - Search and manage user details. +
+
+ + + + + + + + Users + + Search and manage user details. +
+ +
+ {users.length} +
+
@@ -1238,8 +1301,30 @@ - Bookings - Search and manage booking history. +
+
+ + + + + + + + Bookings + + Search and manage booking history. +
+
+ {bookings.length} +
+
@@ -1274,17 +1359,31 @@ - Holiday Hours - - Manage temporary schedules for holidays, closures, and special events. - +
+
+ Holiday Hours + + Manage temporary schedules for holidays, closures, and special events. + +
+ +
-
- -
- {#if exceptionGroupsLoading}
{#each Array(2) as _, i} @@ -1298,22 +1397,75 @@ {/if} {#each exceptionGroups as g} -
+
-
{g.name}
-
{g.description}
-
- Applies to weeks: {g.weekStarts?.slice(0, 5).join(', ')} - {#if (g.weekStarts?.length ?? 0) > 5} - (+{(g.weekStarts?.length ?? 0) - 5} more) - {/if} +
+
+
+ + + + + + +
+

{g.name}

+
+ + {g.weekStarts?.length || 0} weeks + +
+ +

{g.description}

+ +
+
Applies to weeks:
+
+ {g.weekStarts + ?.slice(0, 3) + .map((w) => + new Date(w).toLocaleDateString('en-GB', { + day: 'numeric', + month: 'short' + }) + ) + .join(', ')} + {#if (g.weekStarts?.length ?? 0) > 3} + + (+{(g.weekStarts?.length ?? 0) - 3} more) + {/if} +
-
-
@@ -1336,94 +1500,288 @@ - - Working Hours - View and manage your standard weekly schedule. - {#if !defaultHoursIsLoading}
-

Weekly Schedule

+
+

Weekly Schedule

+

+ Your standard operating hours for each day of the week +

+
-
- + +
- - - - - + + + + + + - + {#each defaultHours as row} - - - + + - - + {/each}
DayStatusStartEnd
DayStatusOpening TimeClosing TimeTotal Hours
{weekdayLabel(row.weekday)} +
+
+ {weekdayLabel(row.weekday) === 'Mon' + ? 'Monday' + : weekdayLabel(row.weekday) === 'Tue' + ? 'Tuesday' + : weekdayLabel(row.weekday) === 'Wed' + ? 'Wednesday' + : weekdayLabel(row.weekday) === 'Thu' + ? 'Thursday' + : weekdayLabel(row.weekday) === 'Fri' + ? 'Friday' + : weekdayLabel(row.weekday) === 'Sat' + ? 'Saturday' + : 'Sunday'} +
+
+ {row.is_open ? 'Open' : 'Closed'} - {row.is_open ? row.start_time : '—'} + + {#if row.is_open} +
+ + + + + {row.start_time} +
+ {:else} + + {/if}
- {row.is_open ? row.end_time : '—'} + + {#if row.is_open} +
+ + + + + {row.end_time} +
+ {:else} + + {/if} +
+ {#if row.is_open} + + {calculateHours(row.start_time, row.end_time)} + hrs + + {:else} + + {/if}
+ + +
+ {#each defaultHours as row} +
+
+
+ + {weekdayLabel(row.weekday) === 'Mon' + ? 'Monday' + : weekdayLabel(row.weekday) === 'Tue' + ? 'Tuesday' + : weekdayLabel(row.weekday) === 'Wed' + ? 'Wednesday' + : weekdayLabel(row.weekday) === 'Thu' + ? 'Thursday' + : weekdayLabel(row.weekday) === 'Fri' + ? 'Friday' + : weekdayLabel(row.weekday) === 'Sat' + ? 'Saturday' + : 'Sunday'} + +
+ + + {row.is_open ? 'Open' : 'Closed'} + +
+ + {#if row.is_open} +
+
+
Opening
+
{row.start_time}
+
+
+
Closing
+
{row.end_time}
+
+
+
+ Total: {calculateHours(row.start_time, row.end_time)} hours +
+ {:else} +
No hours scheduled for this day
+ {/if} +
+ {/each} +
{:else} -
- + +
- - - - - + + + + + + - + {#each Array(7) as _, i} - - - - - + + + + + + {/each}
DayStatusStartEnd
DayStatusOpening TimeClosing TimeTotal Hours
+
+ + +
+
+ + + + + + + +
+ + +
+ {#each Array(7) as _, i} +
+
+
+ + +
+ +
+
+ + +
+
+ {/each} +
{/if}
- Services Management - Manage your services - add, edit, toggle availability, or delete services. - -
- +
+ Services Management + + Manage your services - add, edit, toggle availability, or delete services. + +
+
+ +