admin/features/events/detail/admin-event-detail/AdminEventRejectModal.tsx
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

80 lines
2.3 KiB
TypeScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client'
import type { AdminEventDetailData } from './types'
import { useState } from 'react'
import Input from '@/components/formElements/Input'
import Modal from '@/components/modals/Modal'
import { coerceToString } from '@/helpers'
import { rejectEventAsAdmin } from '@/services/events'
import useAdminAction from '@/hooks/useAdminAction'
interface AdminEventRejectModalProps {
eventId: string
isOpen: boolean
onOpenChange: (open: boolean) => void
onRejected: (updated: AdminEventDetailData) => void
}
const AdminEventRejectModal = ({ eventId, isOpen, onOpenChange, onRejected }: AdminEventRejectModalProps) => {
const [rejectionReason, setRejectionReason] = useState('')
const { pendingId, runAction } = useAdminAction()
const reset = () => {
setRejectionReason('')
}
const handleReject = () =>
runAction(
'reject',
async () => {
const updated = (await rejectEventAsAdmin(eventId, rejectionReason.trim())) as AdminEventDetailData
onRejected(updated)
onOpenChange(false)
reset()
},
'رویداد رد شد و برای اصلاح به پیش‌نویس بازگشت'
)
return (
<Modal
acceptDanger
acceptBtnDisabled={rejectionReason.trim().length < 3}
acceptBtnText="رد رویداد"
isLoading={pendingId === 'reject'}
isOpen={isOpen}
rejectBtnText="انصراف"
size="lg"
title="رد رویداد"
onAccept={() => void handleReject()}
onOpenChange={(open) => {
onOpenChange(open)
if (!open) reset()
}}
onReject={() => {
onOpenChange(false)
reset()
}}
>
<div className="flex flex-col gap-4">
<p className="text-sm text-text-muted">دلیل رد برای میزبان ارسال میشود تا بتواند رویداد را اصلاح و دوباره برای بررسی ارسال کند.</p>
<Input
generalType="textarea"
label="دلیل رد"
name="rejectionReason"
placeholder="حداقل ۳ کاراکتر"
textAreaMinRows={3}
value={rejectionReason}
onValueChange={(value) => {
setRejectionReason(coerceToString(value))
}}
/>
</div>
</Modal>
)
}
export default AdminEventRejectModal