Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
26 lines
924 B
TypeScript
26 lines
924 B
TypeScript
export type EventCapacityTone = 'neutral' | 'warning' | 'danger'
|
|
|
|
export function occupiedSeatCount(bookedCount: number, reservedCapacity: number): number {
|
|
return bookedCount + reservedCapacity
|
|
}
|
|
|
|
export function remainingSeatCount(capacity: number, bookedCount: number, reservedCapacity = 0): number {
|
|
return Math.max(0, capacity - occupiedSeatCount(bookedCount, reservedCapacity))
|
|
}
|
|
|
|
export function isOccupancyFull(capacity: number, bookedCount: number, reservedCapacity = 0): boolean {
|
|
return occupiedSeatCount(bookedCount, reservedCapacity) >= capacity
|
|
}
|
|
|
|
/** Badge tone from remaining / total: red <20%, orange <50%, otherwise gray. */
|
|
export function capacityToneFromRemaining(remaining: number, capacity: number): EventCapacityTone {
|
|
if (capacity <= 0) return 'danger'
|
|
|
|
const ratio = remaining / capacity
|
|
|
|
if (ratio < 0.2) return 'danger'
|
|
if (ratio < 0.5) return 'warning'
|
|
|
|
return 'neutral'
|
|
}
|