|
|
@@ -2,6 +2,8 @@ import { AlertTriangle } from 'lucide-react'
|
|
|
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
|
|
|
import { ConfirmDialog } from '@/components/confirm-dialog'
|
|
|
import { type Evaluation } from '@/types/evaluations.types'
|
|
|
+import { useDeleteEvaluation } from '@/hooks/evaluations/useDeleteEvaluation'
|
|
|
+import { toast } from 'sonner'
|
|
|
|
|
|
interface Props {
|
|
|
open: boolean
|
|
|
@@ -14,30 +16,36 @@ export function EvaluationsDeleteDialog({
|
|
|
onOpenChange,
|
|
|
currentRow,
|
|
|
}: Props) {
|
|
|
- // const { mutate, isPending } = useDeleteUser()
|
|
|
+ const { mutate, isPending } = useDeleteEvaluation()
|
|
|
|
|
|
if (!currentRow) return null
|
|
|
|
|
|
- // const handleDelete = () => {
|
|
|
- // mutate(currentRow.id, {
|
|
|
- // onSuccess: () => {
|
|
|
- // onOpenChange(false)
|
|
|
- // },
|
|
|
- // })
|
|
|
- // }
|
|
|
+ const handleDelete = () => {
|
|
|
+ mutate(
|
|
|
+ { id: currentRow.id },
|
|
|
+ {
|
|
|
+ onSuccess: () => {
|
|
|
+ toast.success('ارزیابی مورد نظر با موفقیت حذف شد.')
|
|
|
+ onOpenChange(false)
|
|
|
+ },
|
|
|
+ onError: () => {
|
|
|
+ toast.error('خطا در حذف ارزیابی!')
|
|
|
+ },
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
|
|
|
return (
|
|
|
<ConfirmDialog
|
|
|
open={open}
|
|
|
onOpenChange={onOpenChange}
|
|
|
- form='evaluations-delete-form'
|
|
|
title={
|
|
|
<span className='text-destructive'>
|
|
|
<AlertTriangle
|
|
|
className='me-1 inline-block stroke-destructive'
|
|
|
size={18}
|
|
|
/>{' '}
|
|
|
- حذف پست
|
|
|
+ حذف ارزیابی
|
|
|
</span>
|
|
|
}
|
|
|
desc={
|
|
|
@@ -50,8 +58,9 @@ export function EvaluationsDeleteDialog({
|
|
|
}
|
|
|
confirmText='حذف'
|
|
|
cancelBtnText='انصراف'
|
|
|
- // isLoading={isPending}
|
|
|
+ isLoading={isPending}
|
|
|
destructive
|
|
|
+ handleConfirm={handleDelete}
|
|
|
/>
|
|
|
)
|
|
|
}
|