|
|
@@ -0,0 +1,66 @@
|
|
|
+import { ConfirmDialog } from '@/components/confirm-dialog'
|
|
|
+import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
|
|
|
+import { useUpdateEvaluationStatus } from '@/hooks/evaluations/useUpdateEvaluationStatus'
|
|
|
+import { type Evaluation } from '@/types/evaluations.types'
|
|
|
+import { CircleCheck } from 'lucide-react'
|
|
|
+import { toast } from 'sonner'
|
|
|
+
|
|
|
+interface Props {
|
|
|
+ open: boolean
|
|
|
+ onOpenChange: (open: boolean) => void
|
|
|
+ currentRow: Evaluation | null
|
|
|
+}
|
|
|
+
|
|
|
+export function EvaluationsApproveDialog({
|
|
|
+ open,
|
|
|
+ onOpenChange,
|
|
|
+ currentRow,
|
|
|
+}: Props) {
|
|
|
+ const { mutate, isPending } = useUpdateEvaluationStatus()
|
|
|
+
|
|
|
+ if (!currentRow) return null
|
|
|
+
|
|
|
+ const handleApprove = () => {
|
|
|
+ mutate(
|
|
|
+ {
|
|
|
+ id: currentRow.id,
|
|
|
+ payload: { status: 'approved' },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ onSuccess: () => {
|
|
|
+ toast.success('ارزیابی با موفقیت تایید شد.')
|
|
|
+ onOpenChange(false)
|
|
|
+ },
|
|
|
+
|
|
|
+ onError: () => {
|
|
|
+ toast.error('خطا در تایید ارزیابی!')
|
|
|
+ },
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <ConfirmDialog
|
|
|
+ open={open}
|
|
|
+ onOpenChange={onOpenChange}
|
|
|
+ title={
|
|
|
+ <span>
|
|
|
+ <CircleCheck className='me-1 inline-block' size={18} /> تایید ارزیابی
|
|
|
+ </span>
|
|
|
+ }
|
|
|
+ desc={
|
|
|
+ <Alert variant='default'>
|
|
|
+ <AlertTitle>توجه!</AlertTitle>
|
|
|
+ <AlertDescription>
|
|
|
+ با تایید این ارزیابی، وضعیت آن به تکمیل شده تغییر میکند. این عملیات
|
|
|
+ را با اطمینان انجام دهید.
|
|
|
+ </AlertDescription>
|
|
|
+ </Alert>
|
|
|
+ }
|
|
|
+ confirmText='تایید ارزیابی'
|
|
|
+ cancelBtnText='انصراف'
|
|
|
+ handleConfirm={handleApprove}
|
|
|
+ isLoading={isPending}
|
|
|
+ />
|
|
|
+ )
|
|
|
+}
|