admin/features/events/detail/admin-event-detail/AdminEventPendingRevisionCard.tsx
alisaza 116d1be258 fix(events): show proposed FAQs on pending revision review
Surface revision-payload FAQs on the pending card so admins can review
another host's FAQ changes alongside title/slug.
2026-09-11 18:03:08 +03:30

86 lines
3.2 KiB
TypeScript
Raw 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 { EventRevision } from '@/services/events'
import Button from '@/components/formElements/Button'
import { Card, CardBody } from '@/components/heroui/Card'
import { texts } from '@/texts'
interface AdminEventPendingRevisionCardProps {
pendingId: string | null
revision: EventRevision
onApprove: () => void
onReject: () => void
}
const AdminEventPendingRevisionCard = ({ pendingId, revision, onApprove, onReject }: AdminEventPendingRevisionCardProps) => {
const { title, slug, faqs } = revision.payload
const proposedFaqs = Array.isArray(faqs) ? faqs : []
return (
<Card className="admin-surface">
<CardBody className="flex flex-col gap-4 p-4">
<div className="flex flex-col gap-1">
<h2 className="text-base font-bold text-secondary-10">{texts.events.revisionPendingCardTitle}</h2>
<p className="text-xs text-text-muted">ارسالشده: {new Date(revision.submittedAt).toLocaleString('fa-IR')}</p>
</div>
<dl className="grid gap-2 sm:grid-cols-2">
{title != null && title !== '' ? (
<div className="rounded-xl border border-secondary-40 bg-secondary-50/60 p-3 text-right">
<dt className="text-xs text-secondary-30">عنوان پیشنهادی</dt>
<dd className="mt-1 text-sm font-semibold text-secondary-20">{String(title)}</dd>
</div>
) : null}
{slug != null && slug !== '' ? (
<div className="rounded-xl border border-secondary-40 bg-secondary-50/60 p-3 text-right">
<dt className="text-xs text-secondary-30">اسلاگ پیشنهادی</dt>
<dd
className="mt-1 break-all text-sm font-semibold text-secondary-20"
dir="ltr"
>
{String(slug)}
</dd>
</div>
) : null}
</dl>
{proposedFaqs.length > 0 ? (
<div className="space-y-2 text-right">
<p className="text-xs text-secondary-30">سوالات متداول پیشنهادی ({proposedFaqs.length.toLocaleString('fa-IR')})</p>
{proposedFaqs.map((faq, index) => (
<div
key={`${faq.question}-${index}`}
className="rounded-xl border border-secondary-40 bg-secondary-50/60 p-3"
>
<h3 className="text-sm font-bold text-secondary-20">{faq.question}</h3>
<p className="mt-1 whitespace-pre-line text-xs leading-6 text-secondary-30">{faq.answer}</p>
</div>
))}
</div>
) : null}
<div className="flex flex-wrap items-center justify-end gap-2">
<Button
isLoading={pendingId === 'approve-revision'}
size="sm"
onClick={onApprove}
>
{texts.events.revisionApprove}
</Button>
<Button
color="danger"
disabled={pendingId === 'approve-revision'}
size="sm"
variant="flat"
onClick={onReject}
>
{texts.events.revisionReject}
</Button>
</div>
</CardBody>
</Card>
)
}
export default AdminEventPendingRevisionCard