Elffuss BraidHub

kikocis/continue public

main · 1.4 KiBRawPermalink
1import { useDispatch } from "react-redux";
2import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
3import { Button } from "../ui/Button";
4
5interface ConfirmationDialogProps {
6 onConfirm: () => void;
7 onCancel?: () => void;
8 text: string;
9 title?: string;
10 hideCancelButton?: boolean;
11 confirmText?: string;
12}
13
14function ConfirmationDialog(props: ConfirmationDialogProps) {
15 const dispatch = useDispatch();
16
17 return (
18 <div className="p-4 pt-0">
19 <h1 className="mb-1 text-center text-xl">
20 {props.title ?? "Confirmation"}
21 </h1>
22 <p className="text-center text-base" style={{ whiteSpace: "pre-wrap" }}>
23 {props.text}
24 </p>
25
26 <div className="w/1/2 flex justify-end gap-2">
27 {!!props.hideCancelButton || (
28 <Button
29 variant="outline"
30 onClick={() => {
31 dispatch(setShowDialog(false));
32 dispatch(setDialogMessage(undefined));
33 props.onCancel?.();
34 }}
35 >
36 Cancel
37 </Button>
38 )}
39 <Button
40 onClick={() => {
41 props.onConfirm();
42 dispatch(setShowDialog(false));
43 dispatch(setDialogMessage(undefined));
44 }}
45 >
46 {props.confirmText ?? "Confirm"}
47 </Button>
48 </div>
49 </div>
50 );
51}
52
53export default ConfirmationDialog;