style: fix prefer-svelte-reactivity — replace with Svelte reactive equivalents

This commit is contained in:
2026-06-25 14:40:22 +01:00
parent d5e93b3be2
commit 334b911e16
11 changed files with 35 additions and 29 deletions
@@ -8,6 +8,7 @@
import * as Modal from '$lib/components/ui/dialog';
import { Skeleton } from '$lib/components/ui/skeleton';
import { formatUserName } from '$lib/utils/nameDisplay';
import { SvelteDate, SvelteURLSearchParams } from 'svelte/reactivity';
interface GiftCard {
id: string;
@@ -252,7 +253,7 @@
loading = true;
loadingSearch = true;
try {
const params = new URLSearchParams({
const params = new SvelteURLSearchParams({
page: page.toString(),
per_page: '10'
});
@@ -779,7 +780,7 @@
}
function formatDate(dateStr: string): string {
return new Date(dateStr).toLocaleDateString('en-GB', {
return new SvelteDate(dateStr).toLocaleDateString('en-GB', {
day: 'numeric',
month: 'short',
year: 'numeric',
@@ -789,14 +790,14 @@
function getExpiryDate(lastUsedAt?: string): Date | null {
if (!lastUsedAt) return null;
const date = new Date(lastUsedAt);
const date = new SvelteDate(lastUsedAt);
date.setMonth(date.getMonth() + 24);
return date;
}
function isExpired(lastUsedAt?: string): boolean {
const expiry = getExpiryDate(lastUsedAt);
return expiry !== null && expiry < new Date();
return expiry !== null && expiry < new SvelteDate();
}
// =============== Sorting ===============
@@ -854,7 +855,7 @@
case 'remaining':
return (a.amount_remaining - b.amount_remaining) * mul;
case 'created':
return (new Date(a.created_at).getTime() - new Date(b.created_at).getTime()) * mul;
return (new SvelteDate(a.created_at).getTime() - new SvelteDate(b.created_at).getTime()) * mul;
case 'status': {
const aVal = a.redeemed_by ? 2 : a.amount_remaining === 0 ? 1 : 0;
const bVal = b.redeemed_by ? 2 : b.amount_remaining === 0 ? 1 : 0;
@@ -883,7 +884,7 @@
case 'balance':
return (a.balance - b.balance) * mul;
case 'updated':
return (new Date(a.updated_at).getTime() - new Date(b.updated_at).getTime()) * mul;
return (new SvelteDate(a.updated_at).getTime() - new SvelteDate(b.updated_at).getTime()) * mul;
default:
return 0;
}