85 lines
1.8 KiB
TypeScript
85 lines
1.8 KiB
TypeScript
"use client"
|
|
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from "@/components/ui/dialog"
|
|
import { Button } from "@/components/ui/button"
|
|
|
|
type DialogType = "success" | "error" | "warning"
|
|
|
|
export function FeedbackDialog({
|
|
open,
|
|
onOpenChange,
|
|
type,
|
|
message,
|
|
onConfirm,
|
|
}: {
|
|
open: boolean
|
|
onOpenChange: (open: boolean) => void
|
|
type: DialogType
|
|
message: string
|
|
onConfirm?: (result: boolean) => void
|
|
}) {
|
|
const getColor = () => {
|
|
switch (type) {
|
|
case "success":
|
|
return "text-green-600"
|
|
case "error":
|
|
return "text-red-600"
|
|
case "warning":
|
|
return "text-yellow-600"
|
|
}
|
|
}
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
<DialogContent className="sm:max-w-sm">
|
|
<DialogHeader>
|
|
<DialogTitle className={getColor()}>{type.toUpperCase()}</DialogTitle>
|
|
</DialogHeader>
|
|
|
|
<p className="text-sm text-gray-600">{message}</p>
|
|
|
|
<DialogFooter>
|
|
{type == "success" || type == "error" ? (
|
|
<Button
|
|
variant="outline"
|
|
onClick={() => {
|
|
onConfirm?.(true)
|
|
onOpenChange(false)
|
|
}}
|
|
>
|
|
Ok
|
|
</Button>
|
|
) : (
|
|
<>
|
|
{" "}
|
|
<Button
|
|
variant="outline"
|
|
onClick={() => {
|
|
onConfirm?.(false)
|
|
onOpenChange(false)
|
|
}}
|
|
>
|
|
No
|
|
</Button>
|
|
<Button
|
|
onClick={() => {
|
|
onConfirm?.(true)
|
|
onOpenChange(false)
|
|
}}
|
|
>
|
|
Yes
|
|
</Button>
|
|
</>
|
|
)}
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|