fix(events): align admin capacity API with direct live edits

Support optional capacity on the reserved-capacity patch and stop showing
proposed capacity on pending revision cards.
This commit is contained in:
alisaza 2026-09-11 15:52:29 +03:30
parent 5f2b83c9f9
commit 2da1c5e80f
3 changed files with 714 additions and 2908 deletions

View File

@ -3,7 +3,6 @@
import type { EventRevision } from '@/services/events' import type { EventRevision } from '@/services/events'
import Button from '@/components/formElements/Button' import Button from '@/components/formElements/Button'
import { Card, CardBody } from '@/components/heroui/Card' import { Card, CardBody } from '@/components/heroui/Card'
import { formatNumber } from '@/helpers'
import { texts } from '@/texts' import { texts } from '@/texts'
interface AdminEventPendingRevisionCardProps { interface AdminEventPendingRevisionCardProps {
@ -14,7 +13,7 @@ interface AdminEventPendingRevisionCardProps {
} }
const AdminEventPendingRevisionCard = ({ pendingId, revision, onApprove, onReject }: AdminEventPendingRevisionCardProps) => { const AdminEventPendingRevisionCard = ({ pendingId, revision, onApprove, onReject }: AdminEventPendingRevisionCardProps) => {
const { title, slug, capacity } = revision.payload const { title, slug } = revision.payload
return ( return (
<Card className="admin-surface"> <Card className="admin-surface">
@ -24,7 +23,7 @@ const AdminEventPendingRevisionCard = ({ pendingId, revision, onApprove, onRejec
<p className="text-xs text-text-muted">ارسالشده: {new Date(revision.submittedAt).toLocaleString('fa-IR')}</p> <p className="text-xs text-text-muted">ارسالشده: {new Date(revision.submittedAt).toLocaleString('fa-IR')}</p>
</div> </div>
<dl className="grid gap-2 sm:grid-cols-3"> <dl className="grid gap-2 sm:grid-cols-2">
{title != null && title !== '' ? ( {title != null && title !== '' ? (
<div className="rounded-xl border border-secondary-40 bg-secondary-50/60 p-3 text-right"> <div className="rounded-xl border border-secondary-40 bg-secondary-50/60 p-3 text-right">
<dt className="text-xs text-secondary-30">عنوان پیشنهادی</dt> <dt className="text-xs text-secondary-30">عنوان پیشنهادی</dt>
@ -42,12 +41,6 @@ const AdminEventPendingRevisionCard = ({ pendingId, revision, onApprove, onRejec
</dd> </dd>
</div> </div>
) : null} ) : null}
{capacity != null && Number.isFinite(Number(capacity)) ? (
<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">{formatNumber(Number(capacity))}</dd>
</div>
) : null}
</dl> </dl>
<div className="flex flex-wrap items-center justify-end gap-2"> <div className="flex flex-wrap items-center justify-end gap-2">

File diff suppressed because it is too large Load Diff

View File

@ -95,8 +95,11 @@ export async function deleteEventAsAdmin(eventId: string): Promise<CreatedEvent>
return unwrapApiPayload<CreatedEvent>(response.data) return unwrapApiPayload<CreatedEvent>(response.data)
} }
export async function updateEventReservedCapacity(eventId: string, reservedCapacity: number): Promise<CreatedEvent> { export async function updateEventReservedCapacity(
const response = await axiosInstance.patch(API_ROUTES.EVENTS.ADMIN_RESERVED_CAPACITY(eventId), { reservedCapacity }) eventId: string,
payload: { reservedCapacity: number; capacity?: number }
): Promise<CreatedEvent> {
const response = await axiosInstance.patch(API_ROUTES.EVENTS.ADMIN_RESERVED_CAPACITY(eventId), payload)
return unwrapApiPayload<CreatedEvent>(response.data) return unwrapApiPayload<CreatedEvent>(response.data)
} }