R7E-16D 审批动作二次确认
Refs: R7E-16D BIZ8-12B QAOPS8-17
这个提交包含在:
@@ -1,4 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { type ReactNode, useState } from "react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -13,10 +13,13 @@ type ConfirmDialogProps = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
title: string;
|
||||
description?: string;
|
||||
description?: ReactNode;
|
||||
confirmLabel?: string;
|
||||
cancelLabel?: string;
|
||||
variant?: "default" | "destructive";
|
||||
testId?: string;
|
||||
confirmTestId?: string;
|
||||
cancelTestId?: string;
|
||||
onConfirm: () => void | Promise<void>;
|
||||
};
|
||||
|
||||
@@ -28,6 +31,9 @@ export function ConfirmDialog({
|
||||
confirmLabel = "确认",
|
||||
cancelLabel = "取消",
|
||||
variant = "default",
|
||||
testId,
|
||||
confirmTestId,
|
||||
cancelTestId,
|
||||
onConfirm,
|
||||
}: ConfirmDialogProps) {
|
||||
const [pending, setPending] = useState(false);
|
||||
@@ -44,7 +50,7 @@ export function ConfirmDialog({
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-sm">
|
||||
<DialogContent className="max-w-sm" data-testid={testId}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
{description ? <DialogDescription>{description}</DialogDescription> : null}
|
||||
@@ -54,6 +60,7 @@ export function ConfirmDialog({
|
||||
variant="secondary"
|
||||
disabled={pending}
|
||||
onClick={() => onOpenChange(false)}
|
||||
data-testid={cancelTestId}
|
||||
type="button"
|
||||
>
|
||||
{cancelLabel}
|
||||
@@ -62,6 +69,7 @@ export function ConfirmDialog({
|
||||
variant={variant === "destructive" ? "destructive" : "default"}
|
||||
disabled={pending}
|
||||
onClick={handleConfirm}
|
||||
data-testid={confirmTestId}
|
||||
type="button"
|
||||
>
|
||||
{pending ? "处理中..." : confirmLabel}
|
||||
|
||||
在新工单中引用
屏蔽一个用户