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 Button from '@/components/formElements/Button'
import { Card, CardBody } from '@/components/heroui/Card'
import { formatNumber } from '@/helpers'
import { texts } from '@/texts'
interface AdminEventPendingRevisionCardProps {
@ -14,7 +13,7 @@ interface AdminEventPendingRevisionCardProps {
}
const AdminEventPendingRevisionCard = ({ pendingId, revision, onApprove, onReject }: AdminEventPendingRevisionCardProps) => {
const { title, slug, capacity } = revision.payload
const { title, slug } = revision.payload
return (
<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>
</div>
<dl className="grid gap-2 sm:grid-cols-3">
<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>
@ -42,12 +41,6 @@ const AdminEventPendingRevisionCard = ({ pendingId, revision, onApprove, onRejec
</dd>
</div>
) : 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>
<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)
}
export async function updateEventReservedCapacity(eventId: string, reservedCapacity: number): Promise<CreatedEvent> {
const response = await axiosInstance.patch(API_ROUTES.EVENTS.ADMIN_RESERVED_CAPACITY(eventId), { reservedCapacity })
export async function updateEventReservedCapacity(
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)
}