R7E-16E/R7E-16F 高风险操作确认统一
这个提交包含在:
@@ -0,0 +1,52 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { getActionConfirmCopy, type ActionConfirmKind } from "../../lib/actionConfirm";
|
||||
import { ConfirmDialog } from "./ConfirmDialog";
|
||||
|
||||
type ActionConfirmDialogProps = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
kind: ActionConfirmKind;
|
||||
targetName?: string;
|
||||
count?: number;
|
||||
title?: string;
|
||||
description?: ReactNode;
|
||||
confirmLabel?: string;
|
||||
variant?: "default" | "destructive";
|
||||
testId?: string;
|
||||
confirmTestId?: string;
|
||||
cancelTestId?: string;
|
||||
onConfirm: () => void | Promise<void>;
|
||||
};
|
||||
|
||||
export function ActionConfirmDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
kind,
|
||||
targetName,
|
||||
count,
|
||||
title,
|
||||
description,
|
||||
confirmLabel,
|
||||
variant,
|
||||
testId,
|
||||
confirmTestId,
|
||||
cancelTestId,
|
||||
onConfirm,
|
||||
}: ActionConfirmDialogProps) {
|
||||
const copy = getActionConfirmCopy(kind, { targetName, count, detail: description });
|
||||
|
||||
return (
|
||||
<ConfirmDialog
|
||||
open={open}
|
||||
onOpenChange={onOpenChange}
|
||||
title={title ?? copy.title}
|
||||
description={description ?? copy.description}
|
||||
confirmLabel={confirmLabel ?? copy.confirmLabel}
|
||||
variant={variant ?? copy.variant}
|
||||
testId={testId}
|
||||
confirmTestId={confirmTestId}
|
||||
cancelTestId={cancelTestId}
|
||||
onConfirm={onConfirm}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -31,9 +31,9 @@ export function ConfirmDialog({
|
||||
confirmLabel = "确认",
|
||||
cancelLabel = "取消",
|
||||
variant = "default",
|
||||
testId,
|
||||
confirmTestId,
|
||||
cancelTestId,
|
||||
testId = "action-confirm-dialog",
|
||||
confirmTestId = "action-confirm-submit",
|
||||
cancelTestId = "action-confirm-cancel",
|
||||
onConfirm,
|
||||
}: ConfirmDialogProps) {
|
||||
const [pending, setPending] = useState(false);
|
||||
|
||||
在新工单中引用
屏蔽一个用户