"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 { Stepper, StepperIndicator, StepperItem, StepperSeparator, StepperTitle, } from "@/components/ui/stepper"; 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". Centered so the numbered // indicators sit inline with their labels. export function DialogStepper({ step }: { step: "form" | "wallet" }) { const { t } = useTranslation(); const steps = [ { value: 1, label: t("walletSync.step1") }, { value: 2, label: t("walletSync.step2") }, ]; const activeValue = step === "form" ? 1 : 2; return ( {steps.map(({ value, label }, i) => ( {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" ? ( <> {t("walletSync.skip")} push([summary])} type="button"> {t("walletSync.send")} > ) : ( {t("walletSync.done")} )} > ); }
{t("walletSync.prompt", { name: patientName })}
{t("walletSync.promptBody")}
{error === "generic" ? t("walletSync.errors.generic") : error}
{t(`walletPush.status.${status}.title`)}
{t(`walletPush.status.${status}.body`)}