Added 'No show' status. Edit user profile

This commit is contained in:
Jose Selesan
2026-04-09 23:01:09 -03:00
parent 4dcaae7136
commit 2d86881f94
7 changed files with 440 additions and 45 deletions

View File

@@ -63,13 +63,33 @@ function formatDateLabel(dateIso: string) {
}).format(date)
}
function statusLabel(status: 'CONFIRMED' | 'CANCELLED' | 'COMPLETED') {
function getEffectiveStatus(booking: AdminBooking): 'CONFIRMED' | 'CANCELLED' | 'COMPLETED' | 'NO_SHOW' {
if (booking.status !== 'CONFIRMED') {
return booking.status
}
// Check if booking is past end time and still confirmed
const now = new Date()
const bookingDateTime = new Date(`${booking.date}T${booking.endTime}:00`)
if (now > bookingDateTime) {
return 'NO_SHOW'
}
return 'CONFIRMED'
}
function effectiveStatusLabel(status: 'CONFIRMED' | 'CANCELLED' | 'COMPLETED' | 'NO_SHOW') {
if (status === 'NO_SHOW') return 'No show'
if (status === 'COMPLETED') return 'Cumplida'
if (status === 'CANCELLED') return 'Cancelada'
return 'Confirmada'
}
function statusClassName(status: 'CONFIRMED' | 'CANCELLED' | 'COMPLETED') {
function effectiveStatusClassName(status: 'CONFIRMED' | 'CANCELLED' | 'COMPLETED' | 'NO_SHOW') {
if (status === 'NO_SHOW') {
return 'border-orange-200 bg-orange-50 text-orange-700'
}
if (status === 'COMPLETED') {
return 'border-emerald-200 bg-emerald-50 text-emerald-700'
}
@@ -333,7 +353,8 @@ export function HomePage() {
<h2 className="text-sm font-semibold capitalize">{formatDateLabel(date)}</h2>
<div className="mt-3 space-y-2">
{bookings.map((booking) => {
const canManage = booking.status === 'CONFIRMED'
const effectiveStatus = getEffectiveStatus(booking)
const canManage = booking.status === 'CONFIRMED' && effectiveStatus === 'CONFIRMED'
const isMutating = updateStatusMutation.isPending
return (
@@ -352,9 +373,9 @@ export function HomePage() {
<div className="flex flex-wrap items-center gap-2">
<span
className={`inline-flex rounded-full border px-2 py-1 text-xs font-medium ${statusClassName(booking.status)}`}
className={`inline-flex rounded-full border px-2 py-1 text-xs font-medium ${effectiveStatusClassName(effectiveStatus)}`}
>
{statusLabel(booking.status)}
{effectiveStatusLabel(effectiveStatus)}
</span>
{canManage && (