feat(badges): two-step confirm before sending email review link

Replace the single alert() call with an inline confirmation row per badge.
Clicking "Email Link" shows "Send / Cancel" in place so accidental sends
are avoided. Only one badge can be in confirm state at a time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-06-06 18:35:40 -04:00
parent 29a24812f4
commit c9b0acfa06

View File

@@ -42,6 +42,9 @@ import {
// Track per-badge copy state for the "Review Link" clipboard button
let copy_status: Record<string, 'idle' | 'copied'> = $state({});
// Track which badge has a pending email confirmation (null = none pending)
let email_confirm_badge_id: string | null = $state(null);
// Access level shortcuts
let is_trusted = $derived($ae_loc.trusted_access === true);
let is_admin = $derived($ae_loc.administrator_access === true);
@@ -80,8 +83,13 @@ async function copy_review_link(event_badge_obj: any) {
}
}
// TODO: replace alert with actual email API call when available
function send_review_email(event_badge_obj: any) {
// TODO: replace with actual email API call when available
function confirm_send_review_email(event_badge_obj: any) {
email_confirm_badge_id = event_badge_obj.event_badge_id;
}
function do_send_review_email(event_badge_obj: any) {
email_confirm_badge_id = null;
const name =
event_badge_obj?.full_name_override ??
event_badge_obj?.full_name ??
@@ -404,16 +412,34 @@ let visible_badge_obj_li = $derived(
<!-- 4. Email Review Link: Manager+ always; Administrator + Edit Mode otherwise -->
{#if is_admin && (is_edit_mode || is_manager)}
<button
type="button"
class="hover:text-primary-800-200 hover:bg-primary-200-800 active:bg-surface-200-700 flex items-center gap-1 px-3 py-2 text-base font-bold transition-colors duration-1000 hover:duration-300 min-w-0 preset-tonal-primary rounded-lg border border-primary-200-800"
onclick={() =>
send_review_email(event_badge_obj)}
title="Email a review link to {display_name}">
<Mail size="1em" />
<span class="hidden sm:inline"
>Email Link</span>
</button>
{#if email_confirm_badge_id === event_badge_obj.event_badge_id}
<!-- Inline confirmation: shown after clicking Email Link -->
<div class="flex items-center gap-2 px-2 py-1 rounded-lg bg-warning-100 dark:bg-warning-900/30 border border-warning-300 dark:border-warning-700 text-sm">
<span class="text-warning-800 dark:text-warning-200 font-medium">Send link to {display_name}?</span>
<button
type="button"
class="flex items-center gap-1 px-2 py-1 rounded font-bold preset-filled-warning-500 text-sm"
onclick={() => do_send_review_email(event_badge_obj)}>
<Mail size="0.9em" />
Send
</button>
<button
type="button"
class="flex items-center gap-1 px-2 py-1 rounded font-bold preset-tonal-surface text-sm"
onclick={() => { email_confirm_badge_id = null; }}>
Cancel
</button>
</div>
{:else}
<button
type="button"
class="hover:text-primary-800-200 hover:bg-primary-200-800 active:bg-surface-200-700 flex items-center gap-1 px-3 py-2 text-base font-bold transition-colors duration-1000 hover:duration-300 min-w-0 preset-tonal-primary rounded-lg border border-primary-200-800"
onclick={() => confirm_send_review_email(event_badge_obj)}
title="Email a review link to {display_name}">
<Mail size="1em" />
<span class="hidden sm:inline">Email Link</span>
</button>
{/if}
{/if}
</div>
</div>