admin/features/events/detail/admin-event-detail/AdminEventLifecycleActions.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

130 lines
3.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

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 Button from '@/components/formElements/Button'
import { APP_ROUTES } from '@/constants/routes'
interface AdminEventLifecycleActionsProps {
event: AdminEventDetailData
pendingId: string | null
onApprove: () => void
onOpenReject: () => void
onForcePublish: () => void
onComplete: () => void
onCancel: () => void
onDelete: () => void
}
const AdminEventLifecycleActions = ({
event,
pendingId,
onApprove,
onOpenReject,
onForcePublish,
onComplete,
onCancel,
onDelete,
}: AdminEventLifecycleActionsProps) => (
<div className="flex max-w-full flex-nowrap items-center justify-end gap-2 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
{['draft', 'pending_review', 'published', 'full'].includes(event.status) ? (
<Button
size="sm"
to={APP_ROUTES.MANAGE_EVENT_EDIT(event.id)}
variant="flat"
>
ویرایش
</Button>
) : null}
<Button
size="sm"
to={`${APP_ROUTES.MANAGE_EVENT_NEW}?cloneFrom=${encodeURIComponent(event.id)}`}
variant="flat"
>
کپی
</Button>
{event.status === 'draft' && !event.adminApprovedAt ? (
<Button
isLoading={pendingId === 'approve'}
size="sm"
onClick={() => {
onApprove()
}}
>
تأیید برای انتشار
</Button>
) : null}
{event.status === 'draft' && event.adminApprovedAt ? (
<span className="shrink-0 self-center whitespace-nowrap text-xs font-semibold text-fifth-700">تأییدشده؛ منتظر میزبان</span>
) : null}
{event.status === 'pending_review' ? (
<>
<Button
isLoading={pendingId === 'approve'}
size="sm"
onClick={() => {
onApprove()
}}
>
تأیید و انتشار
</Button>
<Button
color="danger"
size="sm"
variant="flat"
onClick={onOpenReject}
>
رد
</Button>
</>
) : null}
{event.status === 'draft' || event.status === 'pending_review' ? (
<Button
aria-label="انتشار فوری بدون تایید میزبان"
isLoading={pendingId === 'force-publish'}
size="sm"
variant="flat"
onClick={() => {
onForcePublish()
}}
>
انتشار فوری
</Button>
) : null}
{event.status === 'published' || event.status === 'full' ? (
<>
<Button
isLoading={pendingId === 'complete'}
size="sm"
variant="flat"
onClick={onComplete}
>
پایان
</Button>
<Button
color="danger"
isLoading={pendingId === 'cancel'}
size="sm"
variant="flat"
onClick={onCancel}
>
لغو
</Button>
</>
) : null}
{event.bookedCount === 0 ? (
<Button
color="danger"
isLoading={pendingId === 'delete'}
size="sm"
variant="flat"
onClick={onDelete}
>
حذف
</Button>
) : null}
</div>
)
export default AdminEventLifecycleActions