feat(public-booking): enhance booking confirmation with price and address details
This commit is contained in:
@@ -18,16 +18,35 @@ function formatDateLabel(isoDate: string) {
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
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 createWhatsappMessage(confirmation: PublicBookingConfirmation) {
|
||||
const dateLabel = formatDateLabel(confirmation.date);
|
||||
return [
|
||||
'Ya reservamos cancha para jugar.',
|
||||
`Complejo: ${confirmation.complexName}`,
|
||||
const lines = ['Ya reservamos cancha para jugar.', `Complejo: ${confirmation.complexName}`];
|
||||
|
||||
if (confirmation.complexAddress) {
|
||||
lines.push(`Direccion: ${confirmation.complexAddress}`);
|
||||
}
|
||||
|
||||
lines.push(
|
||||
`Cancha: ${confirmation.courtName} (${confirmation.sport.name})`,
|
||||
`Fecha: ${dateLabel}`,
|
||||
`Horario: ${confirmation.startTime} - ${confirmation.endTime}`,
|
||||
`Codigo de reserva: ${confirmation.bookingCode}`,
|
||||
].join('\n');
|
||||
`Precio: ${formatBookingPrice(confirmation.price)}`,
|
||||
`Codigo de reserva: ${confirmation.bookingCode}`
|
||||
);
|
||||
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export function ShareWhatsappButton({ confirmation }: ShareWhatsappButtonProps) {
|
||||
@@ -36,7 +55,12 @@ export function ShareWhatsappButton({ confirmation }: ShareWhatsappButtonProps)
|
||||
)}`;
|
||||
|
||||
return (
|
||||
<Button type="button" variant="outline" className="h-11 w-full text-sm sm:text-base" asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className="h-12 w-full rounded-xl border-slate-200 bg-white text-sm font-semibold text-slate-900 hover:bg-slate-50 sm:text-base"
|
||||
asChild
|
||||
>
|
||||
<a href={whatsappUrl} target="_blank" rel="noopener noreferrer">
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
|
||||
Reference in New Issue
Block a user