fix stale stuff?
This commit is contained in:
parent
bce9a19776
commit
264b44f555
@ -8,7 +8,7 @@
|
||||
--radius: 0.65rem;
|
||||
--background: oklch(1 0 0);
|
||||
--foreground: oklch(0.141 0.005 285.823);
|
||||
--card: oklch(1 0 0);
|
||||
--card: oklch(0.95 0 0);
|
||||
--card-foreground: oklch(0.141 0.005 285.823);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.141 0.005 285.823);
|
||||
@ -21,7 +21,7 @@
|
||||
--accent: oklch(0.967 0.001 286.375);
|
||||
--accent-foreground: oklch(0.21 0.006 285.885);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.92 0.004 286.32);
|
||||
--border: oklch(0.9 0.004 286.32);
|
||||
--input: oklch(0.92 0.004 286.32);
|
||||
--ring: oklch(0.606 0.25 292.717);
|
||||
--chart-1: oklch(0.646 0.222 41.116);
|
||||
@ -37,7 +37,7 @@
|
||||
--sidebar-accent-foreground: oklch(0.21 0.006 285.885);
|
||||
--sidebar-border: oklch(0.92 0.004 286.32);
|
||||
--sidebar-ring: oklch(0.606 0.25 292.717);
|
||||
--warning: oklch(0.84 0.16 84);
|
||||
--warning: oklch(0.6 0.16 84);
|
||||
--error: oklch(0.577 0.245 27.325);
|
||||
--positive: oklch(0.5 0.2067 147.18);
|
||||
--action: oklch(0.5852 0.2263 260.47);
|
||||
|
||||
@ -25,12 +25,19 @@
|
||||
export let inquireCallback: (item: Item) => void;
|
||||
export let claimCallback: (item: Item) => void;
|
||||
|
||||
let timeSincePosted: number | string = (new Date().getTime() - item.foundDate.getTime()) / 1000 / 60 / 60 / 24; // days
|
||||
// if (timeSincePosted < 1) {
|
||||
// timeSincePosted = '<1';
|
||||
// } else {
|
||||
// timeSincePosted = Math.round(timeSincePosted);
|
||||
// }
|
||||
// Normalize the foundDate in case it was serialized (string) in prod builds
|
||||
// (SSR/JSON serialization often turns Date objects into strings).
|
||||
const foundDateObj: Date = item?.foundDate instanceof Date
|
||||
? item.foundDate
|
||||
: new Date(item?.foundDate);
|
||||
|
||||
// Compute days since posted as a number (always a number, fall back to 0 on invalid date)
|
||||
let timeSincePosted: number = (() => {
|
||||
const t = foundDateObj?.getTime?.();
|
||||
if (!t || Number.isNaN(t)) return 0;
|
||||
return (Date.now() - t) / 1000 / 60 / 60 / 24; // days (float)
|
||||
})();
|
||||
// If you want to round/display differently you can do that in the template.
|
||||
|
||||
</script>
|
||||
|
||||
@ -59,13 +66,13 @@
|
||||
<Tooltip.Trigger
|
||||
>
|
||||
<Badge variant="outline"
|
||||
class="inline-block {user?.settings !== null && user?.settings !== undefined && timeSincePosted >= user.settings.staleItemDays ? 'text-warning' : ''}">{timeSincePosted < 1 ? "<1" : Math.round(timeSincePosted)}
|
||||
class="inline-block {user?.settings?.staleItemDays !== undefined && timeSincePosted >= user.settings.staleItemDays ? 'text-warning' : ''}">{timeSincePosted < 1 ? "<1" : Math.round(timeSincePosted)}
|
||||
day{(timeSincePosted <= 1) ? '' : 's'} ago
|
||||
</Badge>
|
||||
</Tooltip.Trigger
|
||||
>
|
||||
<Tooltip.Content>
|
||||
<p>{item.foundDate.toLocaleDateString('en-US', dateFormatOptions)}</p>
|
||||
<p>{foundDateObj.toLocaleDateString('en-US', dateFormatOptions)}</p>
|
||||
</Tooltip.Content>
|
||||
</Tooltip.Root>
|
||||
</Tooltip.Provider>
|
||||
@ -96,13 +103,13 @@
|
||||
|
||||
<Button variant="ghost" class="text-positive"
|
||||
onclick={async () => {await approveDenyItem({id: item.id, approved: true});
|
||||
invalidateAll()}}>
|
||||
await invalidateAll()}}>
|
||||
<CheckIcon />
|
||||
Approve
|
||||
</Button>
|
||||
<Button variant="ghost" class="text-destructive"
|
||||
onclick={async () => {await approveDenyItem({id: item.id, approved: false});
|
||||
invalidateAll()}}>
|
||||
await invalidateAll()}}>
|
||||
<XIcon />
|
||||
Deny
|
||||
</Button>
|
||||
@ -116,13 +123,13 @@
|
||||
{:else}
|
||||
<Button variant="ghost" class="text-destructive"
|
||||
onclick={async () => {await approveDenyItem({id: item.id, approved: false});
|
||||
invalidateAll()}}>
|
||||
await invalidateAll()}}>
|
||||
<TrashIcon />
|
||||
Delete
|
||||
</Button>
|
||||
<Button variant="ghost" class="text-action"
|
||||
onclick={async () => {await restoreClaimedItem(item.id);
|
||||
invalidateAll()}}>
|
||||
await invalidateAll()}}>
|
||||
<ArchiveRestoreIcon />
|
||||
Restore
|
||||
</Button>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user