Enhanced various components to utilize the alert modal for user confirmations before executing critical actions. This includes marking messages as read, saving notification rules, restoring reviews, sending replies, changing ticket statuses, and managing event commissions. The integration improves user experience by ensuring actions are intentional and provides clear feedback on the outcomes.
133 lines
3.7 KiB
TypeScript
133 lines
3.7 KiB
TypeScript
'use client'
|
||
|
||
import type { AdminEventDetailData } from './types'
|
||
|
||
import Button from '@/components/formElements/Button'
|
||
import { APP_ROUTES } from '@/constants/routes'
|
||
import { texts } from '@/texts'
|
||
|
||
import { resolveAdminEventLifecycleHint } from './adminEventLifecycleHints'
|
||
|
||
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) => {
|
||
const hint = resolveAdminEventLifecycleHint(event)
|
||
|
||
return (
|
||
<div className="flex max-w-full flex-col items-end gap-1">
|
||
<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}
|
||
{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' ? (
|
||
<Button
|
||
aria-label={texts.events.adminLifecycleTitleForcePublish}
|
||
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>
|
||
{hint ? <p className="max-w-[min(72vw,28rem)] text-right text-xs leading-5 text-text-muted">{hint}</p> : null}
|
||
</div>
|
||
)
|
||
}
|
||
|
||
export default AdminEventLifecycleActions
|