"use client"; import { Check, Loader2, Send, X } from "lucide-react"; import { useTranslation } from "react-i18next"; import { Button } from "@/components/ui/button"; import { DialogFooter, DialogPanel } from "@/components/ui/dialog"; import { cn } from "@/lib/utils"; import type { UseWalletSync } from "./use-wallet-sync"; // Two-step header shown at the top of a dialog when the selected patient has a // linked wallet: "Details" → "Sync to wallet". export function DialogStepper({ step }: { step: "form" | "wallet" }) { const { t } = useTranslation(); const steps = [ { key: "form", label: t("walletSync.step1") }, { key: "wallet", label: t("walletSync.step2") }, ] as const; const activeIndex = step === "form" ? 0 : 1; return (
{steps.map((s, i) => { const done = i < activeIndex; const active = i === activeIndex; return (
{done ? : i + 1} {s.label} {i < steps.length - 1 && ( )}
); })}
); } // Step 2 body + footer: offer to push the just-saved change to the patient's // wallet, then show the approval status. Rendered in place of the form's // DialogPanel/DialogFooter, so it returns them as a fragment. export function WalletSyncStep({ patientName, summary, sync, onDone, }: { patientName: string; summary: string; sync: UseWalletSync; onDone: () => void; }) { const { t } = useTranslation(); const { state, update, error, push } = sync; const status = update?.status ?? "pending"; return ( <> {state === "idle" || state === "error" ? (

{t("walletSync.prompt", { name: patientName })}

{t("walletSync.promptBody")}

{t("walletSync.changesLabel")}
{summary}
{error && (

{error === "generic" ? t("walletSync.errors.generic") : error}

)}
) : (
{status === "approved" ? (
) : status === "denied" ? (
) : ( )}

{t(`walletPush.status.${status}.title`)}

{t(`walletPush.status.${status}.body`)}

)}
{state === "idle" || state === "error" ? ( <> ) : ( )} ); }