style: fix prefer-svelte-reactivity — replace with Svelte reactive equivalents
This commit is contained in:
@@ -104,15 +104,15 @@
|
||||
/** Return the current London date as a Date set to midnight in the local timezone.
|
||||
* Uses Intl.DateTimeFormat with Europe/London to handle BST/GMT correctly. */
|
||||
function getLondonToday(): Date {
|
||||
const dateStr = new Date().toLocaleDateString('en-CA', { timeZone: 'Europe/London' });
|
||||
return new Date(dateStr + 'T00:00:00');
|
||||
const dateStr = new SvelteDate().toLocaleDateString('en-CA', { timeZone: 'Europe/London' });
|
||||
return new SvelteDate(dateStr + 'T00:00:00');
|
||||
}
|
||||
|
||||
/** Return the current time-of-day in London as minutes since midnight, using
|
||||
* Intl.DateTimeFormat with Europe/London so the current-time blue line is
|
||||
* positioned correctly regardless of the browser's system timezone. */
|
||||
function getLondonNowMinutes(): number {
|
||||
const timeStr = new Date().toLocaleTimeString('en-GB', {
|
||||
const timeStr = new SvelteDate().toLocaleTimeString('en-GB', {
|
||||
timeZone: 'Europe/London',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
@@ -127,7 +127,7 @@
|
||||
* at 23:30 UTC (00:30 BST next day) are grouped under the correct
|
||||
* London date column rather than the UTC date. */
|
||||
function getLondonDateKey(iso: string): string {
|
||||
return new Date(iso).toLocaleDateString('en-CA', { timeZone: 'Europe/London' });
|
||||
return new SvelteDate(iso).toLocaleDateString('en-CA', { timeZone: 'Europe/London' });
|
||||
}
|
||||
|
||||
function formatWeekLabel(start: Date): string {
|
||||
@@ -316,7 +316,7 @@
|
||||
|
||||
function navigateWeek(delta: number) {
|
||||
if (!weekStart) return;
|
||||
const d = new Date(weekStart);
|
||||
const d = new SvelteDate(weekStart);
|
||||
d.setDate(d.getDate() + delta * 7);
|
||||
weekStart = d;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import { Skeleton } from '$lib/components/ui/skeleton';
|
||||
import { Separator } from '$lib/components/ui/separator';
|
||||
import { SvelteMap } from 'svelte/reactivity';
|
||||
|
||||
type GdprData = {
|
||||
user_profile: {
|
||||
@@ -401,7 +402,7 @@
|
||||
.filter((r) => r.status === 'completed')
|
||||
.reduce((sum, r) => sum + Number(r.amount), 0);
|
||||
|
||||
const serviceMap = new Map<string, { count: number; total: number }>();
|
||||
const serviceMap = new SvelteMap<string, { count: number; total: number }>();
|
||||
for (const b of bookings) {
|
||||
for (const s of b.services ?? []) {
|
||||
const existing = serviceMap.get(s.name) ?? { count: 0, total: 0 };
|
||||
@@ -415,7 +416,7 @@
|
||||
.sort((a, b) => b.count - a.count)
|
||||
.slice(0, 5);
|
||||
|
||||
const methodMap = new Map<string, { count: number; total: number }>();
|
||||
const methodMap = new SvelteMap<string, { count: number; total: number }>();
|
||||
for (const p of payments.filter((p) => p.status === 'completed')) {
|
||||
if (p.payment_method === 'discount') continue;
|
||||
const method = p.payment_method.replace(/_/g, ' ');
|
||||
|
||||
Reference in New Issue
Block a user