Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
84 lines
2.6 KiB
TypeScript
84 lines
2.6 KiB
TypeScript
'use client'
|
||
|
||
import type { AdminEventDetailData } from './types'
|
||
|
||
import Switch from '@/components/formElements/Switch'
|
||
import { Card, CardBody } from '@/components/heroui/Card'
|
||
import { Chip } from '@/components/heroui/Chip'
|
||
import { getBooleanStatus, getEventStatus } from '@/constants/status'
|
||
import { occupiedSeatCount } from '@/features/events/eventCapacity'
|
||
import { formatCurrency, formatNumber } from '@/helpers'
|
||
import { formatPersianDate } from '@/lib/formatters'
|
||
|
||
const number = formatNumber
|
||
|
||
interface AdminEventSummaryCardProps {
|
||
event: AdminEventDetailData
|
||
isTogglingDiscoverable: boolean
|
||
onToggleDiscoverable: (nextValue: boolean) => void
|
||
}
|
||
|
||
const AdminEventSummaryCard = ({ event, isTogglingDiscoverable, onToggleDiscoverable }: AdminEventSummaryCardProps) => {
|
||
const eventStatusBadge = getEventStatus(event.status)
|
||
const featuredBadge = getBooleanStatus(event.isFeatured, { true: 'ویژه', false: 'عادی' })
|
||
|
||
return (
|
||
<Card className="admin-surface">
|
||
<CardBody className="flex flex-row items-center gap-3 p-3 md:px-4 md:py-3">
|
||
<div className="flex min-w-0 flex-1 flex-row flex-wrap items-center gap-2">
|
||
{eventStatusBadge ? (
|
||
<Chip
|
||
color={eventStatusBadge.chipColor}
|
||
size="sm"
|
||
variant="flat"
|
||
>
|
||
{eventStatusBadge.label}
|
||
</Chip>
|
||
) : null}
|
||
<Chip
|
||
size="sm"
|
||
variant="flat"
|
||
>
|
||
{event.isFree ? 'رایگان' : formatCurrency(event.price)}
|
||
</Chip>
|
||
<Chip
|
||
size="sm"
|
||
variant="flat"
|
||
>
|
||
{number(occupiedSeatCount(event.bookedCount, event.reservedCapacity ?? 0))} / {number(event.capacity)}
|
||
</Chip>
|
||
{featuredBadge ? (
|
||
<Chip
|
||
color={featuredBadge.chipColor}
|
||
size="sm"
|
||
variant="flat"
|
||
>
|
||
{featuredBadge.label}
|
||
</Chip>
|
||
) : null}
|
||
<Chip
|
||
size="sm"
|
||
variant="flat"
|
||
>
|
||
{formatPersianDate(event.startsAt)}
|
||
</Chip>
|
||
</div>
|
||
<Switch
|
||
className="shrink-0"
|
||
classNames={{ label: 'whitespace-nowrap text-xs text-secondary-30' }}
|
||
isDisabled={isTogglingDiscoverable}
|
||
isSelected={event.settings.isDiscoverable}
|
||
size="sm"
|
||
onValueChange={(value) => {
|
||
onToggleDiscoverable(value)
|
||
}}
|
||
>
|
||
نمایش در جستجو
|
||
</Switch>
|
||
</CardBody>
|
||
</Card>
|
||
)
|
||
}
|
||
|
||
export default AdminEventSummaryCard
|