Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
81 lines
2.3 KiB
TypeScript
81 lines
2.3 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
DialogTrigger,
|
|
DialogFooter,
|
|
} from "@/app/components/ui/dialog";
|
|
import { Button } from "@/app/components/ui/button";
|
|
import type { AdminLocationNode } from "@/app/lib/types";
|
|
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
|
|
|
/**
|
|
* Confirmation dialog for the structural status toggle on a location node.
|
|
* PUTs { status } through the page's read-merge-write update path (the backend
|
|
* has no dedicated status endpoint — see AdminLocationService.update).
|
|
*/
|
|
export function StatusToggleDialog({
|
|
node,
|
|
onConfirm,
|
|
}: {
|
|
node: AdminLocationNode;
|
|
onConfirm: (status: "Y" | "N") => Promise<void>;
|
|
}) {
|
|
const t = useT();
|
|
const [open, setOpen] = useState(false);
|
|
const [error, setError] = useState<string | null>(null);
|
|
const [pending, setPending] = useState(false);
|
|
|
|
const active = node.status === "Y";
|
|
const next = active ? "N" : "Y";
|
|
|
|
async function handleConfirm() {
|
|
setError(null);
|
|
setPending(true);
|
|
try {
|
|
await onConfirm(next);
|
|
setOpen(false);
|
|
} catch (err) {
|
|
setError(err instanceof Error ? err.message : "LocStatusUpdateFailed");
|
|
} finally {
|
|
setPending(false);
|
|
}
|
|
}
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
<DialogTrigger asChild>
|
|
<Button type="button" variant={active ? "destructive-outline" : "default"}>
|
|
{active ? t("CatDeactivate") : t("CatActivate")}
|
|
</Button>
|
|
</DialogTrigger>
|
|
<DialogContent>
|
|
<DialogHeader>
|
|
<DialogTitle>
|
|
{active ? t("LocStatusDeactivateTitle", { name: node.name }) : t("LocStatusActivateTitle", { name: node.name })}
|
|
</DialogTitle>
|
|
</DialogHeader>
|
|
<p className="text-sm text-muted-foreground">
|
|
{active
|
|
? t("LocStatusDeactivateDescription", { name: node.name, code: node.code })
|
|
: t("LocStatusActivateDescription", { name: node.name, code: node.code })}
|
|
</p>
|
|
{error && (
|
|
<p role="alert" className="text-sm text-destructive">
|
|
{t(error)}
|
|
</p>
|
|
)}
|
|
<DialogFooter>
|
|
<Button type="button" onClick={handleConfirm} disabled={pending}>
|
|
{t("Confirm")}
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
}
|