From 4a9fc0de3cf05ebf847d2f1898167ea539aa5923 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 17 Dec 2025 18:28:49 -0800 Subject: [PATCH] fix phantom claim button showing for all users canClaim was true when both claimedBy and currentUserId were undefined (undefined === undefined). now requires both to be set. also changed Claim to Accept/Decline buttons. --- src/lib/components/crew/PhantomRow.svelte | 37 +++++++++++++++++------ 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/lib/components/crew/PhantomRow.svelte b/src/lib/components/crew/PhantomRow.svelte index 5721ddcf..a9abee27 100644 --- a/src/lib/components/crew/PhantomRow.svelte +++ b/src/lib/components/crew/PhantomRow.svelte @@ -13,10 +13,12 @@ onEdit?: () => void onDelete?: () => void onAssign?: () => void - onConfirmClaim?: () => void + onAccept?: () => void + onDecline?: () => void } - const { phantom, currentUserId, onEdit, onDelete, onAssign, onConfirmClaim }: Props = $props() + const { phantom, currentUserId, onEdit, onDelete, onAssign, onAccept, onDecline }: Props = + $props() function formatDate(dateString: string): string { return new Date(dateString).toLocaleDateString(undefined, { @@ -35,9 +37,12 @@ return 'unclaimed' }) - // Check if current user is the one assigned to this phantom (can claim) + // Check if current user is the one assigned to this phantom (can accept/decline) const canClaim = $derived( - phantom.claimedBy?.id === currentUserId && !phantom.claimConfirmed + !!phantom.claimedBy && + !!currentUserId && + phantom.claimedBy.id === currentUserId && + !phantom.claimConfirmed ) @@ -88,11 +93,20 @@ {/if} {/snippet} - {:else if canClaim && onConfirmClaim} - - + {:else if canClaim} + +
+ {#if onDecline} + + {/if} + {#if onAccept} + + {/if} +
{/if} @@ -153,6 +167,11 @@ gap: spacing.$unit; } + .claim-buttons { + display: flex; + gap: spacing.$unit-half; + } + .status-badge { display: inline-block; padding: 2px 8px;