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