feat(public-booking): add pricing logic to booking slots and update schemas

This commit is contained in:
Jose Selesan
2026-06-02 16:37:11 -03:00
parent 3e314a9b9a
commit 9045a8c017
3 changed files with 62 additions and 1 deletions

View File

@@ -77,6 +77,7 @@ type SelectedSlot = {
sportName: string;
startTime: string;
endTime: string;
price: number;
};
type BookingShellProps = {
@@ -179,6 +180,18 @@ function extractMessage(error: unknown, fallback: string) {
return fallback;
}
function formatBookingPrice(price: number): string {
if (price === 0) {
return 'Sin cargo';
}
return new Intl.NumberFormat('es-AR', {
style: 'currency',
currency: 'ARS',
maximumFractionDigits: Number.isInteger(price) ? 0 : 2,
}).format(price);
}
function getStep(selectedSlot: SelectedSlot | null, isValid: boolean) {
if (!selectedSlot) return 1;
if (!isValid) return 3;
@@ -966,6 +979,7 @@ function MobileAvailableSlots({
sportName: court.sport.name,
startTime: slot.startTime,
endTime: slot.endTime,
price: slot.price,
})
}
aria-pressed={selected}
@@ -1093,6 +1107,7 @@ function BookingTimeline({
sportName: court.sport.name,
startTime: slot.startTime,
endTime: slot.endTime,
price: slot.price,
});
}}
className={`absolute top-7 flex h-12 min-w-[50px] items-center justify-center rounded border text-xs transition ${
@@ -1237,6 +1252,13 @@ function SelectedSlotCard(props: BookingShellProps & { compact?: boolean }) {
className={compact ? 'mt-4 space-y-3' : 'mt-5 grid gap-3'}
onSubmit={handleSubmit(onSubmit)}
>
<div className="flex items-center justify-between gap-3 rounded-md border border-emerald-400/20 bg-emerald-400/[0.06] px-3 py-2.5">
<span className="text-sm text-white/72">Precio del turno</span>
<span className="shrink-0 text-base font-bold text-white">
{formatBookingPrice(selectedSlot.price)}
</span>
</div>
<div className={compact ? 'space-y-3' : 'grid grid-cols-2 gap-3'}>
<Field data-invalid={Boolean(errors.customerName)}>
<FieldLabel htmlFor="customerName" className="text-white/76">