Compare commits
12 Commits
feat/onboa
...
473686528e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
473686528e | ||
| c1b47674c8 | |||
|
|
85f234b05e | ||
| 50fa4ed9a5 | |||
|
|
07496e6673 | ||
|
|
9045a8c017 | ||
|
|
3e314a9b9a | ||
| bc4716c48f | |||
|
|
0e69759549 | ||
|
|
88ea7e70da | ||
|
|
7a30f9a29b | ||
| 83fa1ea020 |
@@ -4,7 +4,7 @@
|
|||||||
"dev": "bun run --hot src/server.ts",
|
"dev": "bun run --hot src/server.ts",
|
||||||
"start": "bun src/server.ts",
|
"start": "bun src/server.ts",
|
||||||
"build": "tsc -b",
|
"build": "tsc -b",
|
||||||
"test": "bun test",
|
"test": "bun test --preload ./test/support/prisma.mock.ts ./test",
|
||||||
"lint": "biome check .",
|
"lint": "biome check .",
|
||||||
"lint:fix": "biome check --write .",
|
"lint:fix": "biome check --write .",
|
||||||
"format": "biome format --write .",
|
"format": "biome format --write .",
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ model CourtBooking {
|
|||||||
endTime String @map("end_time") @db.VarChar(5)
|
endTime String @map("end_time") @db.VarChar(5)
|
||||||
customerName String @map("customer_name") @db.VarChar(120)
|
customerName String @map("customer_name") @db.VarChar(120)
|
||||||
customerPhone String @map("customer_phone") @db.VarChar(30)
|
customerPhone String @map("customer_phone") @db.VarChar(30)
|
||||||
|
customerEmail String? @map("customer_email") @db.VarChar(254)
|
||||||
status CourtBookingStatus @default(CONFIRMED)
|
status CourtBookingStatus @default(CONFIRMED)
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
createdAt DateTime @default(now()) @map("created_at")
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
updatedAt DateTime @updatedAt @map("updated_at")
|
||||||
@@ -107,6 +108,7 @@ model CourtBookingLog {
|
|||||||
newStatus CourtBookingStatus @map("new_status")
|
newStatus CourtBookingStatus @map("new_status")
|
||||||
customerName String @map("customer_name") @db.VarChar(120)
|
customerName String @map("customer_name") @db.VarChar(120)
|
||||||
customerPhone String @map("customer_phone") @db.VarChar(30)
|
customerPhone String @map("customer_phone") @db.VarChar(30)
|
||||||
|
customerEmail String? @map("customer_email") @db.VarChar(254)
|
||||||
changedAt DateTime @default(now()) @map("changed_at")
|
changedAt DateTime @default(now()) @map("changed_at")
|
||||||
|
|
||||||
@@map("court_booking_logs")
|
@@map("court_booking_logs")
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the `onboarding_requests` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "court_booking_logs" ADD COLUMN "customer_email" VARCHAR(254);
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "court_bookings" ADD COLUMN "customer_email" VARCHAR(254);
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "onboarding_requests";
|
||||||
288
apps/backend/src/emails/booking-confirmation.ts
Normal file
288
apps/backend/src/emails/booking-confirmation.ts
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
type BookingEmailData = {
|
||||||
|
bookingCode: string;
|
||||||
|
complexName: string;
|
||||||
|
date: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
courtName: string;
|
||||||
|
sportName: string;
|
||||||
|
customerName: string;
|
||||||
|
price?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
function formatFriendlyDate(isoDate: string): string {
|
||||||
|
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(isoDate);
|
||||||
|
if (!match) return isoDate;
|
||||||
|
|
||||||
|
const date = new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
|
||||||
|
|
||||||
|
const weekday = new Intl.DateTimeFormat('es-AR', { weekday: 'long' }).format(date);
|
||||||
|
const day = date.getDate();
|
||||||
|
const month = new Intl.DateTimeFormat('es-AR', { month: 'long' }).format(date);
|
||||||
|
|
||||||
|
return `${weekday.charAt(0).toUpperCase() + weekday.slice(1)}, ${day} de ${month}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BASE_STYLES = `
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: #f4f4f5;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
}
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
function wrapLayout(content: string) {
|
||||||
|
return `<!DOCTYPE html>
|
||||||
|
<html lang="es">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Playzer</title>
|
||||||
|
<style>${BASE_STYLES}</style>
|
||||||
|
</head>
|
||||||
|
<body style="margin:0;padding:0;background-color:#f4f4f5;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;">
|
||||||
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color:#f4f4f5;min-height:100vh;">
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding:32px 16px;">
|
||||||
|
<table role="presentation" width="100%" style="max-width:520px;background-color:#ffffff;border-radius:12px;overflow:hidden;box-shadow:0 1px 3px rgba(0,0,0,0.08);">
|
||||||
|
${content}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function headerSection() {
|
||||||
|
return `
|
||||||
|
<tr>
|
||||||
|
<td style="background-color:#0a1628;padding:32px 32px 28px;text-align:center;">
|
||||||
|
<span style="font-size:24px;font-weight:700;color:#10b981;letter-spacing:-0.3px;">Playzer</span>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function divider() {
|
||||||
|
return `
|
||||||
|
<tr>
|
||||||
|
<td style="padding:0 32px;">
|
||||||
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td style="height:1px;background-color:#e5e7eb;line-height:1px;font-size:1px;"> </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dateTimeBlock(date: string, startTime: string, endTime: string): string {
|
||||||
|
const friendlyDate = formatFriendlyDate(date);
|
||||||
|
|
||||||
|
return `
|
||||||
|
<tr>
|
||||||
|
<td style="padding:0 32px;">
|
||||||
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color:#f0fdf4;border-radius:10px;border:1px solid #bbf7d0;">
|
||||||
|
<tr>
|
||||||
|
<td style="padding:20px 24px;text-align:center;">
|
||||||
|
<p style="margin:0;font-size:16px;font-weight:700;color:#065f46;line-height:1.4;">
|
||||||
|
${friendlyDate}
|
||||||
|
</p>
|
||||||
|
<p style="margin:8px 0 0;font-size:22px;font-weight:800;color:#059669;letter-spacing:-0.3px;">
|
||||||
|
${startTime} — ${endTime}
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function bookingConfirmationHtml(data: BookingEmailData): string {
|
||||||
|
const formattedPrice =
|
||||||
|
data.price !== undefined && data.price > 0
|
||||||
|
? new Intl.NumberFormat('es-AR', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'ARS',
|
||||||
|
maximumFractionDigits: Number.isInteger(data.price) ? 0 : 2,
|
||||||
|
}).format(data.price)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const content = `
|
||||||
|
${headerSection()}
|
||||||
|
<tr>
|
||||||
|
<td style="padding:32px 32px 8px;">
|
||||||
|
<h1 style="margin:0;font-size:22px;font-weight:700;color:#111827;text-align:center;">
|
||||||
|
Reserva confirmada
|
||||||
|
</h1>
|
||||||
|
<p style="margin:8px 0 0;font-size:14px;color:#6b7280;text-align:center;">
|
||||||
|
${data.complexName}
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="padding:20px 32px 12px;">
|
||||||
|
${dateTimeBlock(data.date, data.startTime, data.endTime)}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
${divider()}
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="padding:24px 32px;">
|
||||||
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
|
||||||
|
${detailRow('Código', `<span style="font-family:monospace;font-weight:700;letter-spacing:2px;">${data.bookingCode}</span>`)}
|
||||||
|
${detailRow('Cancha', `${data.courtName} — ${data.sportName}`)}
|
||||||
|
${detailRow('Cliente', data.customerName)}
|
||||||
|
${formattedPrice ? detailRow('Precio', formattedPrice) : ''}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
${divider()}
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="padding:24px 32px;">
|
||||||
|
<p style="margin:0;font-size:13px;color:#6b7280;text-align:center;line-height:1.5;">
|
||||||
|
Presentá el código de reserva al llegar al complejo.
|
||||||
|
<br />
|
||||||
|
Si necesitás cancelar o modificar, contactate directamente con el complejo.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="background-color:#f9fafb;padding:20px 32px;text-align:center;">
|
||||||
|
<p style="margin:0;font-size:12px;color:#9ca3af;">
|
||||||
|
Playzer — Reserva de canchas online
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
|
||||||
|
return wrapLayout(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function bookingCancelledHtml(data: BookingEmailData): string {
|
||||||
|
const content = `
|
||||||
|
${headerSection()}
|
||||||
|
<tr>
|
||||||
|
<td style="padding:32px 32px 8px;">
|
||||||
|
<h1 style="margin:0;font-size:22px;font-weight:700;color:#dc2626;text-align:center;">
|
||||||
|
Reserva cancelada
|
||||||
|
</h1>
|
||||||
|
<p style="margin:8px 0 0;font-size:14px;color:#6b7280;text-align:center;">
|
||||||
|
${data.complexName}
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="padding:20px 32px 12px;">
|
||||||
|
${dateTimeBlock(data.date, data.startTime, data.endTime)}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
${divider()}
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="padding:24px 32px;">
|
||||||
|
<p style="margin:0;font-size:14px;color:#374151;line-height:1.6;">
|
||||||
|
La reserva <strong style="font-family:monospace;font-weight:700;letter-spacing:2px;">${data.bookingCode}</strong>
|
||||||
|
fue cancelada. Si tenés dudas, contactate con el complejo.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="padding:0 32px 24px;">
|
||||||
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
|
||||||
|
${detailRow('Cancha', `${data.courtName} — ${data.sportName}`)}
|
||||||
|
${detailRow('Cliente', data.customerName)}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="background-color:#f9fafb;padding:20px 32px;text-align:center;">
|
||||||
|
<p style="margin:0;font-size:12px;color:#9ca3af;">
|
||||||
|
Playzer — Reserva de canchas online
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
|
||||||
|
return wrapLayout(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function bookingNoShowHtml(data: BookingEmailData): string {
|
||||||
|
const content = `
|
||||||
|
${headerSection()}
|
||||||
|
<tr>
|
||||||
|
<td style="padding:32px 32px 8px;">
|
||||||
|
<h1 style="margin:0;font-size:22px;font-weight:700;color:#d97706;text-align:center;">
|
||||||
|
Reserva no concretada
|
||||||
|
</h1>
|
||||||
|
<p style="margin:8px 0 0;font-size:14px;color:#6b7280;text-align:center;">
|
||||||
|
${data.complexName}
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="padding:20px 32px 12px;">
|
||||||
|
${dateTimeBlock(data.date, data.startTime, data.endTime)}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
${divider()}
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="padding:24px 32px;">
|
||||||
|
<p style="margin:0;font-size:14px;color:#374151;line-height:1.6;">
|
||||||
|
La reserva <strong style="font-family:monospace;font-weight:700;letter-spacing:2px;">${data.bookingCode}</strong>
|
||||||
|
fue registrada como no concretada por falta de asistencia.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="padding:0 32px 24px;">
|
||||||
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
|
||||||
|
${detailRow('Cancha', `${data.courtName} — ${data.sportName}`)}
|
||||||
|
${detailRow('Cliente', data.customerName)}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="background-color:#f9fafb;padding:20px 32px;text-align:center;">
|
||||||
|
<p style="margin:0;font-size:12px;color:#9ca3af;">
|
||||||
|
Playzer — Reserva de canchas online
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
|
||||||
|
return wrapLayout(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
function detailRow(label: string, value: string): string {
|
||||||
|
return `
|
||||||
|
<tr>
|
||||||
|
<td style="padding:6px 0;">
|
||||||
|
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td style="width:100px;font-size:13px;color:#6b7280;vertical-align:top;padding:2px 0;">
|
||||||
|
${label}
|
||||||
|
</td>
|
||||||
|
<td style="font-size:13px;font-weight:600;color:#111827;vertical-align:top;padding:2px 0;">
|
||||||
|
${value}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
@@ -82,11 +82,6 @@ export type CourtBooking = Prisma.CourtBookingModel
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export type CourtBookingLog = Prisma.CourtBookingLogModel
|
export type CourtBookingLog = Prisma.CourtBookingLogModel
|
||||||
/**
|
|
||||||
* Model OnboardingRequest
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export type OnboardingRequest = Prisma.OnboardingRequestModel
|
|
||||||
/**
|
/**
|
||||||
* Model PasswordResetRequest
|
* Model PasswordResetRequest
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -106,11 +106,6 @@ export type CourtBooking = Prisma.CourtBookingModel
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export type CourtBookingLog = Prisma.CourtBookingLogModel
|
export type CourtBookingLog = Prisma.CourtBookingLogModel
|
||||||
/**
|
|
||||||
* Model OnboardingRequest
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export type OnboardingRequest = Prisma.OnboardingRequestModel
|
|
||||||
/**
|
/**
|
||||||
* Model PasswordResetRequest
|
* Model PasswordResetRequest
|
||||||
*
|
*
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -397,7 +397,6 @@ export const ModelName = {
|
|||||||
CourtPriceRule: 'CourtPriceRule',
|
CourtPriceRule: 'CourtPriceRule',
|
||||||
CourtBooking: 'CourtBooking',
|
CourtBooking: 'CourtBooking',
|
||||||
CourtBookingLog: 'CourtBookingLog',
|
CourtBookingLog: 'CourtBookingLog',
|
||||||
OnboardingRequest: 'OnboardingRequest',
|
|
||||||
PasswordResetRequest: 'PasswordResetRequest',
|
PasswordResetRequest: 'PasswordResetRequest',
|
||||||
Plan: 'Plan'
|
Plan: 'Plan'
|
||||||
} as const
|
} as const
|
||||||
@@ -415,7 +414,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
|||||||
omit: GlobalOmitOptions
|
omit: GlobalOmitOptions
|
||||||
}
|
}
|
||||||
meta: {
|
meta: {
|
||||||
modelProps: "user" | "session" | "account" | "verification" | "complex" | "complexUser" | "complexInvitation" | "sport" | "court" | "courtAvailability" | "courtPriceRule" | "courtBooking" | "courtBookingLog" | "onboardingRequest" | "passwordResetRequest" | "plan"
|
modelProps: "user" | "session" | "account" | "verification" | "complex" | "complexUser" | "complexInvitation" | "sport" | "court" | "courtAvailability" | "courtPriceRule" | "courtBooking" | "courtBookingLog" | "passwordResetRequest" | "plan"
|
||||||
txIsolationLevel: TransactionIsolationLevel
|
txIsolationLevel: TransactionIsolationLevel
|
||||||
}
|
}
|
||||||
model: {
|
model: {
|
||||||
@@ -1381,80 +1380,6 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OnboardingRequest: {
|
|
||||||
payload: Prisma.$OnboardingRequestPayload<ExtArgs>
|
|
||||||
fields: Prisma.OnboardingRequestFieldRefs
|
|
||||||
operations: {
|
|
||||||
findUnique: {
|
|
||||||
args: Prisma.OnboardingRequestFindUniqueArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload> | null
|
|
||||||
}
|
|
||||||
findUniqueOrThrow: {
|
|
||||||
args: Prisma.OnboardingRequestFindUniqueOrThrowArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload>
|
|
||||||
}
|
|
||||||
findFirst: {
|
|
||||||
args: Prisma.OnboardingRequestFindFirstArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload> | null
|
|
||||||
}
|
|
||||||
findFirstOrThrow: {
|
|
||||||
args: Prisma.OnboardingRequestFindFirstOrThrowArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload>
|
|
||||||
}
|
|
||||||
findMany: {
|
|
||||||
args: Prisma.OnboardingRequestFindManyArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload>[]
|
|
||||||
}
|
|
||||||
create: {
|
|
||||||
args: Prisma.OnboardingRequestCreateArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload>
|
|
||||||
}
|
|
||||||
createMany: {
|
|
||||||
args: Prisma.OnboardingRequestCreateManyArgs<ExtArgs>
|
|
||||||
result: BatchPayload
|
|
||||||
}
|
|
||||||
createManyAndReturn: {
|
|
||||||
args: Prisma.OnboardingRequestCreateManyAndReturnArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload>[]
|
|
||||||
}
|
|
||||||
delete: {
|
|
||||||
args: Prisma.OnboardingRequestDeleteArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload>
|
|
||||||
}
|
|
||||||
update: {
|
|
||||||
args: Prisma.OnboardingRequestUpdateArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload>
|
|
||||||
}
|
|
||||||
deleteMany: {
|
|
||||||
args: Prisma.OnboardingRequestDeleteManyArgs<ExtArgs>
|
|
||||||
result: BatchPayload
|
|
||||||
}
|
|
||||||
updateMany: {
|
|
||||||
args: Prisma.OnboardingRequestUpdateManyArgs<ExtArgs>
|
|
||||||
result: BatchPayload
|
|
||||||
}
|
|
||||||
updateManyAndReturn: {
|
|
||||||
args: Prisma.OnboardingRequestUpdateManyAndReturnArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload>[]
|
|
||||||
}
|
|
||||||
upsert: {
|
|
||||||
args: Prisma.OnboardingRequestUpsertArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$OnboardingRequestPayload>
|
|
||||||
}
|
|
||||||
aggregate: {
|
|
||||||
args: Prisma.OnboardingRequestAggregateArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.Optional<Prisma.AggregateOnboardingRequest>
|
|
||||||
}
|
|
||||||
groupBy: {
|
|
||||||
args: Prisma.OnboardingRequestGroupByArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.Optional<Prisma.OnboardingRequestGroupByOutputType>[]
|
|
||||||
}
|
|
||||||
count: {
|
|
||||||
args: Prisma.OnboardingRequestCountArgs<ExtArgs>
|
|
||||||
result: runtime.Types.Utils.Optional<Prisma.OnboardingRequestCountAggregateOutputType> | number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PasswordResetRequest: {
|
PasswordResetRequest: {
|
||||||
payload: Prisma.$PasswordResetRequestPayload<ExtArgs>
|
payload: Prisma.$PasswordResetRequestPayload<ExtArgs>
|
||||||
fields: Prisma.PasswordResetRequestFieldRefs
|
fields: Prisma.PasswordResetRequestFieldRefs
|
||||||
@@ -1806,6 +1731,7 @@ export const CourtBookingScalarFieldEnum = {
|
|||||||
endTime: 'endTime',
|
endTime: 'endTime',
|
||||||
customerName: 'customerName',
|
customerName: 'customerName',
|
||||||
customerPhone: 'customerPhone',
|
customerPhone: 'customerPhone',
|
||||||
|
customerEmail: 'customerEmail',
|
||||||
status: 'status',
|
status: 'status',
|
||||||
createdAt: 'createdAt',
|
createdAt: 'createdAt',
|
||||||
updatedAt: 'updatedAt'
|
updatedAt: 'updatedAt'
|
||||||
@@ -1825,30 +1751,13 @@ export const CourtBookingLogScalarFieldEnum = {
|
|||||||
newStatus: 'newStatus',
|
newStatus: 'newStatus',
|
||||||
customerName: 'customerName',
|
customerName: 'customerName',
|
||||||
customerPhone: 'customerPhone',
|
customerPhone: 'customerPhone',
|
||||||
|
customerEmail: 'customerEmail',
|
||||||
changedAt: 'changedAt'
|
changedAt: 'changedAt'
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export type CourtBookingLogScalarFieldEnum = (typeof CourtBookingLogScalarFieldEnum)[keyof typeof CourtBookingLogScalarFieldEnum]
|
export type CourtBookingLogScalarFieldEnum = (typeof CourtBookingLogScalarFieldEnum)[keyof typeof CourtBookingLogScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
export const OnboardingRequestScalarFieldEnum = {
|
|
||||||
id: 'id',
|
|
||||||
fullName: 'fullName',
|
|
||||||
email: 'email',
|
|
||||||
otpHash: 'otpHash',
|
|
||||||
otpExpiresAt: 'otpExpiresAt',
|
|
||||||
otpAttempts: 'otpAttempts',
|
|
||||||
otpLastSentAt: 'otpLastSentAt',
|
|
||||||
otpResendCount: 'otpResendCount',
|
|
||||||
emailVerifiedAt: 'emailVerifiedAt',
|
|
||||||
completedAt: 'completedAt',
|
|
||||||
createdAt: 'createdAt',
|
|
||||||
updatedAt: 'updatedAt'
|
|
||||||
} as const
|
|
||||||
|
|
||||||
export type OnboardingRequestScalarFieldEnum = (typeof OnboardingRequestScalarFieldEnum)[keyof typeof OnboardingRequestScalarFieldEnum]
|
|
||||||
|
|
||||||
|
|
||||||
export const PasswordResetRequestScalarFieldEnum = {
|
export const PasswordResetRequestScalarFieldEnum = {
|
||||||
id: 'id',
|
id: 'id',
|
||||||
email: 'email',
|
email: 'email',
|
||||||
@@ -2162,7 +2071,6 @@ export type GlobalOmitConfig = {
|
|||||||
courtPriceRule?: Prisma.CourtPriceRuleOmit
|
courtPriceRule?: Prisma.CourtPriceRuleOmit
|
||||||
courtBooking?: Prisma.CourtBookingOmit
|
courtBooking?: Prisma.CourtBookingOmit
|
||||||
courtBookingLog?: Prisma.CourtBookingLogOmit
|
courtBookingLog?: Prisma.CourtBookingLogOmit
|
||||||
onboardingRequest?: Prisma.OnboardingRequestOmit
|
|
||||||
passwordResetRequest?: Prisma.PasswordResetRequestOmit
|
passwordResetRequest?: Prisma.PasswordResetRequestOmit
|
||||||
plan?: Prisma.PlanOmit
|
plan?: Prisma.PlanOmit
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ export const ModelName = {
|
|||||||
CourtPriceRule: 'CourtPriceRule',
|
CourtPriceRule: 'CourtPriceRule',
|
||||||
CourtBooking: 'CourtBooking',
|
CourtBooking: 'CourtBooking',
|
||||||
CourtBookingLog: 'CourtBookingLog',
|
CourtBookingLog: 'CourtBookingLog',
|
||||||
OnboardingRequest: 'OnboardingRequest',
|
|
||||||
PasswordResetRequest: 'PasswordResetRequest',
|
PasswordResetRequest: 'PasswordResetRequest',
|
||||||
Plan: 'Plan'
|
Plan: 'Plan'
|
||||||
} as const
|
} as const
|
||||||
@@ -249,6 +248,7 @@ export const CourtBookingScalarFieldEnum = {
|
|||||||
endTime: 'endTime',
|
endTime: 'endTime',
|
||||||
customerName: 'customerName',
|
customerName: 'customerName',
|
||||||
customerPhone: 'customerPhone',
|
customerPhone: 'customerPhone',
|
||||||
|
customerEmail: 'customerEmail',
|
||||||
status: 'status',
|
status: 'status',
|
||||||
createdAt: 'createdAt',
|
createdAt: 'createdAt',
|
||||||
updatedAt: 'updatedAt'
|
updatedAt: 'updatedAt'
|
||||||
@@ -268,30 +268,13 @@ export const CourtBookingLogScalarFieldEnum = {
|
|||||||
newStatus: 'newStatus',
|
newStatus: 'newStatus',
|
||||||
customerName: 'customerName',
|
customerName: 'customerName',
|
||||||
customerPhone: 'customerPhone',
|
customerPhone: 'customerPhone',
|
||||||
|
customerEmail: 'customerEmail',
|
||||||
changedAt: 'changedAt'
|
changedAt: 'changedAt'
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export type CourtBookingLogScalarFieldEnum = (typeof CourtBookingLogScalarFieldEnum)[keyof typeof CourtBookingLogScalarFieldEnum]
|
export type CourtBookingLogScalarFieldEnum = (typeof CourtBookingLogScalarFieldEnum)[keyof typeof CourtBookingLogScalarFieldEnum]
|
||||||
|
|
||||||
|
|
||||||
export const OnboardingRequestScalarFieldEnum = {
|
|
||||||
id: 'id',
|
|
||||||
fullName: 'fullName',
|
|
||||||
email: 'email',
|
|
||||||
otpHash: 'otpHash',
|
|
||||||
otpExpiresAt: 'otpExpiresAt',
|
|
||||||
otpAttempts: 'otpAttempts',
|
|
||||||
otpLastSentAt: 'otpLastSentAt',
|
|
||||||
otpResendCount: 'otpResendCount',
|
|
||||||
emailVerifiedAt: 'emailVerifiedAt',
|
|
||||||
completedAt: 'completedAt',
|
|
||||||
createdAt: 'createdAt',
|
|
||||||
updatedAt: 'updatedAt'
|
|
||||||
} as const
|
|
||||||
|
|
||||||
export type OnboardingRequestScalarFieldEnum = (typeof OnboardingRequestScalarFieldEnum)[keyof typeof OnboardingRequestScalarFieldEnum]
|
|
||||||
|
|
||||||
|
|
||||||
export const PasswordResetRequestScalarFieldEnum = {
|
export const PasswordResetRequestScalarFieldEnum = {
|
||||||
id: 'id',
|
id: 'id',
|
||||||
email: 'email',
|
email: 'email',
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ export type * from './models/CourtAvailability'
|
|||||||
export type * from './models/CourtPriceRule'
|
export type * from './models/CourtPriceRule'
|
||||||
export type * from './models/CourtBooking'
|
export type * from './models/CourtBooking'
|
||||||
export type * from './models/CourtBookingLog'
|
export type * from './models/CourtBookingLog'
|
||||||
export type * from './models/OnboardingRequest'
|
|
||||||
export type * from './models/PasswordResetRequest'
|
export type * from './models/PasswordResetRequest'
|
||||||
export type * from './models/Plan'
|
export type * from './models/Plan'
|
||||||
export type * from './commonInputTypes'
|
export type * from './commonInputTypes'
|
||||||
@@ -33,6 +33,7 @@ export type CourtBookingMinAggregateOutputType = {
|
|||||||
endTime: string | null
|
endTime: string | null
|
||||||
customerName: string | null
|
customerName: string | null
|
||||||
customerPhone: string | null
|
customerPhone: string | null
|
||||||
|
customerEmail: string | null
|
||||||
status: $Enums.CourtBookingStatus | null
|
status: $Enums.CourtBookingStatus | null
|
||||||
createdAt: Date | null
|
createdAt: Date | null
|
||||||
updatedAt: Date | null
|
updatedAt: Date | null
|
||||||
@@ -47,6 +48,7 @@ export type CourtBookingMaxAggregateOutputType = {
|
|||||||
endTime: string | null
|
endTime: string | null
|
||||||
customerName: string | null
|
customerName: string | null
|
||||||
customerPhone: string | null
|
customerPhone: string | null
|
||||||
|
customerEmail: string | null
|
||||||
status: $Enums.CourtBookingStatus | null
|
status: $Enums.CourtBookingStatus | null
|
||||||
createdAt: Date | null
|
createdAt: Date | null
|
||||||
updatedAt: Date | null
|
updatedAt: Date | null
|
||||||
@@ -61,6 +63,7 @@ export type CourtBookingCountAggregateOutputType = {
|
|||||||
endTime: number
|
endTime: number
|
||||||
customerName: number
|
customerName: number
|
||||||
customerPhone: number
|
customerPhone: number
|
||||||
|
customerEmail: number
|
||||||
status: number
|
status: number
|
||||||
createdAt: number
|
createdAt: number
|
||||||
updatedAt: number
|
updatedAt: number
|
||||||
@@ -77,6 +80,7 @@ export type CourtBookingMinAggregateInputType = {
|
|||||||
endTime?: true
|
endTime?: true
|
||||||
customerName?: true
|
customerName?: true
|
||||||
customerPhone?: true
|
customerPhone?: true
|
||||||
|
customerEmail?: true
|
||||||
status?: true
|
status?: true
|
||||||
createdAt?: true
|
createdAt?: true
|
||||||
updatedAt?: true
|
updatedAt?: true
|
||||||
@@ -91,6 +95,7 @@ export type CourtBookingMaxAggregateInputType = {
|
|||||||
endTime?: true
|
endTime?: true
|
||||||
customerName?: true
|
customerName?: true
|
||||||
customerPhone?: true
|
customerPhone?: true
|
||||||
|
customerEmail?: true
|
||||||
status?: true
|
status?: true
|
||||||
createdAt?: true
|
createdAt?: true
|
||||||
updatedAt?: true
|
updatedAt?: true
|
||||||
@@ -105,6 +110,7 @@ export type CourtBookingCountAggregateInputType = {
|
|||||||
endTime?: true
|
endTime?: true
|
||||||
customerName?: true
|
customerName?: true
|
||||||
customerPhone?: true
|
customerPhone?: true
|
||||||
|
customerEmail?: true
|
||||||
status?: true
|
status?: true
|
||||||
createdAt?: true
|
createdAt?: true
|
||||||
updatedAt?: true
|
updatedAt?: true
|
||||||
@@ -192,6 +198,7 @@ export type CourtBookingGroupByOutputType = {
|
|||||||
endTime: string
|
endTime: string
|
||||||
customerName: string
|
customerName: string
|
||||||
customerPhone: string
|
customerPhone: string
|
||||||
|
customerEmail: string | null
|
||||||
status: $Enums.CourtBookingStatus
|
status: $Enums.CourtBookingStatus
|
||||||
createdAt: Date
|
createdAt: Date
|
||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
@@ -227,6 +234,7 @@ export type CourtBookingWhereInput = {
|
|||||||
endTime?: Prisma.StringFilter<"CourtBooking"> | string
|
endTime?: Prisma.StringFilter<"CourtBooking"> | string
|
||||||
customerName?: Prisma.StringFilter<"CourtBooking"> | string
|
customerName?: Prisma.StringFilter<"CourtBooking"> | string
|
||||||
customerPhone?: Prisma.StringFilter<"CourtBooking"> | string
|
customerPhone?: Prisma.StringFilter<"CourtBooking"> | string
|
||||||
|
customerEmail?: Prisma.StringNullableFilter<"CourtBooking"> | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusFilter<"CourtBooking"> | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusFilter<"CourtBooking"> | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
createdAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
||||||
updatedAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
updatedAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
||||||
@@ -242,6 +250,7 @@ export type CourtBookingOrderByWithRelationInput = {
|
|||||||
endTime?: Prisma.SortOrder
|
endTime?: Prisma.SortOrder
|
||||||
customerName?: Prisma.SortOrder
|
customerName?: Prisma.SortOrder
|
||||||
customerPhone?: Prisma.SortOrder
|
customerPhone?: Prisma.SortOrder
|
||||||
|
customerEmail?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||||
status?: Prisma.SortOrder
|
status?: Prisma.SortOrder
|
||||||
createdAt?: Prisma.SortOrder
|
createdAt?: Prisma.SortOrder
|
||||||
updatedAt?: Prisma.SortOrder
|
updatedAt?: Prisma.SortOrder
|
||||||
@@ -261,6 +270,7 @@ export type CourtBookingWhereUniqueInput = Prisma.AtLeast<{
|
|||||||
endTime?: Prisma.StringFilter<"CourtBooking"> | string
|
endTime?: Prisma.StringFilter<"CourtBooking"> | string
|
||||||
customerName?: Prisma.StringFilter<"CourtBooking"> | string
|
customerName?: Prisma.StringFilter<"CourtBooking"> | string
|
||||||
customerPhone?: Prisma.StringFilter<"CourtBooking"> | string
|
customerPhone?: Prisma.StringFilter<"CourtBooking"> | string
|
||||||
|
customerEmail?: Prisma.StringNullableFilter<"CourtBooking"> | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusFilter<"CourtBooking"> | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusFilter<"CourtBooking"> | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
createdAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
||||||
updatedAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
updatedAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
||||||
@@ -276,6 +286,7 @@ export type CourtBookingOrderByWithAggregationInput = {
|
|||||||
endTime?: Prisma.SortOrder
|
endTime?: Prisma.SortOrder
|
||||||
customerName?: Prisma.SortOrder
|
customerName?: Prisma.SortOrder
|
||||||
customerPhone?: Prisma.SortOrder
|
customerPhone?: Prisma.SortOrder
|
||||||
|
customerEmail?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||||
status?: Prisma.SortOrder
|
status?: Prisma.SortOrder
|
||||||
createdAt?: Prisma.SortOrder
|
createdAt?: Prisma.SortOrder
|
||||||
updatedAt?: Prisma.SortOrder
|
updatedAt?: Prisma.SortOrder
|
||||||
@@ -296,6 +307,7 @@ export type CourtBookingScalarWhereWithAggregatesInput = {
|
|||||||
endTime?: Prisma.StringWithAggregatesFilter<"CourtBooking"> | string
|
endTime?: Prisma.StringWithAggregatesFilter<"CourtBooking"> | string
|
||||||
customerName?: Prisma.StringWithAggregatesFilter<"CourtBooking"> | string
|
customerName?: Prisma.StringWithAggregatesFilter<"CourtBooking"> | string
|
||||||
customerPhone?: Prisma.StringWithAggregatesFilter<"CourtBooking"> | string
|
customerPhone?: Prisma.StringWithAggregatesFilter<"CourtBooking"> | string
|
||||||
|
customerEmail?: Prisma.StringNullableWithAggregatesFilter<"CourtBooking"> | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusWithAggregatesFilter<"CourtBooking"> | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusWithAggregatesFilter<"CourtBooking"> | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeWithAggregatesFilter<"CourtBooking"> | Date | string
|
createdAt?: Prisma.DateTimeWithAggregatesFilter<"CourtBooking"> | Date | string
|
||||||
updatedAt?: Prisma.DateTimeWithAggregatesFilter<"CourtBooking"> | Date | string
|
updatedAt?: Prisma.DateTimeWithAggregatesFilter<"CourtBooking"> | Date | string
|
||||||
@@ -309,6 +321,7 @@ export type CourtBookingCreateInput = {
|
|||||||
endTime: string
|
endTime: string
|
||||||
customerName: string
|
customerName: string
|
||||||
customerPhone: string
|
customerPhone: string
|
||||||
|
customerEmail?: string | null
|
||||||
status?: $Enums.CourtBookingStatus
|
status?: $Enums.CourtBookingStatus
|
||||||
createdAt?: Date | string
|
createdAt?: Date | string
|
||||||
updatedAt?: Date | string
|
updatedAt?: Date | string
|
||||||
@@ -324,6 +337,7 @@ export type CourtBookingUncheckedCreateInput = {
|
|||||||
endTime: string
|
endTime: string
|
||||||
customerName: string
|
customerName: string
|
||||||
customerPhone: string
|
customerPhone: string
|
||||||
|
customerEmail?: string | null
|
||||||
status?: $Enums.CourtBookingStatus
|
status?: $Enums.CourtBookingStatus
|
||||||
createdAt?: Date | string
|
createdAt?: Date | string
|
||||||
updatedAt?: Date | string
|
updatedAt?: Date | string
|
||||||
@@ -337,6 +351,7 @@ export type CourtBookingUpdateInput = {
|
|||||||
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
|
customerEmail?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
@@ -352,6 +367,7 @@ export type CourtBookingUncheckedUpdateInput = {
|
|||||||
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
|
customerEmail?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
@@ -366,6 +382,7 @@ export type CourtBookingCreateManyInput = {
|
|||||||
endTime: string
|
endTime: string
|
||||||
customerName: string
|
customerName: string
|
||||||
customerPhone: string
|
customerPhone: string
|
||||||
|
customerEmail?: string | null
|
||||||
status?: $Enums.CourtBookingStatus
|
status?: $Enums.CourtBookingStatus
|
||||||
createdAt?: Date | string
|
createdAt?: Date | string
|
||||||
updatedAt?: Date | string
|
updatedAt?: Date | string
|
||||||
@@ -379,6 +396,7 @@ export type CourtBookingUpdateManyMutationInput = {
|
|||||||
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
|
customerEmail?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
@@ -393,6 +411,7 @@ export type CourtBookingUncheckedUpdateManyInput = {
|
|||||||
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
|
customerEmail?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
@@ -423,6 +442,7 @@ export type CourtBookingCountOrderByAggregateInput = {
|
|||||||
endTime?: Prisma.SortOrder
|
endTime?: Prisma.SortOrder
|
||||||
customerName?: Prisma.SortOrder
|
customerName?: Prisma.SortOrder
|
||||||
customerPhone?: Prisma.SortOrder
|
customerPhone?: Prisma.SortOrder
|
||||||
|
customerEmail?: Prisma.SortOrder
|
||||||
status?: Prisma.SortOrder
|
status?: Prisma.SortOrder
|
||||||
createdAt?: Prisma.SortOrder
|
createdAt?: Prisma.SortOrder
|
||||||
updatedAt?: Prisma.SortOrder
|
updatedAt?: Prisma.SortOrder
|
||||||
@@ -437,6 +457,7 @@ export type CourtBookingMaxOrderByAggregateInput = {
|
|||||||
endTime?: Prisma.SortOrder
|
endTime?: Prisma.SortOrder
|
||||||
customerName?: Prisma.SortOrder
|
customerName?: Prisma.SortOrder
|
||||||
customerPhone?: Prisma.SortOrder
|
customerPhone?: Prisma.SortOrder
|
||||||
|
customerEmail?: Prisma.SortOrder
|
||||||
status?: Prisma.SortOrder
|
status?: Prisma.SortOrder
|
||||||
createdAt?: Prisma.SortOrder
|
createdAt?: Prisma.SortOrder
|
||||||
updatedAt?: Prisma.SortOrder
|
updatedAt?: Prisma.SortOrder
|
||||||
@@ -451,6 +472,7 @@ export type CourtBookingMinOrderByAggregateInput = {
|
|||||||
endTime?: Prisma.SortOrder
|
endTime?: Prisma.SortOrder
|
||||||
customerName?: Prisma.SortOrder
|
customerName?: Prisma.SortOrder
|
||||||
customerPhone?: Prisma.SortOrder
|
customerPhone?: Prisma.SortOrder
|
||||||
|
customerEmail?: Prisma.SortOrder
|
||||||
status?: Prisma.SortOrder
|
status?: Prisma.SortOrder
|
||||||
createdAt?: Prisma.SortOrder
|
createdAt?: Prisma.SortOrder
|
||||||
updatedAt?: Prisma.SortOrder
|
updatedAt?: Prisma.SortOrder
|
||||||
@@ -510,6 +532,7 @@ export type CourtBookingCreateWithoutCourtInput = {
|
|||||||
endTime: string
|
endTime: string
|
||||||
customerName: string
|
customerName: string
|
||||||
customerPhone: string
|
customerPhone: string
|
||||||
|
customerEmail?: string | null
|
||||||
status?: $Enums.CourtBookingStatus
|
status?: $Enums.CourtBookingStatus
|
||||||
createdAt?: Date | string
|
createdAt?: Date | string
|
||||||
updatedAt?: Date | string
|
updatedAt?: Date | string
|
||||||
@@ -523,6 +546,7 @@ export type CourtBookingUncheckedCreateWithoutCourtInput = {
|
|||||||
endTime: string
|
endTime: string
|
||||||
customerName: string
|
customerName: string
|
||||||
customerPhone: string
|
customerPhone: string
|
||||||
|
customerEmail?: string | null
|
||||||
status?: $Enums.CourtBookingStatus
|
status?: $Enums.CourtBookingStatus
|
||||||
createdAt?: Date | string
|
createdAt?: Date | string
|
||||||
updatedAt?: Date | string
|
updatedAt?: Date | string
|
||||||
@@ -566,6 +590,7 @@ export type CourtBookingScalarWhereInput = {
|
|||||||
endTime?: Prisma.StringFilter<"CourtBooking"> | string
|
endTime?: Prisma.StringFilter<"CourtBooking"> | string
|
||||||
customerName?: Prisma.StringFilter<"CourtBooking"> | string
|
customerName?: Prisma.StringFilter<"CourtBooking"> | string
|
||||||
customerPhone?: Prisma.StringFilter<"CourtBooking"> | string
|
customerPhone?: Prisma.StringFilter<"CourtBooking"> | string
|
||||||
|
customerEmail?: Prisma.StringNullableFilter<"CourtBooking"> | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusFilter<"CourtBooking"> | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusFilter<"CourtBooking"> | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
createdAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
||||||
updatedAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
updatedAt?: Prisma.DateTimeFilter<"CourtBooking"> | Date | string
|
||||||
@@ -579,6 +604,7 @@ export type CourtBookingCreateManyCourtInput = {
|
|||||||
endTime: string
|
endTime: string
|
||||||
customerName: string
|
customerName: string
|
||||||
customerPhone: string
|
customerPhone: string
|
||||||
|
customerEmail?: string | null
|
||||||
status?: $Enums.CourtBookingStatus
|
status?: $Enums.CourtBookingStatus
|
||||||
createdAt?: Date | string
|
createdAt?: Date | string
|
||||||
updatedAt?: Date | string
|
updatedAt?: Date | string
|
||||||
@@ -592,6 +618,7 @@ export type CourtBookingUpdateWithoutCourtInput = {
|
|||||||
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
|
customerEmail?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
@@ -605,6 +632,7 @@ export type CourtBookingUncheckedUpdateWithoutCourtInput = {
|
|||||||
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
|
customerEmail?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
@@ -618,6 +646,7 @@ export type CourtBookingUncheckedUpdateManyWithoutCourtInput = {
|
|||||||
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
endTime?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
customerName?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
customerPhone?: Prisma.StringFieldUpdateOperationsInput | string
|
||||||
|
customerEmail?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||||
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
status?: Prisma.EnumCourtBookingStatusFieldUpdateOperationsInput | $Enums.CourtBookingStatus
|
||||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||||
@@ -634,6 +663,7 @@ export type CourtBookingSelect<ExtArgs extends runtime.Types.Extensions.Internal
|
|||||||
endTime?: boolean
|
endTime?: boolean
|
||||||
customerName?: boolean
|
customerName?: boolean
|
||||||
customerPhone?: boolean
|
customerPhone?: boolean
|
||||||
|
customerEmail?: boolean
|
||||||
status?: boolean
|
status?: boolean
|
||||||
createdAt?: boolean
|
createdAt?: boolean
|
||||||
updatedAt?: boolean
|
updatedAt?: boolean
|
||||||
@@ -649,6 +679,7 @@ export type CourtBookingSelectCreateManyAndReturn<ExtArgs extends runtime.Types.
|
|||||||
endTime?: boolean
|
endTime?: boolean
|
||||||
customerName?: boolean
|
customerName?: boolean
|
||||||
customerPhone?: boolean
|
customerPhone?: boolean
|
||||||
|
customerEmail?: boolean
|
||||||
status?: boolean
|
status?: boolean
|
||||||
createdAt?: boolean
|
createdAt?: boolean
|
||||||
updatedAt?: boolean
|
updatedAt?: boolean
|
||||||
@@ -664,6 +695,7 @@ export type CourtBookingSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.
|
|||||||
endTime?: boolean
|
endTime?: boolean
|
||||||
customerName?: boolean
|
customerName?: boolean
|
||||||
customerPhone?: boolean
|
customerPhone?: boolean
|
||||||
|
customerEmail?: boolean
|
||||||
status?: boolean
|
status?: boolean
|
||||||
createdAt?: boolean
|
createdAt?: boolean
|
||||||
updatedAt?: boolean
|
updatedAt?: boolean
|
||||||
@@ -679,12 +711,13 @@ export type CourtBookingSelectScalar = {
|
|||||||
endTime?: boolean
|
endTime?: boolean
|
||||||
customerName?: boolean
|
customerName?: boolean
|
||||||
customerPhone?: boolean
|
customerPhone?: boolean
|
||||||
|
customerEmail?: boolean
|
||||||
status?: boolean
|
status?: boolean
|
||||||
createdAt?: boolean
|
createdAt?: boolean
|
||||||
updatedAt?: boolean
|
updatedAt?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CourtBookingOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "bookingCode" | "courtId" | "bookingDate" | "startTime" | "endTime" | "customerName" | "customerPhone" | "status" | "createdAt" | "updatedAt", ExtArgs["result"]["courtBooking"]>
|
export type CourtBookingOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "bookingCode" | "courtId" | "bookingDate" | "startTime" | "endTime" | "customerName" | "customerPhone" | "customerEmail" | "status" | "createdAt" | "updatedAt", ExtArgs["result"]["courtBooking"]>
|
||||||
export type CourtBookingInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
export type CourtBookingInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||||
court?: boolean | Prisma.CourtDefaultArgs<ExtArgs>
|
court?: boolean | Prisma.CourtDefaultArgs<ExtArgs>
|
||||||
}
|
}
|
||||||
@@ -709,6 +742,7 @@ export type $CourtBookingPayload<ExtArgs extends runtime.Types.Extensions.Intern
|
|||||||
endTime: string
|
endTime: string
|
||||||
customerName: string
|
customerName: string
|
||||||
customerPhone: string
|
customerPhone: string
|
||||||
|
customerEmail: string | null
|
||||||
status: $Enums.CourtBookingStatus
|
status: $Enums.CourtBookingStatus
|
||||||
createdAt: Date
|
createdAt: Date
|
||||||
updatedAt: Date
|
updatedAt: Date
|
||||||
@@ -1144,6 +1178,7 @@ export interface CourtBookingFieldRefs {
|
|||||||
readonly endTime: Prisma.FieldRef<"CourtBooking", 'String'>
|
readonly endTime: Prisma.FieldRef<"CourtBooking", 'String'>
|
||||||
readonly customerName: Prisma.FieldRef<"CourtBooking", 'String'>
|
readonly customerName: Prisma.FieldRef<"CourtBooking", 'String'>
|
||||||
readonly customerPhone: Prisma.FieldRef<"CourtBooking", 'String'>
|
readonly customerPhone: Prisma.FieldRef<"CourtBooking", 'String'>
|
||||||
|
readonly customerEmail: Prisma.FieldRef<"CourtBooking", 'String'>
|
||||||
readonly status: Prisma.FieldRef<"CourtBooking", 'CourtBookingStatus'>
|
readonly status: Prisma.FieldRef<"CourtBooking", 'CourtBookingStatus'>
|
||||||
readonly createdAt: Prisma.FieldRef<"CourtBooking", 'DateTime'>
|
readonly createdAt: Prisma.FieldRef<"CourtBooking", 'DateTime'>
|
||||||
readonly updatedAt: Prisma.FieldRef<"CourtBooking", 'DateTime'>
|
readonly updatedAt: Prisma.FieldRef<"CourtBooking", 'DateTime'>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -31,11 +31,14 @@ export const auth = betterAuth({
|
|||||||
sendOnSignUp: true,
|
sendOnSignUp: true,
|
||||||
autoSignInAfterVerification: true,
|
autoSignInAfterVerification: true,
|
||||||
sendVerificationEmail: async ({ user, url }) => {
|
sendVerificationEmail: async ({ user, url }) => {
|
||||||
|
const verificationUrl = new URL(url);
|
||||||
|
const appUrl = process.env.APP_BASE_URL ?? 'http://localhost:5173';
|
||||||
|
verificationUrl.searchParams.set('callbackURL', appUrl);
|
||||||
await sendMail({
|
await sendMail({
|
||||||
to: user.email,
|
to: user.email,
|
||||||
subject: 'Verificá tu email en Playzer',
|
subject: 'Verificá tu email en Playzer',
|
||||||
html: `Hacé click para verificar tu email: <a href="${url}">${url}</a>`,
|
html: `Hacé click para verificar tu email: <a href="${verificationUrl.toString()}">${verificationUrl.toString()}</a>`,
|
||||||
text: `Hacé click para verificar tu email: ${url}`,
|
text: `Hacé click para verificar tu email: ${verificationUrl.toString()}`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
AdminBookingServiceError,
|
AdminBookingServiceError,
|
||||||
createAdminBooking,
|
createAdminBooking,
|
||||||
} from '@/modules/admin-booking/services/admin-booking.service';
|
} from '@/modules/admin-booking/services/admin-booking.service';
|
||||||
|
import { sendBookingConfirmation } from '@/services/booking-email.service';
|
||||||
import type { AppContext } from '@/types/hono';
|
import type { AppContext } from '@/types/hono';
|
||||||
import type { CreateAdminBookingInput } from '@repo/api-contract';
|
import type { CreateAdminBookingInput } from '@repo/api-contract';
|
||||||
|
|
||||||
@@ -14,6 +15,20 @@ export async function createAdminBookingHandler(c: AppContext) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const booking = await createAdminBooking(user.id, complexId, payload);
|
const booking = await createAdminBooking(user.id, complexId, payload);
|
||||||
|
|
||||||
|
void sendBookingConfirmation({
|
||||||
|
bookingCode: booking.bookingCode,
|
||||||
|
complexName: booking.complexName,
|
||||||
|
date: booking.date,
|
||||||
|
startTime: booking.startTime,
|
||||||
|
endTime: booking.endTime,
|
||||||
|
courtName: booking.courtName,
|
||||||
|
sportName: booking.sport.name,
|
||||||
|
customerName: booking.customerName,
|
||||||
|
customerEmail: booking.customerEmail,
|
||||||
|
price: booking.price,
|
||||||
|
});
|
||||||
|
|
||||||
return c.json(booking, 201);
|
return c.json(booking, 201);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof AdminBookingServiceError) {
|
if (error instanceof AdminBookingServiceError) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
AdminBookingServiceError,
|
AdminBookingServiceError,
|
||||||
updateAdminBookingStatus,
|
updateAdminBookingStatus,
|
||||||
} from '@/modules/admin-booking/services/admin-booking.service';
|
} from '@/modules/admin-booking/services/admin-booking.service';
|
||||||
|
import { sendBookingCancelled, sendBookingNoShow } from '@/services/booking-email.service';
|
||||||
import type { AppContext } from '@/types/hono';
|
import type { AppContext } from '@/types/hono';
|
||||||
import type { UpdateAdminBookingStatusInput } from '@repo/api-contract';
|
import type { UpdateAdminBookingStatusInput } from '@repo/api-contract';
|
||||||
|
|
||||||
@@ -14,6 +15,33 @@ export async function updateAdminBookingStatusHandler(c: AppContext) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const booking = await updateAdminBookingStatus(user.id, id, payload);
|
const booking = await updateAdminBookingStatus(user.id, id, payload);
|
||||||
|
|
||||||
|
if (payload.status === 'CANCELLED') {
|
||||||
|
void sendBookingCancelled({
|
||||||
|
bookingCode: booking.bookingCode,
|
||||||
|
complexName: booking.complexName,
|
||||||
|
date: booking.date,
|
||||||
|
startTime: booking.startTime,
|
||||||
|
endTime: booking.endTime,
|
||||||
|
courtName: booking.courtName,
|
||||||
|
sportName: booking.sport.name,
|
||||||
|
customerName: booking.customerName,
|
||||||
|
customerEmail: booking.customerEmail,
|
||||||
|
});
|
||||||
|
} else if (payload.status === 'NOSHOW') {
|
||||||
|
void sendBookingNoShow({
|
||||||
|
bookingCode: booking.bookingCode,
|
||||||
|
complexName: booking.complexName,
|
||||||
|
date: booking.date,
|
||||||
|
startTime: booking.startTime,
|
||||||
|
endTime: booking.endTime,
|
||||||
|
courtName: booking.courtName,
|
||||||
|
sportName: booking.sport.name,
|
||||||
|
customerName: booking.customerName,
|
||||||
|
customerEmail: booking.customerEmail,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return c.json(booking);
|
return c.json(booking);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof AdminBookingServiceError) {
|
if (error instanceof AdminBookingServiceError) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { randomInt } from 'node:crypto';
|
|||||||
import { CourtBookingStatus } from '@/generated/prisma/enums';
|
import { CourtBookingStatus } from '@/generated/prisma/enums';
|
||||||
import { db } from '@/lib/prisma';
|
import { db } from '@/lib/prisma';
|
||||||
import { evaluatePlanUsage, parsePlanRules } from '@/modules/plan/services/plan-rules.service';
|
import { evaluatePlanUsage, parsePlanRules } from '@/modules/plan/services/plan-rules.service';
|
||||||
|
import type { DayOfWeek } from '@repo/api-contract';
|
||||||
import type {
|
import type {
|
||||||
AdminBooking,
|
AdminBooking,
|
||||||
CreateAdminBookingInput,
|
CreateAdminBookingInput,
|
||||||
@@ -156,6 +157,40 @@ async function ensureComplexAccess(complexId: string, userId: string) {
|
|||||||
return complexUser.complex;
|
return complexUser.complex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolvePrice(
|
||||||
|
court: {
|
||||||
|
basePrice: unknown;
|
||||||
|
priceRules: Array<{
|
||||||
|
dayOfWeek: string | null;
|
||||||
|
startTime: string | null;
|
||||||
|
endTime: string | null;
|
||||||
|
price: unknown;
|
||||||
|
}>;
|
||||||
|
},
|
||||||
|
dayOfWeek: string,
|
||||||
|
startTime: string,
|
||||||
|
endTime: string
|
||||||
|
): number {
|
||||||
|
const slotStart = toMinutes(startTime);
|
||||||
|
const slotEnd = toMinutes(endTime);
|
||||||
|
|
||||||
|
const matchingRules = court.priceRules
|
||||||
|
.filter((rule) => {
|
||||||
|
if (rule.dayOfWeek && rule.dayOfWeek !== dayOfWeek) return false;
|
||||||
|
if (!rule.startTime || !rule.endTime) return true;
|
||||||
|
return slotStart >= toMinutes(rule.startTime) && slotEnd <= toMinutes(rule.endTime);
|
||||||
|
})
|
||||||
|
.sort((first, second) => {
|
||||||
|
const firstSpecificity =
|
||||||
|
(first.dayOfWeek ? 2 : 0) + (first.startTime && first.endTime ? 1 : 0);
|
||||||
|
const secondSpecificity =
|
||||||
|
(second.dayOfWeek ? 2 : 0) + (second.startTime && second.endTime ? 1 : 0);
|
||||||
|
return secondSpecificity - firstSpecificity;
|
||||||
|
});
|
||||||
|
|
||||||
|
return Number(matchingRules[0]?.price ?? court.basePrice);
|
||||||
|
}
|
||||||
|
|
||||||
function mapBookingResponse(booking: {
|
function mapBookingResponse(booking: {
|
||||||
id: string;
|
id: string;
|
||||||
bookingCode: string;
|
bookingCode: string;
|
||||||
@@ -164,6 +199,7 @@ function mapBookingResponse(booking: {
|
|||||||
endTime: string;
|
endTime: string;
|
||||||
customerName: string;
|
customerName: string;
|
||||||
customerPhone: string;
|
customerPhone: string;
|
||||||
|
customerEmail: string | null;
|
||||||
status: 'CONFIRMED' | 'CANCELLED' | 'COMPLETED' | 'NOSHOW';
|
status: 'CONFIRMED' | 'CANCELLED' | 'COMPLETED' | 'NOSHOW';
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
@@ -180,6 +216,7 @@ function mapBookingResponse(booking: {
|
|||||||
slug: string;
|
slug: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
price?: number;
|
||||||
}): AdminBooking {
|
}): AdminBooking {
|
||||||
return {
|
return {
|
||||||
id: booking.id,
|
id: booking.id,
|
||||||
@@ -198,6 +235,8 @@ function mapBookingResponse(booking: {
|
|||||||
endTime: booking.endTime,
|
endTime: booking.endTime,
|
||||||
customerName: booking.customerName,
|
customerName: booking.customerName,
|
||||||
customerPhone: booking.customerPhone,
|
customerPhone: booking.customerPhone,
|
||||||
|
customerEmail: booking.customerEmail ?? undefined,
|
||||||
|
price: booking.price ?? 0,
|
||||||
status: booking.status,
|
status: booking.status,
|
||||||
createdAt: booking.createdAt.toISOString(),
|
createdAt: booking.createdAt.toISOString(),
|
||||||
updatedAt: booking.updatedAt.toISOString(),
|
updatedAt: booking.updatedAt.toISOString(),
|
||||||
@@ -258,6 +297,16 @@ export async function createAdminBooking(
|
|||||||
input: CreateAdminBookingInput
|
input: CreateAdminBookingInput
|
||||||
) {
|
) {
|
||||||
const complex = await ensureComplexAccess(complexId, userId);
|
const complex = await ensureComplexAccess(complexId, userId);
|
||||||
|
|
||||||
|
const adminUser = await db.user.findUnique({
|
||||||
|
where: { id: userId },
|
||||||
|
select: { emailVerified: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!adminUser?.emailVerified) {
|
||||||
|
throw new AdminBookingServiceError('Debés verificar tu email para poder crear reservas.', 403);
|
||||||
|
}
|
||||||
|
|
||||||
const bookingDate = parseIsoDate(input.date);
|
const bookingDate = parseIsoDate(input.date);
|
||||||
const dayOfWeek = getDayOfWeek(bookingDate);
|
const dayOfWeek = getDayOfWeek(bookingDate);
|
||||||
|
|
||||||
@@ -282,6 +331,10 @@ export async function createAdminBooking(
|
|||||||
slug: true,
|
slug: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
priceRules: {
|
||||||
|
where: { isActive: true },
|
||||||
|
orderBy: [{ dayOfWeek: 'asc' }, { startTime: 'asc' }],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -371,6 +424,7 @@ export async function createAdminBooking(
|
|||||||
endTime: selectedSlot.endTime,
|
endTime: selectedSlot.endTime,
|
||||||
customerName: input.customerName.trim(),
|
customerName: input.customerName.trim(),
|
||||||
customerPhone: input.customerPhone.trim(),
|
customerPhone: input.customerPhone.trim(),
|
||||||
|
customerEmail: input.customerEmail?.trim() || null,
|
||||||
status: 'CONFIRMED',
|
status: 'CONFIRMED',
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
@@ -397,7 +451,9 @@ export async function createAdminBooking(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return mapBookingResponse(booking);
|
const price = resolvePrice(court, dayOfWeek, selectedSlot.startTime, selectedSlot.endTime);
|
||||||
|
|
||||||
|
return mapBookingResponse({ ...booking, price });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof AdminBookingServiceError) {
|
if (error instanceof AdminBookingServiceError) {
|
||||||
throw error;
|
throw error;
|
||||||
@@ -511,6 +567,7 @@ export async function updateAdminBookingStatus(
|
|||||||
endTime: booking.endTime,
|
endTime: booking.endTime,
|
||||||
customerName: booking.customerName,
|
customerName: booking.customerName,
|
||||||
customerPhone: booking.customerPhone,
|
customerPhone: booking.customerPhone,
|
||||||
|
customerEmail: booking.customerEmail,
|
||||||
previousStatus: booking.status,
|
previousStatus: booking.status,
|
||||||
newStatus: input.status,
|
newStatus: input.status,
|
||||||
changedAt: new Date(),
|
changedAt: new Date(),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
PublicBookingServiceError,
|
PublicBookingServiceError,
|
||||||
createPublicBooking,
|
createPublicBooking,
|
||||||
} from '@/modules/public-booking/services/public-booking.service';
|
} from '@/modules/public-booking/services/public-booking.service';
|
||||||
|
import { sendBookingConfirmation } from '@/services/booking-email.service';
|
||||||
import type { AppContext } from '@/types/hono';
|
import type { AppContext } from '@/types/hono';
|
||||||
import type { CreatePublicBookingInput } from '@repo/api-contract';
|
import type { CreatePublicBookingInput } from '@repo/api-contract';
|
||||||
|
|
||||||
@@ -30,6 +31,19 @@ export async function createPublicBookingHandler(c: AppContext) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void sendBookingConfirmation({
|
||||||
|
bookingCode: booking.bookingCode,
|
||||||
|
complexName: booking.complexName,
|
||||||
|
date: booking.date,
|
||||||
|
startTime: booking.startTime,
|
||||||
|
endTime: booking.endTime,
|
||||||
|
courtName: booking.courtName,
|
||||||
|
sportName: booking.sport.name,
|
||||||
|
customerName: booking.customerName,
|
||||||
|
customerEmail: booking.customerEmail,
|
||||||
|
price: booking.price,
|
||||||
|
});
|
||||||
|
|
||||||
return c.json(booking, 201);
|
return c.json(booking, 201);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof PublicBookingServiceError) {
|
if (error instanceof PublicBookingServiceError) {
|
||||||
|
|||||||
@@ -13,6 +13,16 @@ type Slot = {
|
|||||||
endTime: string;
|
endTime: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type PriceableCourt = {
|
||||||
|
basePrice: unknown;
|
||||||
|
priceRules: Array<{
|
||||||
|
dayOfWeek: DayOfWeek | null;
|
||||||
|
startTime: string | null;
|
||||||
|
endTime: string | null;
|
||||||
|
price: unknown;
|
||||||
|
}>;
|
||||||
|
};
|
||||||
|
|
||||||
type ComplexWithPublicBookingData = Awaited<ReturnType<typeof getComplexWithBookingData>>;
|
type ComplexWithPublicBookingData = Awaited<ReturnType<typeof getComplexWithBookingData>>;
|
||||||
|
|
||||||
const DAY_OF_WEEK_BY_INDEX: DayOfWeek[] = [
|
const DAY_OF_WEEK_BY_INDEX: DayOfWeek[] = [
|
||||||
@@ -202,6 +212,10 @@ async function getComplexWithBookingData(complexSlug: string) {
|
|||||||
availabilities: {
|
availabilities: {
|
||||||
orderBy: [{ dayOfWeek: 'asc' }, { startTime: 'asc' }],
|
orderBy: [{ dayOfWeek: 'asc' }, { startTime: 'asc' }],
|
||||||
},
|
},
|
||||||
|
priceRules: {
|
||||||
|
where: { isActive: true },
|
||||||
|
orderBy: [{ dayOfWeek: 'asc' }, { startTime: 'asc' }],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
orderBy: { createdAt: 'asc' },
|
orderBy: { createdAt: 'asc' },
|
||||||
},
|
},
|
||||||
@@ -226,6 +240,33 @@ async function getComplexWithBookingData(complexSlug: string) {
|
|||||||
return complex;
|
return complex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveSlotPrice(court: PriceableCourt, dayOfWeek: DayOfWeek, slot: Slot): number {
|
||||||
|
const slotStart = toMinutes(slot.startTime);
|
||||||
|
const slotEnd = toMinutes(slot.endTime);
|
||||||
|
const matchingRules = court.priceRules
|
||||||
|
.filter((rule) => {
|
||||||
|
if (rule.dayOfWeek && rule.dayOfWeek !== dayOfWeek) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rule.startTime || !rule.endTime) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return slotStart >= toMinutes(rule.startTime) && slotEnd <= toMinutes(rule.endTime);
|
||||||
|
})
|
||||||
|
.sort((first, second) => {
|
||||||
|
const firstSpecificity =
|
||||||
|
(first.dayOfWeek ? 2 : 0) + (first.startTime && first.endTime ? 1 : 0);
|
||||||
|
const secondSpecificity =
|
||||||
|
(second.dayOfWeek ? 2 : 0) + (second.startTime && second.endTime ? 1 : 0);
|
||||||
|
|
||||||
|
return secondSpecificity - firstSpecificity;
|
||||||
|
});
|
||||||
|
|
||||||
|
return Number(matchingRules[0]?.price ?? court.basePrice);
|
||||||
|
}
|
||||||
|
|
||||||
function mapBookingResponse(input: {
|
function mapBookingResponse(input: {
|
||||||
bookingId: string;
|
bookingId: string;
|
||||||
bookingCode: string;
|
bookingCode: string;
|
||||||
@@ -235,6 +276,8 @@ function mapBookingResponse(input: {
|
|||||||
endTime: string;
|
endTime: string;
|
||||||
customerName: string;
|
customerName: string;
|
||||||
customerPhone: string;
|
customerPhone: string;
|
||||||
|
customerEmail: string | null;
|
||||||
|
price: number;
|
||||||
status: 'CONFIRMED' | 'CANCELLED' | 'COMPLETED' | 'NOSHOW';
|
status: 'CONFIRMED' | 'CANCELLED' | 'COMPLETED' | 'NOSHOW';
|
||||||
court: {
|
court: {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -263,7 +306,9 @@ function mapBookingResponse(input: {
|
|||||||
endTime: input.endTime,
|
endTime: input.endTime,
|
||||||
customerName: input.customerName,
|
customerName: input.customerName,
|
||||||
customerPhone: input.customerPhone,
|
customerPhone: input.customerPhone,
|
||||||
|
customerEmail: input.customerEmail ?? undefined,
|
||||||
status: input.status,
|
status: input.status,
|
||||||
|
price: input.price,
|
||||||
createdAt: input.createdAt.toISOString(),
|
createdAt: input.createdAt.toISOString(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -284,11 +329,17 @@ export async function getPublicBookingConfirmation(complexSlug: string, bookingC
|
|||||||
bookingDate: true,
|
bookingDate: true,
|
||||||
startTime: true,
|
startTime: true,
|
||||||
endTime: true,
|
endTime: true,
|
||||||
|
customerEmail: true,
|
||||||
status: true,
|
status: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
court: {
|
court: {
|
||||||
select: {
|
select: {
|
||||||
name: true,
|
name: true,
|
||||||
|
basePrice: true,
|
||||||
|
priceRules: {
|
||||||
|
where: { isActive: true },
|
||||||
|
orderBy: [{ dayOfWeek: 'asc' }, { startTime: 'asc' }],
|
||||||
|
},
|
||||||
sport: {
|
sport: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
@@ -299,6 +350,7 @@ export async function getPublicBookingConfirmation(complexSlug: string, bookingC
|
|||||||
complex: {
|
complex: {
|
||||||
select: {
|
select: {
|
||||||
complexName: true,
|
complexName: true,
|
||||||
|
physicalAddress: true,
|
||||||
complexSlug: true,
|
complexSlug: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -311,13 +363,22 @@ export async function getPublicBookingConfirmation(complexSlug: string, bookingC
|
|||||||
throw new PublicBookingServiceError('Reserva no encontrada.', 404);
|
throw new PublicBookingServiceError('Reserva no encontrada.', 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const date = formatIsoDate(booking.bookingDate);
|
||||||
|
const { dayOfWeek } = parseIsoDate(date);
|
||||||
|
const price = resolveSlotPrice(booking.court, dayOfWeek, {
|
||||||
|
startTime: booking.startTime,
|
||||||
|
endTime: booking.endTime,
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bookingCode: booking.bookingCode,
|
bookingCode: booking.bookingCode,
|
||||||
complexName: booking.court.complex.complexName,
|
complexName: booking.court.complex.complexName,
|
||||||
|
complexAddress: booking.court.complex.physicalAddress ?? undefined,
|
||||||
complexSlug: booking.court.complex.complexSlug,
|
complexSlug: booking.court.complex.complexSlug,
|
||||||
date: formatIsoDate(booking.bookingDate),
|
date,
|
||||||
startTime: booking.startTime,
|
startTime: booking.startTime,
|
||||||
endTime: booking.endTime,
|
endTime: booking.endTime,
|
||||||
|
price,
|
||||||
courtName: booking.court.name,
|
courtName: booking.court.name,
|
||||||
sport: {
|
sport: {
|
||||||
id: booking.court.sport.id,
|
id: booking.court.sport.id,
|
||||||
@@ -325,13 +386,39 @@ export async function getPublicBookingConfirmation(complexSlug: string, bookingC
|
|||||||
slug: booking.court.sport.slug,
|
slug: booking.court.sport.slug,
|
||||||
},
|
},
|
||||||
status: booking.status,
|
status: booking.status,
|
||||||
|
customerEmail: booking.customerEmail ?? undefined,
|
||||||
createdAt: booking.createdAt.toISOString(),
|
createdAt: booking.createdAt.toISOString(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function hasVerifiedAdmin(complexId: string): Promise<boolean> {
|
||||||
|
const verifiedAdmin = await db.complexUser.findFirst({
|
||||||
|
where: {
|
||||||
|
complexId,
|
||||||
|
role: 'ADMIN',
|
||||||
|
user: { emailVerified: true },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return verifiedAdmin !== null;
|
||||||
|
}
|
||||||
|
|
||||||
export async function listPublicAvailability(complexSlug: string, query: PublicAvailabilityQuery) {
|
export async function listPublicAvailability(complexSlug: string, query: PublicAvailabilityQuery) {
|
||||||
const { bookingDate, dayOfWeek } = parseIsoDate(query.date);
|
const { bookingDate, dayOfWeek } = parseIsoDate(query.date);
|
||||||
const complex = await getComplexWithBookingData(complexSlug);
|
const complex = await getComplexWithBookingData(complexSlug);
|
||||||
|
|
||||||
|
if (!(await hasVerifiedAdmin(complex.id))) {
|
||||||
|
return {
|
||||||
|
complexId: complex.id,
|
||||||
|
complexName: complex.complexName,
|
||||||
|
complexAddress: complex.physicalAddress ?? null,
|
||||||
|
complexSlug: complex.complexSlug,
|
||||||
|
date: query.date,
|
||||||
|
sportSelectionRequired: false,
|
||||||
|
sports: [],
|
||||||
|
courts: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const sports = resolveSports(complex);
|
const sports = resolveSports(complex);
|
||||||
const sportSelectionRequired = sports.length > 1;
|
const sportSelectionRequired = sports.length > 1;
|
||||||
|
|
||||||
@@ -407,7 +494,10 @@ export async function listPublicAvailability(complexSlug: string, query: PublicA
|
|||||||
},
|
},
|
||||||
slotDurationMinutes: court.slotDurationMinutes,
|
slotDurationMinutes: court.slotDurationMinutes,
|
||||||
availabilityDay: dayOfWeek,
|
availabilityDay: dayOfWeek,
|
||||||
availableSlots,
|
availableSlots: availableSlots.map((slot) => ({
|
||||||
|
...slot,
|
||||||
|
price: resolveSlotPrice(court, dayOfWeek, slot),
|
||||||
|
})),
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter((court) => court.availableSlots.length > 0);
|
.filter((court) => court.availableSlots.length > 0);
|
||||||
@@ -427,6 +517,14 @@ export async function listPublicAvailability(complexSlug: string, query: PublicA
|
|||||||
export async function createPublicBooking(complexSlug: string, input: CreatePublicBookingInput) {
|
export async function createPublicBooking(complexSlug: string, input: CreatePublicBookingInput) {
|
||||||
const { bookingDate, dayOfWeek } = parseIsoDate(input.date);
|
const { bookingDate, dayOfWeek } = parseIsoDate(input.date);
|
||||||
const complex = await getComplexWithBookingData(complexSlug);
|
const complex = await getComplexWithBookingData(complexSlug);
|
||||||
|
|
||||||
|
if (!(await hasVerifiedAdmin(complex.id))) {
|
||||||
|
throw new PublicBookingServiceError(
|
||||||
|
'El complejo no puede recibir reservas hasta que un administrador verifique su email.',
|
||||||
|
403
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const sports = resolveSports(complex);
|
const sports = resolveSports(complex);
|
||||||
const { sportSelectionRequired } = validateSportSelection(sports, input.sportId);
|
const { sportSelectionRequired } = validateSportSelection(sports, input.sportId);
|
||||||
|
|
||||||
@@ -533,6 +631,7 @@ export async function createPublicBooking(complexSlug: string, input: CreatePubl
|
|||||||
endTime: selectedSlot.endTime,
|
endTime: selectedSlot.endTime,
|
||||||
customerName: input.customerName.trim(),
|
customerName: input.customerName.trim(),
|
||||||
customerPhone: input.customerPhone.trim(),
|
customerPhone: input.customerPhone.trim(),
|
||||||
|
customerEmail: input.customerEmail?.trim() || null,
|
||||||
status: 'CONFIRMED',
|
status: 'CONFIRMED',
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
@@ -544,11 +643,14 @@ export async function createPublicBooking(complexSlug: string, input: CreatePubl
|
|||||||
endTime: true,
|
endTime: true,
|
||||||
customerName: true,
|
customerName: true,
|
||||||
customerPhone: true,
|
customerPhone: true,
|
||||||
|
customerEmail: true,
|
||||||
status: true,
|
status: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const price = resolveSlotPrice(selectedCourt, dayOfWeek, selectedSlot);
|
||||||
|
|
||||||
return mapBookingResponse({
|
return mapBookingResponse({
|
||||||
bookingId: booking.id,
|
bookingId: booking.id,
|
||||||
bookingCode: booking.bookingCode,
|
bookingCode: booking.bookingCode,
|
||||||
@@ -558,6 +660,8 @@ export async function createPublicBooking(complexSlug: string, input: CreatePubl
|
|||||||
endTime: booking.endTime,
|
endTime: booking.endTime,
|
||||||
customerName: booking.customerName,
|
customerName: booking.customerName,
|
||||||
customerPhone: booking.customerPhone,
|
customerPhone: booking.customerPhone,
|
||||||
|
customerEmail: booking.customerEmail,
|
||||||
|
price,
|
||||||
status: booking.status,
|
status: booking.status,
|
||||||
court: {
|
court: {
|
||||||
id: selectedCourt.id,
|
id: selectedCourt.id,
|
||||||
|
|||||||
86
apps/backend/src/services/booking-email.service.ts
Normal file
86
apps/backend/src/services/booking-email.service.ts
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
import {
|
||||||
|
bookingCancelledHtml,
|
||||||
|
bookingConfirmationHtml,
|
||||||
|
bookingNoShowHtml,
|
||||||
|
} from '@/emails/booking-confirmation';
|
||||||
|
import { sendMail } from '@/lib/mailer';
|
||||||
|
|
||||||
|
type BookingEmailInput = {
|
||||||
|
bookingCode: string;
|
||||||
|
complexName: string;
|
||||||
|
date: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
courtName: string;
|
||||||
|
sportName: string;
|
||||||
|
customerName: string;
|
||||||
|
customerEmail?: string;
|
||||||
|
price?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function sendBookingConfirmation(data: BookingEmailInput) {
|
||||||
|
if (!data.customerEmail) return;
|
||||||
|
|
||||||
|
const html = bookingConfirmationHtml({
|
||||||
|
bookingCode: data.bookingCode,
|
||||||
|
complexName: data.complexName,
|
||||||
|
date: data.date,
|
||||||
|
startTime: data.startTime,
|
||||||
|
endTime: data.endTime,
|
||||||
|
courtName: data.courtName,
|
||||||
|
sportName: data.sportName,
|
||||||
|
customerName: data.customerName,
|
||||||
|
price: data.price,
|
||||||
|
});
|
||||||
|
|
||||||
|
await sendMail({
|
||||||
|
to: data.customerEmail,
|
||||||
|
subject: `Reserva confirmada en ${data.complexName} | Playzer`,
|
||||||
|
html,
|
||||||
|
text: `Reserva confirmada en ${data.complexName}. Codigo: ${data.bookingCode}. Cancha: ${data.courtName}. Fecha: ${data.date}. Horario: ${data.startTime} - ${data.endTime}.`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function sendBookingCancelled(data: BookingEmailInput) {
|
||||||
|
if (!data.customerEmail) return;
|
||||||
|
|
||||||
|
const html = bookingCancelledHtml({
|
||||||
|
bookingCode: data.bookingCode,
|
||||||
|
complexName: data.complexName,
|
||||||
|
date: data.date,
|
||||||
|
startTime: data.startTime,
|
||||||
|
endTime: data.endTime,
|
||||||
|
courtName: data.courtName,
|
||||||
|
sportName: data.sportName,
|
||||||
|
customerName: data.customerName,
|
||||||
|
});
|
||||||
|
|
||||||
|
await sendMail({
|
||||||
|
to: data.customerEmail,
|
||||||
|
subject: `Reserva cancelada en ${data.complexName} | Playzer`,
|
||||||
|
html,
|
||||||
|
text: `Reserva cancelada en ${data.complexName}. Codigo: ${data.bookingCode}. Fecha: ${data.date}. Horario: ${data.startTime} - ${data.endTime}.`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function sendBookingNoShow(data: BookingEmailInput) {
|
||||||
|
if (!data.customerEmail) return;
|
||||||
|
|
||||||
|
const html = bookingNoShowHtml({
|
||||||
|
bookingCode: data.bookingCode,
|
||||||
|
complexName: data.complexName,
|
||||||
|
date: data.date,
|
||||||
|
startTime: data.startTime,
|
||||||
|
endTime: data.endTime,
|
||||||
|
courtName: data.courtName,
|
||||||
|
sportName: data.sportName,
|
||||||
|
customerName: data.customerName,
|
||||||
|
});
|
||||||
|
|
||||||
|
await sendMail({
|
||||||
|
to: data.customerEmail,
|
||||||
|
subject: `Reserva no concretada en ${data.complexName} | Playzer`,
|
||||||
|
html,
|
||||||
|
text: `Reserva no concretada en ${data.complexName}. Codigo: ${data.bookingCode}. Fecha: ${data.date}. Horario: ${data.startTime} - ${data.endTime}.`,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { beforeEach, expect, mock, test } from 'bun:test';
|
import { beforeEach, expect, mock, test } from 'bun:test';
|
||||||
|
|
||||||
import { createInviteComplexUserHandler } from '@/modules/complex/handlers/invite-complex-user.handler';
|
|
||||||
import type { InviteComplexUserResponse } from '@repo/api-contract';
|
import type { InviteComplexUserResponse } from '@repo/api-contract';
|
||||||
|
|
||||||
const inviteComplexUserMock = mock(async () => undefined as unknown as InviteComplexUserResponse);
|
const inviteComplexUserMock = mock(async () => undefined as unknown as InviteComplexUserResponse);
|
||||||
@@ -15,6 +14,10 @@ class MockComplexMembersError extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { createInviteComplexUserHandler } = await import(
|
||||||
|
'@/modules/complex/handlers/invite-complex-user.handler'
|
||||||
|
);
|
||||||
|
|
||||||
const inviteComplexUserHandler = createInviteComplexUserHandler({
|
const inviteComplexUserHandler = createInviteComplexUserHandler({
|
||||||
inviteComplexUser: inviteComplexUserMock,
|
inviteComplexUser: inviteComplexUserMock,
|
||||||
ComplexMembersError: MockComplexMembersError,
|
ComplexMembersError: MockComplexMembersError,
|
||||||
@@ -59,7 +62,6 @@ function createContext(input: {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
inviteComplexUserMock.mockReset();
|
inviteComplexUserMock.mockReset();
|
||||||
mock.clearAllMocks();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns 201 with the service result', async () => {
|
test('returns 201 with the service result', async () => {
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import { beforeEach, expect, mock, test } from 'bun:test';
|
import { beforeEach, expect, test } from 'bun:test';
|
||||||
|
|
||||||
import {
|
|
||||||
ComplexMembersError,
|
|
||||||
inviteComplexUser,
|
|
||||||
} from '@/modules/complex/services/complex-members.service';
|
|
||||||
import { prismaMock, sendMailMock, transactionMock } from '../support/prisma.mock';
|
import { prismaMock, sendMailMock, transactionMock } from '../support/prisma.mock';
|
||||||
|
|
||||||
|
const { ComplexMembersError, inviteComplexUser } = await import(
|
||||||
|
'@/modules/complex/services/complex-members.service'
|
||||||
|
);
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
prismaMock._reset();
|
prismaMock._reset();
|
||||||
mock.clearAllMocks();
|
sendMailMock.mockClear();
|
||||||
|
transactionMock.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates a pending invitation and sends the email', async () => {
|
test('creates a pending invitation and sends the email', async () => {
|
||||||
@@ -21,10 +22,10 @@ test('creates a pending invitation and sends the email', async () => {
|
|||||||
complexId: 'complex-1',
|
complexId: 'complex-1',
|
||||||
email: 'new.member@example.com',
|
email: 'new.member@example.com',
|
||||||
tokenHash: 'token-hash',
|
tokenHash: 'token-hash',
|
||||||
expiresAt: new Date('2026-04-29T00:00:00.000Z'),
|
expiresAt: new Date('2027-01-01T00:00:00.000Z'),
|
||||||
acceptedAt: null,
|
acceptedAt: null,
|
||||||
revokedAt: null,
|
revokedAt: null,
|
||||||
createdAt: new Date('2026-04-22T00:00:00.000Z'),
|
createdAt: new Date('2026-12-01T00:00:00.000Z'),
|
||||||
} as never);
|
} as never);
|
||||||
|
|
||||||
const result = await inviteComplexUser('admin-1', 'complex-1', {
|
const result = await inviteComplexUser('admin-1', 'complex-1', {
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ function createContext(body: unknown) {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
createSportMock.mockReset();
|
createSportMock.mockReset();
|
||||||
mock.clearAllMocks();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('returns 201 with the created sport', async () => {
|
test('returns 201 with the created sport', async () => {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import type { PrismaClient } from '@/generated/prisma/client';
|
|||||||
import type { PrismaClientMock } from 'bun-mock-prisma';
|
import type { PrismaClientMock } from 'bun-mock-prisma';
|
||||||
|
|
||||||
const prismaMock = createPrismaMock<PrismaClient>() as PrismaClientMock<PrismaClient>;
|
const prismaMock = createPrismaMock<PrismaClient>() as PrismaClientMock<PrismaClient>;
|
||||||
const uuidV7Mock = mock(() => '00000000-0000-4000-8000-000000000001');
|
|
||||||
|
|
||||||
mock.module('@/lib/prisma', () => ({
|
mock.module('@/lib/prisma', () => ({
|
||||||
__esModule: true,
|
__esModule: true,
|
||||||
@@ -15,10 +14,7 @@ mock.module('@/lib/prisma', () => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
mock.module('uuid', () => ({
|
const { uuidV7Mock } = await import('../support/prisma.mock');
|
||||||
__esModule: true,
|
|
||||||
v7: uuidV7Mock,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const { createSport, getSportById, listSports, updateSport } = await import(
|
const { createSport, getSportById, listSports, updateSport } = await import(
|
||||||
'@/modules/sport/services/sport.service'
|
'@/modules/sport/services/sport.service'
|
||||||
@@ -26,7 +22,7 @@ const { createSport, getSportById, listSports, updateSport } = await import(
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
prismaMock._reset();
|
prismaMock._reset();
|
||||||
mock.clearAllMocks();
|
uuidV7Mock.mockClear();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('listSports returns sports ordered by name', async () => {
|
test('listSports returns sports ordered by name', async () => {
|
||||||
|
|||||||
@@ -33,3 +33,10 @@ mock.module('@/lib/mailer', () => ({
|
|||||||
__esModule: true,
|
__esModule: true,
|
||||||
sendMail: sendMailMock,
|
sendMail: sendMailMock,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
export const uuidV7Mock = mock(() => '00000000-0000-4000-8000-000000000001');
|
||||||
|
|
||||||
|
mock.module('uuid', () => ({
|
||||||
|
__esModule: true,
|
||||||
|
v7: uuidV7Mock,
|
||||||
|
}));
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ interface CreateManualBookingPayload {
|
|||||||
startTime: string;
|
startTime: string;
|
||||||
customerName: string;
|
customerName: string;
|
||||||
customerPhone: string;
|
customerPhone: string;
|
||||||
|
customerEmail?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BookingContextValue {
|
interface BookingContextValue {
|
||||||
@@ -315,6 +316,7 @@ export function BookingProvider({ children, complex }: BookingProviderProps) {
|
|||||||
startTime: payload.startTime,
|
startTime: payload.startTime,
|
||||||
customerName: payload.customerName,
|
customerName: payload.customerName,
|
||||||
customerPhone: payload.customerPhone,
|
customerPhone: payload.customerPhone,
|
||||||
|
customerEmail: payload.customerEmail || undefined,
|
||||||
}),
|
}),
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
await queryClient.invalidateQueries({ queryKey: ['admin-bookings', complex.id] });
|
await queryClient.invalidateQueries({ queryKey: ['admin-bookings', complex.id] });
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { useIsMobile } from '@/hooks/use-mobile';
|
import { useIsMobile } from '@/hooks/use-mobile';
|
||||||
|
import { authClient } from '@/lib/api-client';
|
||||||
|
import { useAuth } from '@/lib/auth';
|
||||||
import type { ComplexWithRole } from '@repo/api-contract';
|
import type { ComplexWithRole } from '@repo/api-contract';
|
||||||
|
import { useState } from 'react';
|
||||||
import { BookingProvider } from './booking-provider';
|
import { BookingProvider } from './booking-provider';
|
||||||
import { BookingCreateDialog } from './components/booking-create-dialog';
|
import { BookingCreateDialog } from './components/booking-create-dialog';
|
||||||
import { BookingDaySummary, BookingQuickActions } from './components/booking-day-summary';
|
import { BookingDaySummary, BookingQuickActions } from './components/booking-day-summary';
|
||||||
@@ -15,9 +18,44 @@ interface BookingProps {
|
|||||||
|
|
||||||
export function Booking({ complex }: BookingProps) {
|
export function Booking({ complex }: BookingProps) {
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
|
const { user } = useAuth();
|
||||||
|
const [sending, setSending] = useState(false);
|
||||||
|
const [emailSent, setEmailSent] = useState(false);
|
||||||
|
|
||||||
|
const emailNotVerified = user && !user.emailVerified;
|
||||||
|
|
||||||
|
const handleResendVerification = async () => {
|
||||||
|
if (!user?.email || sending) return;
|
||||||
|
setSending(true);
|
||||||
|
try {
|
||||||
|
await authClient.sendVerificationEmail({ email: user.email });
|
||||||
|
setEmailSent(true);
|
||||||
|
setTimeout(() => setEmailSent(false), 6000);
|
||||||
|
} catch {
|
||||||
|
// Silently fail — the banner already shows the email to contact
|
||||||
|
} finally {
|
||||||
|
setSending(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BookingProvider complex={complex}>
|
<BookingProvider complex={complex}>
|
||||||
|
{emailNotVerified && (
|
||||||
|
<div className="mb-6 flex items-center justify-between gap-4 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800 dark:border-amber-800/30 dark:bg-amber-950/30 dark:text-amber-200">
|
||||||
|
<span>
|
||||||
|
No verificaste tu email. Para crear reservas necesitás verificar tu dirección de correo
|
||||||
|
electrónico.
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleResendVerification}
|
||||||
|
disabled={sending}
|
||||||
|
className="shrink-0 rounded-lg bg-amber-200 px-3 py-1.5 text-xs font-medium text-amber-900 transition-colors hover:bg-amber-300 disabled:opacity-50 dark:bg-amber-800 dark:text-amber-50 dark:hover:bg-amber-700"
|
||||||
|
>
|
||||||
|
{sending ? 'Enviando...' : emailSent ? '¡Email enviado!' : 'Reenviar email'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{isMobile ? (
|
{isMobile ? (
|
||||||
<BookingMobile />
|
<BookingMobile />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ const bookingFormSchema = z.object({
|
|||||||
.trim()
|
.trim()
|
||||||
.min(6, 'Ingresa un telefono válido.')
|
.min(6, 'Ingresa un telefono válido.')
|
||||||
.max(30, 'El telefono no puede superar los 30 caracteres.'),
|
.max(30, 'El telefono no puede superar los 30 caracteres.'),
|
||||||
|
customerEmail: z.string().email('Ingresá un email válido.').optional().or(z.literal('')),
|
||||||
});
|
});
|
||||||
|
|
||||||
type BookingForm = z.infer<typeof bookingFormSchema>;
|
type BookingForm = z.infer<typeof bookingFormSchema>;
|
||||||
@@ -76,6 +77,7 @@ export function BookingCreateDialog() {
|
|||||||
defaultValues: {
|
defaultValues: {
|
||||||
customerName: '',
|
customerName: '',
|
||||||
customerPhone: '',
|
customerPhone: '',
|
||||||
|
customerEmail: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -154,6 +156,7 @@ export function BookingCreateDialog() {
|
|||||||
startTime,
|
startTime,
|
||||||
customerName: values.customerName,
|
customerName: values.customerName,
|
||||||
customerPhone: values.customerPhone,
|
customerPhone: values.customerPhone,
|
||||||
|
customerEmail: values.customerEmail || undefined,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -271,6 +274,23 @@ export function BookingCreateDialog() {
|
|||||||
<FieldError errors={[errors.customerPhone]} />
|
<FieldError errors={[errors.customerPhone]} />
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
<Field data-invalid={Boolean(errors.customerEmail)}>
|
||||||
|
<FieldLabel htmlFor="customerEmail">
|
||||||
|
Email <span className="text-muted-foreground font-normal">(opcional)</span>
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id="customerEmail"
|
||||||
|
type="email"
|
||||||
|
placeholder="Ej: juan@ejemplo.com"
|
||||||
|
aria-invalid={Boolean(errors.customerEmail)}
|
||||||
|
{...register('customerEmail')}
|
||||||
|
/>
|
||||||
|
<p className="mt-1 text-xs text-muted-foreground">
|
||||||
|
Se enviará la confirmación de la reserva por email.
|
||||||
|
</p>
|
||||||
|
<FieldError errors={[errors.customerEmail]} />
|
||||||
|
</Field>
|
||||||
|
|
||||||
{createBookingError && <p className="text-sm text-destructive">{createBookingError}</p>}
|
{createBookingError && <p className="text-sm text-destructive">{createBookingError}</p>}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -18,16 +18,35 @@ function formatDateLabel(isoDate: string) {
|
|||||||
}).format(date);
|
}).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) {
|
function createWhatsappMessage(confirmation: PublicBookingConfirmation) {
|
||||||
const dateLabel = formatDateLabel(confirmation.date);
|
const dateLabel = formatDateLabel(confirmation.date);
|
||||||
return [
|
const lines = ['Ya reservamos cancha para jugar.', `Complejo: ${confirmation.complexName}`];
|
||||||
'Ya reservamos cancha para jugar.',
|
|
||||||
`Complejo: ${confirmation.complexName}`,
|
if (confirmation.complexAddress) {
|
||||||
|
lines.push(`Direccion: ${confirmation.complexAddress}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.push(
|
||||||
`Cancha: ${confirmation.courtName} (${confirmation.sport.name})`,
|
`Cancha: ${confirmation.courtName} (${confirmation.sport.name})`,
|
||||||
`Fecha: ${dateLabel}`,
|
`Fecha: ${dateLabel}`,
|
||||||
`Horario: ${confirmation.startTime} - ${confirmation.endTime}`,
|
`Horario: ${confirmation.startTime} - ${confirmation.endTime}`,
|
||||||
`Codigo de reserva: ${confirmation.bookingCode}`,
|
`Precio: ${formatBookingPrice(confirmation.price)}`,
|
||||||
].join('\n');
|
`Codigo de reserva: ${confirmation.bookingCode}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return lines.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ShareWhatsappButton({ confirmation }: ShareWhatsappButtonProps) {
|
export function ShareWhatsappButton({ confirmation }: ShareWhatsappButtonProps) {
|
||||||
@@ -36,7 +55,12 @@ export function ShareWhatsappButton({ confirmation }: ShareWhatsappButtonProps)
|
|||||||
)}`;
|
)}`;
|
||||||
|
|
||||||
return (
|
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">
|
<a href={whatsappUrl} target="_blank" rel="noopener noreferrer">
|
||||||
<svg
|
<svg
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
|
import PlayzerIcon from '@/assets/playzer-favicon-512-transparent.png';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { ApiClientError, apiClient } from '@/lib/api-client';
|
import { ApiClientError, apiClient } from '@/lib/api-client';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useNavigate } from '@tanstack/react-router';
|
import { useNavigate } from '@tanstack/react-router';
|
||||||
|
import {
|
||||||
|
AlertCircle,
|
||||||
|
ArrowRight,
|
||||||
|
CalendarDays,
|
||||||
|
CheckCircle2,
|
||||||
|
Clock3,
|
||||||
|
LoaderCircle,
|
||||||
|
Receipt,
|
||||||
|
Trophy,
|
||||||
|
} from 'lucide-react';
|
||||||
import { ShareWhatsappButton } from './components/share-whatsapp-button';
|
import { ShareWhatsappButton } from './components/share-whatsapp-button';
|
||||||
|
|
||||||
type PublicBookingConfirmationPageProps = {
|
type PublicBookingConfirmationPageProps = {
|
||||||
@@ -21,12 +32,25 @@ function formatDateLabel(isoDate: string) {
|
|||||||
const [year, month, day] = isoDate.split('-').map(Number);
|
const [year, month, day] = isoDate.split('-').map(Number);
|
||||||
const date = new Date(year, (month ?? 1) - 1, day ?? 1);
|
const date = new Date(year, (month ?? 1) - 1, day ?? 1);
|
||||||
|
|
||||||
return new Intl.DateTimeFormat('es-AR', {
|
const label = new Intl.DateTimeFormat('es-AR', {
|
||||||
weekday: 'long',
|
weekday: 'long',
|
||||||
day: '2-digit',
|
day: '2-digit',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
year: 'numeric',
|
|
||||||
}).format(date);
|
}).format(date);
|
||||||
|
|
||||||
|
return label.charAt(0).toUpperCase() + label.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PublicBookingConfirmationPage({
|
export function PublicBookingConfirmationPage({
|
||||||
@@ -40,62 +64,98 @@ export function PublicBookingConfirmationPage({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="min-h-screen bg-linear-to-b from-background via-background to-primary/5">
|
<main className="min-h-screen bg-[#edf7f4] text-[#111827]">
|
||||||
<div className="mx-auto flex min-h-screen w-full max-w-3xl items-center px-3 py-8 sm:px-6">
|
<div className="mx-auto flex min-h-screen w-full max-w-3xl items-center px-4 py-8 sm:px-6">
|
||||||
<section className="w-full rounded-3xl border bg-card p-5 shadow-lg sm:p-8">
|
<section className="w-full rounded-[28px] border border-emerald-950/10 bg-white p-5 shadow-[0_24px_70px_rgba(15,23,42,0.12)] sm:p-8">
|
||||||
{confirmationQuery.isLoading && (
|
{confirmationQuery.isLoading && (
|
||||||
<p className="text-sm text-muted-foreground">Cargando confirmacion...</p>
|
<div className="flex items-center gap-3 text-sm text-slate-500">
|
||||||
|
<LoaderCircle className="size-5 animate-spin text-emerald-600" />
|
||||||
|
Cargando confirmación...
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{confirmationQuery.isError && (
|
{confirmationQuery.isError && (
|
||||||
<p className="text-sm text-destructive">
|
<div className="flex gap-3 rounded-2xl border border-red-200 bg-red-50 p-4 text-sm text-red-700">
|
||||||
{extractMessage(
|
<AlertCircle className="mt-0.5 size-5 shrink-0" />
|
||||||
confirmationQuery.error,
|
<p>
|
||||||
'No pudimos cargar la confirmacion de la reserva.'
|
{extractMessage(
|
||||||
)}
|
confirmationQuery.error,
|
||||||
</p>
|
'No pudimos cargar la confirmación de la reserva.'
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{confirmationQuery.data && (
|
{confirmationQuery.data && (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div>
|
<div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||||
<p className="text-xs font-medium tracking-[0.2em] text-muted-foreground uppercase">
|
<div>
|
||||||
Reserva confirmada
|
<div className="inline-flex items-center gap-2 rounded-full bg-emerald-50 px-3 py-1 text-xs font-semibold tracking-[0.14em] text-emerald-700 uppercase">
|
||||||
</p>
|
<CheckCircle2 className="size-4" />
|
||||||
<h1 className="mt-2 text-2xl font-semibold sm:text-3xl">
|
Reserva confirmada
|
||||||
{confirmationQuery.data.complexName}
|
</div>
|
||||||
</h1>
|
<h1 className="mt-3 text-2xl font-bold tracking-tight sm:text-3xl">
|
||||||
|
{confirmationQuery.data.complexName}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2 text-slate-600">
|
||||||
|
<img src={PlayzerIcon} alt="Playzer" className="size-8" />
|
||||||
|
<span className="text-lg font-bold tracking-tight">Playzer</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="rounded-2xl border border-primary/30 bg-primary/5 p-4 text-center sm:p-5">
|
<div className="rounded-[24px] border border-emerald-500/30 bg-emerald-50/80 p-5 sm:p-6">
|
||||||
<p className="text-xs text-muted-foreground">Codigo de reserva</p>
|
<div className="flex flex-col gap-5 sm:flex-row sm:items-end sm:justify-between">
|
||||||
<p className="mt-1 text-3xl font-bold tracking-[0.25em] text-primary sm:text-4xl">
|
<div>
|
||||||
{confirmationQuery.data.bookingCode}
|
<p className="flex items-center gap-2 text-sm font-semibold text-emerald-700">
|
||||||
</p>
|
<CalendarDays className="size-4" />
|
||||||
|
Tu turno
|
||||||
|
</p>
|
||||||
|
<p className="mt-3 text-2xl font-black leading-tight tracking-tight text-slate-950 sm:text-4xl">
|
||||||
|
{formatDateLabel(confirmationQuery.data.date)}
|
||||||
|
</p>
|
||||||
|
<p className="mt-2 flex items-center gap-2 text-3xl font-black leading-none text-emerald-700 sm:text-5xl">
|
||||||
|
<Clock3 className="size-7 sm:size-9" />
|
||||||
|
{confirmationQuery.data.startTime} - {confirmationQuery.data.endTime}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="rounded-2xl border border-emerald-600/20 bg-white/80 px-4 py-3 sm:min-w-40 sm:text-right">
|
||||||
|
<p className="text-xs font-medium text-slate-500">Precio del turno</p>
|
||||||
|
<p className="mt-1 text-2xl font-bold text-slate-950">
|
||||||
|
{formatBookingPrice(confirmationQuery.data.price)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="rounded-2xl border bg-background p-4 sm:p-5">
|
<div className="overflow-hidden rounded-[22px] border border-slate-200 bg-slate-50/70">
|
||||||
<p className="text-sm text-muted-foreground">Fecha</p>
|
<div className="grid gap-px bg-slate-200 sm:grid-cols-2">
|
||||||
<p className="mt-1 text-base font-medium capitalize sm:text-lg">
|
<div className="bg-white p-4">
|
||||||
{formatDateLabel(confirmationQuery.data.date)}
|
<p className="flex items-center gap-2 text-sm font-medium text-slate-500">
|
||||||
</p>
|
<Trophy className="size-4 text-emerald-600" />
|
||||||
|
Cancha
|
||||||
<p className="mt-4 text-sm text-muted-foreground">Horario</p>
|
</p>
|
||||||
<p className="mt-1 text-base font-medium sm:text-lg">
|
<p className="mt-2 text-base font-semibold text-slate-950">
|
||||||
{confirmationQuery.data.startTime} - {confirmationQuery.data.endTime}
|
{confirmationQuery.data.courtName} · {confirmationQuery.data.sport.name}
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
<p className="mt-4 text-sm text-muted-foreground">Cancha</p>
|
<div className="bg-white p-4">
|
||||||
<p className="mt-1 text-base font-medium sm:text-lg">
|
<p className="flex items-center gap-2 text-sm font-medium text-slate-500">
|
||||||
{confirmationQuery.data.courtName} · {confirmationQuery.data.sport.name}
|
<Receipt className="size-4 text-emerald-600" />
|
||||||
</p>
|
Código de reserva
|
||||||
|
</p>
|
||||||
|
<p className="mt-2 font-mono text-lg font-bold tracking-[0.18em] text-slate-950">
|
||||||
|
{confirmationQuery.data.bookingCode}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid gap-3 sm:grid-cols-2">
|
<div className="grid gap-3 sm:grid-cols-2">
|
||||||
<ShareWhatsappButton confirmation={confirmationQuery.data} />
|
<ShareWhatsappButton confirmation={confirmationQuery.data} />
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
className="h-11 w-full text-sm sm:text-base"
|
className="h-12 w-full rounded-xl bg-emerald-600 text-sm font-semibold text-white hover:bg-emerald-500 sm:text-base"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
void navigate({
|
void navigate({
|
||||||
to: '/$complexSlug/booking',
|
to: '/$complexSlug/booking',
|
||||||
@@ -104,6 +164,7 @@ export function PublicBookingConfirmationPage({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Hacer otra reserva
|
Hacer otra reserva
|
||||||
|
<ArrowRight className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,13 +2,6 @@ import PlayzerIcon from '@/assets/playzer-favicon-512-transparent.png';
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Field, FieldError, FieldLabel } from '@/components/ui/field';
|
import { Field, FieldError, FieldLabel } from '@/components/ui/field';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from '@/components/ui/select';
|
|
||||||
import {
|
import {
|
||||||
Stepper,
|
Stepper,
|
||||||
StepperIndicator,
|
StepperIndicator,
|
||||||
@@ -69,6 +62,7 @@ const bookingFormSchema = z.object({
|
|||||||
.trim()
|
.trim()
|
||||||
.min(6, 'Ingresá un teléfono válido.')
|
.min(6, 'Ingresá un teléfono válido.')
|
||||||
.max(30, 'El teléfono no puede superar los 30 caracteres.'),
|
.max(30, 'El teléfono no puede superar los 30 caracteres.'),
|
||||||
|
customerEmail: z.string().email('Ingresá un email válido.').optional().or(z.literal('')),
|
||||||
});
|
});
|
||||||
|
|
||||||
type BookingFormValues = z.infer<typeof bookingFormSchema>;
|
type BookingFormValues = z.infer<typeof bookingFormSchema>;
|
||||||
@@ -84,6 +78,7 @@ type SelectedSlot = {
|
|||||||
sportName: string;
|
sportName: string;
|
||||||
startTime: string;
|
startTime: string;
|
||||||
endTime: string;
|
endTime: string;
|
||||||
|
price: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type BookingShellProps = {
|
type BookingShellProps = {
|
||||||
@@ -186,6 +181,18 @@ function extractMessage(error: unknown, fallback: string) {
|
|||||||
return fallback;
|
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) {
|
function getStep(selectedSlot: SelectedSlot | null, isValid: boolean) {
|
||||||
if (!selectedSlot) return 1;
|
if (!selectedSlot) return 1;
|
||||||
if (!isValid) return 3;
|
if (!isValid) return 3;
|
||||||
@@ -638,48 +645,52 @@ function PublicBookingDesktop(props: BookingShellProps) {
|
|||||||
)}
|
)}
|
||||||
{isError && <StatusPanel>{errorMessage}</StatusPanel>}
|
{isError && <StatusPanel>{errorMessage}</StatusPanel>}
|
||||||
{isLoading && <StatusPanel>Buscando disponibilidad...</StatusPanel>}
|
{isLoading && <StatusPanel>Buscando disponibilidad...</StatusPanel>}
|
||||||
<Panel className="overflow-hidden">
|
{selectedCourt && (
|
||||||
<div className="flex items-center border-b border-white/10 px-6 py-5">
|
<>
|
||||||
<CourtHeader court={selectedCourt} complexName={props.complexName} />
|
<Panel className="overflow-hidden">
|
||||||
<div className="ml-auto flex items-center overflow-hidden rounded-md border border-white/10 bg-white/[0.035] text-sm">
|
<div className="flex items-center border-b border-white/10 px-6 py-5">
|
||||||
<button
|
<CourtHeader court={selectedCourt} complexName={props.complexName} />
|
||||||
type="button"
|
<div className="ml-auto flex items-center overflow-hidden rounded-md border border-white/10 bg-white/[0.035] text-sm">
|
||||||
className="flex size-11 items-center justify-center border-r border-white/10 transition hover:bg-white/[0.06]"
|
<button
|
||||||
onClick={props.onPreviousDay}
|
type="button"
|
||||||
disabled={!canGoBackButton}
|
className="flex size-11 items-center justify-center border-r border-white/10 transition hover:bg-white/[0.06]"
|
||||||
aria-label="Día anterior"
|
onClick={props.onPreviousDay}
|
||||||
>
|
disabled={!canGoBackButton}
|
||||||
<ChevronLeft className="size-5" />
|
aria-label="Día anterior"
|
||||||
</button>
|
>
|
||||||
<div className="flex h-11 min-w-[250px] items-center justify-center gap-2 px-4">
|
<ChevronLeft className="size-5" />
|
||||||
<CalendarDays className="size-4 text-white/76" />
|
</button>
|
||||||
<span>{selectedDay?.longLabel ?? selectedDate}</span>
|
<div className="flex h-11 min-w-[250px] items-center justify-center gap-2 px-4">
|
||||||
|
<CalendarDays className="size-4 text-white/76" />
|
||||||
|
<span>{selectedDay?.longLabel ?? selectedDate}</span>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="flex size-11 items-center justify-center border-l border-white/10 transition hover:bg-white/[0.06]"
|
||||||
|
onClick={props.onNextDay}
|
||||||
|
aria-label="Día siguiente"
|
||||||
|
>
|
||||||
|
<ChevronRight className="size-5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button
|
|
||||||
type="button"
|
<div className="p-6">
|
||||||
className="flex size-11 items-center justify-center border-l border-white/10 transition hover:bg-white/[0.06]"
|
<Legend />
|
||||||
onClick={props.onNextDay}
|
<BookingTimeline
|
||||||
aria-label="Día siguiente"
|
court={selectedCourt}
|
||||||
>
|
selectedSlot={selectedSlot}
|
||||||
<ChevronRight className="size-5" />
|
onSelectSlot={onSelectSlot}
|
||||||
</button>
|
/>
|
||||||
|
</div>
|
||||||
|
</Panel>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-[minmax(0,1fr)_minmax(340px,0.95fr)] gap-4">
|
||||||
|
<CourtDetails court={selectedCourt} />
|
||||||
|
<SelectedSlotCard {...props} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</>
|
||||||
|
)}
|
||||||
<div className="p-6">
|
|
||||||
<Legend />
|
|
||||||
<BookingTimeline
|
|
||||||
court={selectedCourt}
|
|
||||||
selectedSlot={selectedSlot}
|
|
||||||
onSelectSlot={onSelectSlot}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Panel>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-[minmax(0,1fr)_minmax(340px,0.95fr)] gap-4">
|
|
||||||
<CourtDetails court={selectedCourt} />
|
|
||||||
<SelectedSlotCard {...props} />
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</PublicBookingPageChrome>
|
</PublicBookingPageChrome>
|
||||||
@@ -711,16 +722,19 @@ function PublicBookingMobile(props: BookingShellProps) {
|
|||||||
options={props.sports.map((sport) => ({ value: sport.id, label: sport.name }))}
|
options={props.sports.map((sport) => ({ value: sport.id, label: sport.name }))}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<MobileSelect
|
{props.courts.length > 0 ? (
|
||||||
label="Cancha"
|
<MobileCourtPicker
|
||||||
value={selectedCourt?.courtId ?? ''}
|
courts={props.courts}
|
||||||
placeholder="Seleccioná"
|
selectedCourtId={selectedCourt?.courtId}
|
||||||
onValueChange={props.onSelectCourt}
|
onSelectCourt={props.onSelectCourt}
|
||||||
options={props.courts.map((court) => ({
|
/>
|
||||||
value: court.courtId,
|
) : (
|
||||||
label: court.courtName,
|
!props.isLoading && (
|
||||||
}))}
|
<p className="rounded-md border border-white/10 bg-white/[0.035] p-3 text-sm text-white/62">
|
||||||
/>
|
No hay canchas disponibles para esta fecha.
|
||||||
|
</p>
|
||||||
|
)
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|
||||||
@@ -756,25 +770,23 @@ function PublicBookingMobile(props: BookingShellProps) {
|
|||||||
)}
|
)}
|
||||||
{props.isLoading && <StatusPanel>Buscando disponibilidad...</StatusPanel>}
|
{props.isLoading && <StatusPanel>Buscando disponibilidad...</StatusPanel>}
|
||||||
{props.isError && <StatusPanel>{props.errorMessage}</StatusPanel>}
|
{props.isError && <StatusPanel>{props.errorMessage}</StatusPanel>}
|
||||||
<Panel className="overflow-hidden">
|
{selectedCourt && (
|
||||||
<div className="p-3">
|
<Panel className="overflow-hidden">
|
||||||
<CourtHeader court={selectedCourt} compact />
|
<div className="p-3">
|
||||||
<div className="mt-3">
|
<CourtHeader court={selectedCourt} compact />
|
||||||
<Legend />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div className="border-t border-white/10 p-3">
|
||||||
<div className="border-t border-white/10 px-0 py-3">
|
<MobileAvailableSlots
|
||||||
<BookingTimeline
|
court={selectedCourt}
|
||||||
court={selectedCourt}
|
selectedSlot={props.selectedSlot}
|
||||||
selectedSlot={props.selectedSlot}
|
onSelectSlot={props.onSelectSlot}
|
||||||
onSelectSlot={props.onSelectSlot}
|
/>
|
||||||
compact
|
</div>
|
||||||
/>
|
<div className="px-3 pb-3">
|
||||||
</div>
|
<SelectedSlotCard {...props} compact />
|
||||||
<div className="px-3 pb-3">
|
</div>
|
||||||
<SelectedSlotCard {...props} compact />
|
</Panel>
|
||||||
</div>
|
)}
|
||||||
</Panel>
|
|
||||||
</div>
|
</div>
|
||||||
</PublicBookingPageChrome>
|
</PublicBookingPageChrome>
|
||||||
);
|
);
|
||||||
@@ -876,34 +888,119 @@ function MobileSportSelector({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MobileSelect({
|
function MobileCourtPicker({
|
||||||
label,
|
courts,
|
||||||
value,
|
selectedCourtId,
|
||||||
placeholder,
|
onSelectCourt,
|
||||||
options,
|
|
||||||
onValueChange,
|
|
||||||
}: {
|
}: {
|
||||||
label: string;
|
courts: PublicAvailabilityCourt[];
|
||||||
value: string;
|
selectedCourtId?: string;
|
||||||
placeholder: string;
|
onSelectCourt: (courtId: string) => void;
|
||||||
options: { value: string; label: string }[];
|
|
||||||
onValueChange: (value: string) => void;
|
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-[88px_minmax(0,1fr)] items-center border-b border-white/10 bg-white/[0.025] px-3 py-2 last:border-b-0">
|
<div className="border-b border-white/10 bg-white/[0.025] px-3 py-3 last:border-b-0">
|
||||||
<span className="text-xs text-white/66">{label}</span>
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<Select value={value} onValueChange={onValueChange}>
|
{courts.map((court) => {
|
||||||
<SelectTrigger className="h-8 border-0 bg-transparent px-0 text-xs text-white shadow-none">
|
const isSelected = selectedCourtId === court.courtId;
|
||||||
<SelectValue placeholder={placeholder} />
|
|
||||||
</SelectTrigger>
|
return (
|
||||||
<SelectContent>
|
<button
|
||||||
{options.map((option) => (
|
key={court.courtId}
|
||||||
<SelectItem key={option.value} value={option.value}>
|
type="button"
|
||||||
{option.label}
|
onClick={() => onSelectCourt(court.courtId)}
|
||||||
</SelectItem>
|
aria-pressed={isSelected}
|
||||||
))}
|
className={`flex min-h-16 items-start gap-2 rounded-md border p-3 text-left transition ${
|
||||||
</SelectContent>
|
isSelected
|
||||||
</Select>
|
? 'border-emerald-400 bg-emerald-500/20 text-white shadow-[inset_0_0_18px_rgba(16,185,129,0.12)]'
|
||||||
|
: 'border-white/10 bg-white/[0.045] text-white/72 active:border-white/25 active:bg-white/[0.075]'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full border ${
|
||||||
|
isSelected
|
||||||
|
? 'border-emerald-300 bg-emerald-400 text-[#061019]'
|
||||||
|
: 'border-white/18 text-transparent'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<Check className="size-3.5" />
|
||||||
|
</span>
|
||||||
|
<span className="min-w-0">
|
||||||
|
<span className="block truncate text-sm font-semibold">{court.courtName}</span>
|
||||||
|
<span className="mt-0.5 block truncate text-xs text-white/52">
|
||||||
|
{court.sport.name}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function MobileAvailableSlots({
|
||||||
|
court,
|
||||||
|
selectedSlot,
|
||||||
|
onSelectSlot,
|
||||||
|
}: {
|
||||||
|
court: PublicAvailabilityCourt;
|
||||||
|
selectedSlot: SelectedSlot | null;
|
||||||
|
onSelectSlot: (slot: SelectedSlot) => void;
|
||||||
|
}) {
|
||||||
|
const slots = court.availableSlots;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="flex items-end justify-between gap-3">
|
||||||
|
<div>
|
||||||
|
<h3 className="text-base font-semibold">Horarios disponibles</h3>
|
||||||
|
<p className="mt-0.5 text-xs text-white/58">
|
||||||
|
Turnos de {court.slotDurationMinutes} minutos
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<span className="shrink-0 text-xs font-medium text-emerald-300/90">
|
||||||
|
{slots.length} {slots.length === 1 ? 'turno' : 'turnos'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{slots.length > 0 ? (
|
||||||
|
<div className="mt-3 grid grid-cols-3 gap-2">
|
||||||
|
{slots.map((slot) => {
|
||||||
|
const selected = isSlotSelected(slot, court.courtId, selectedSlot);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={`${court.courtId}-${slot.startTime}`}
|
||||||
|
type="button"
|
||||||
|
onClick={() =>
|
||||||
|
onSelectSlot({
|
||||||
|
courtId: court.courtId,
|
||||||
|
courtName: court.courtName,
|
||||||
|
sportId: court.sport.id,
|
||||||
|
sportName: court.sport.name,
|
||||||
|
startTime: slot.startTime,
|
||||||
|
endTime: slot.endTime,
|
||||||
|
price: slot.price,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
aria-pressed={selected}
|
||||||
|
className={`flex h-12 items-center justify-center gap-1.5 rounded-md border text-sm font-bold transition ${
|
||||||
|
selected
|
||||||
|
? 'border-emerald-300 bg-emerald-400 text-[#061019] shadow-lg shadow-emerald-500/20'
|
||||||
|
: 'border-emerald-500/45 bg-emerald-500/12 text-white active:bg-emerald-500/24'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{selected && <Check className="size-4" />}
|
||||||
|
{slot.startTime}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<p className="mt-3 rounded-md border border-white/10 bg-white/[0.035] p-3 text-sm text-white/62">
|
||||||
|
No hay horarios disponibles para esta cancha.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1011,6 +1108,7 @@ function BookingTimeline({
|
|||||||
sportName: court.sport.name,
|
sportName: court.sport.name,
|
||||||
startTime: slot.startTime,
|
startTime: slot.startTime,
|
||||||
endTime: slot.endTime,
|
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 ${
|
className={`absolute top-7 flex h-12 min-w-[50px] items-center justify-center rounded border text-xs transition ${
|
||||||
@@ -1155,6 +1253,13 @@ function SelectedSlotCard(props: BookingShellProps & { compact?: boolean }) {
|
|||||||
className={compact ? 'mt-4 space-y-3' : 'mt-5 grid gap-3'}
|
className={compact ? 'mt-4 space-y-3' : 'mt-5 grid gap-3'}
|
||||||
onSubmit={handleSubmit(onSubmit)}
|
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'}>
|
<div className={compact ? 'space-y-3' : 'grid grid-cols-2 gap-3'}>
|
||||||
<Field data-invalid={Boolean(errors.customerName)}>
|
<Field data-invalid={Boolean(errors.customerName)}>
|
||||||
<FieldLabel htmlFor="customerName" className="text-white/76">
|
<FieldLabel htmlFor="customerName" className="text-white/76">
|
||||||
@@ -1190,6 +1295,24 @@ function SelectedSlotCard(props: BookingShellProps & { compact?: boolean }) {
|
|||||||
</Field>
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Field data-invalid={Boolean(errors.customerEmail)}>
|
||||||
|
<FieldLabel htmlFor="customerEmail" className="text-white/76">
|
||||||
|
Email <span className="text-white/40 font-normal">(opcional)</span>
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id="customerEmail"
|
||||||
|
type="email"
|
||||||
|
placeholder="Ej: juan@ejemplo.com"
|
||||||
|
aria-invalid={Boolean(errors.customerEmail)}
|
||||||
|
className="border-white/10 bg-white/[0.045] text-white placeholder:text-white/32"
|
||||||
|
{...register('customerEmail')}
|
||||||
|
/>
|
||||||
|
<p className="mt-1 text-xs text-white/40">
|
||||||
|
Te enviaremos la confirmación de la reserva por email.
|
||||||
|
</p>
|
||||||
|
<FieldError errors={[errors.customerEmail]} />
|
||||||
|
</Field>
|
||||||
|
|
||||||
{createError && <p className="text-sm text-red-300">{createError}</p>}
|
{createError && <p className="text-sm text-red-300">{createError}</p>}
|
||||||
{navigationError && <p className="text-sm text-red-300">{navigationError}</p>}
|
{navigationError && <p className="text-sm text-red-300">{navigationError}</p>}
|
||||||
|
|
||||||
@@ -1305,6 +1428,7 @@ export function PublicBookingPage({ complexSlug }: PublicBookingPageProps) {
|
|||||||
defaultValues: {
|
defaultValues: {
|
||||||
customerName: '',
|
customerName: '',
|
||||||
customerPhone: '',
|
customerPhone: '',
|
||||||
|
customerEmail: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1321,6 +1445,7 @@ export function PublicBookingPage({ complexSlug }: PublicBookingPageProps) {
|
|||||||
startTime: selectedSlot.startTime,
|
startTime: selectedSlot.startTime,
|
||||||
customerName: payload.customerName,
|
customerName: payload.customerName,
|
||||||
customerPhone: payload.customerPhone,
|
customerPhone: payload.customerPhone,
|
||||||
|
customerEmail: payload.customerEmail || undefined,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,21 +6,32 @@ import { QueryClientProvider } from '@tanstack/react-query';
|
|||||||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
||||||
import { RouterProvider } from '@tanstack/react-router';
|
import { RouterProvider } from '@tanstack/react-router';
|
||||||
import { TanStackRouterDevtools } from '@tanstack/router-devtools';
|
import { TanStackRouterDevtools } from '@tanstack/router-devtools';
|
||||||
import { StrictMode, useEffect } from 'react';
|
import { StrictMode, useEffect, useRef } from 'react';
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
function AppRouter() {
|
function AppRouter() {
|
||||||
const auth = useAuth();
|
const auth = useAuth();
|
||||||
|
const prevAuthRef = useRef(auth);
|
||||||
|
|
||||||
|
if (auth !== prevAuthRef.current) {
|
||||||
|
prevAuthRef.current = auth;
|
||||||
|
router.update({ context: { auth, api: apiClient } });
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
router.update({ context: { auth, api: apiClient } });
|
||||||
router.invalidate();
|
router.invalidate();
|
||||||
}, [auth.isAuthenticated, auth.loading, auth.user]);
|
}, [auth.isAuthenticated, auth.loading, auth.user]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
configureApiClient({
|
configureApiClient({
|
||||||
onForbidden: async () => {
|
onForbidden: async (error) => {
|
||||||
|
if (error.message?.includes('verificar tu email')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!auth.isAuthenticated) {
|
if (!auth.isAuthenticated) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import { PublicBookingConfirmationPage } from '@/features/public-booking/public-booking-confirmation-page';
|
import { createFileRoute, lazyRouteComponent } from '@tanstack/react-router';
|
||||||
import { createFileRoute } from '@tanstack/react-router';
|
|
||||||
|
const PublicBookingConfirmationPage = lazyRouteComponent(
|
||||||
|
() => import('@/features/public-booking/public-booking-confirmation-page'),
|
||||||
|
'PublicBookingConfirmationPage'
|
||||||
|
);
|
||||||
|
|
||||||
export const Route = createFileRoute('/$complexSlug/booking/confirmed/$bookingCode')({
|
export const Route = createFileRoute('/$complexSlug/booking/confirmed/$bookingCode')({
|
||||||
component: PublicBookingConfirmationRouteComponent,
|
component: RouteComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
function PublicBookingConfirmationRouteComponent() {
|
function RouteComponent() {
|
||||||
const { complexSlug, bookingCode } = Route.useParams();
|
const { complexSlug, bookingCode } = Route.useParams();
|
||||||
|
|
||||||
return <PublicBookingConfirmationPage complexSlug={complexSlug} bookingCode={bookingCode} />;
|
return <PublicBookingConfirmationPage complexSlug={complexSlug} bookingCode={bookingCode} />;
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import { PublicBookingPage } from '@/features/public-booking/public-booking-page';
|
import { createFileRoute, lazyRouteComponent } from '@tanstack/react-router';
|
||||||
import { createFileRoute } from '@tanstack/react-router';
|
|
||||||
|
const PublicBookingPage = lazyRouteComponent(
|
||||||
|
() => import('@/features/public-booking/public-booking-page'),
|
||||||
|
'PublicBookingPage'
|
||||||
|
);
|
||||||
|
|
||||||
export const Route = createFileRoute('/$complexSlug/booking/')({
|
export const Route = createFileRoute('/$complexSlug/booking/')({
|
||||||
component: PublicBookingIndexRouteComponent,
|
component: RouteComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
function PublicBookingIndexRouteComponent() {
|
function RouteComponent() {
|
||||||
const { complexSlug } = Route.useParams();
|
const { complexSlug } = Route.useParams();
|
||||||
|
|
||||||
return <PublicBookingPage complexSlug={complexSlug} />;
|
return <PublicBookingPage complexSlug={complexSlug} />;
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { ComplexSettingsPage } from '@/features/complex/complex-settings-page';
|
import { createFileRoute, lazyRouteComponent } from '@tanstack/react-router';
|
||||||
import { createFileRoute } from '@tanstack/react-router';
|
|
||||||
|
const ComplexSettingsPage = lazyRouteComponent(
|
||||||
|
() => import('@/features/complex/complex-settings-page'),
|
||||||
|
'ComplexSettingsPage'
|
||||||
|
);
|
||||||
|
|
||||||
export const Route = createFileRoute('/_app/_authenticated/complex/$slug/edit')({
|
export const Route = createFileRoute('/_app/_authenticated/complex/$slug/edit')({
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { ProfilePage } from '@/features/profile/profile-page';
|
import { createFileRoute, lazyRouteComponent } from '@tanstack/react-router';
|
||||||
import { createFileRoute } from '@tanstack/react-router';
|
|
||||||
|
const ProfilePage = lazyRouteComponent(
|
||||||
|
() => import('@/features/profile/profile-page'),
|
||||||
|
'ProfilePage'
|
||||||
|
);
|
||||||
|
|
||||||
export const Route = createFileRoute('/_app/profile')({
|
export const Route = createFileRoute('/_app/profile')({
|
||||||
component: ProfilePage,
|
component: ProfilePage,
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { SetupStepperPage } from '@/features/onboard/setup-stepper-page';
|
import { createFileRoute, lazyRouteComponent, redirect } from '@tanstack/react-router';
|
||||||
import { createFileRoute, redirect } from '@tanstack/react-router';
|
|
||||||
|
const SetupStepperPage = lazyRouteComponent(
|
||||||
|
() => import('@/features/onboard/setup-stepper-page'),
|
||||||
|
'SetupStepperPage'
|
||||||
|
);
|
||||||
|
|
||||||
export const Route = createFileRoute('/onboard/setup')({
|
export const Route = createFileRoute('/onboard/setup')({
|
||||||
beforeLoad: ({ context }) => {
|
beforeLoad: ({ context }) => {
|
||||||
|
|||||||
2
bunfig.toml
Normal file
2
bunfig.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[test]
|
||||||
|
preload = ["./apps/backend/test/support/prisma.mock.ts"]
|
||||||
@@ -3,4 +3,5 @@ set -e
|
|||||||
cd /app/apps/backend
|
cd /app/apps/backend
|
||||||
bun prisma migrate deploy
|
bun prisma migrate deploy
|
||||||
bun prisma generate
|
bun prisma generate
|
||||||
|
bun prisma/seed.ts
|
||||||
bun run start
|
bun run start
|
||||||
@@ -19,7 +19,8 @@
|
|||||||
"lint:frontend": "bun --filter frontend lint",
|
"lint:frontend": "bun --filter frontend lint",
|
||||||
"lint:frontend:fix": "bun --filter frontend lint:fix",
|
"lint:frontend:fix": "bun --filter frontend lint:fix",
|
||||||
"lint:backend": "bun --filter backend lint",
|
"lint:backend": "bun --filter backend lint",
|
||||||
"lint:backend:fix": "bun --filter backend lint:fix"
|
"lint:backend:fix": "bun --filter backend lint:fix",
|
||||||
|
"test": "bun --filter backend test"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^1.9.4",
|
"@biomejs/biome": "^1.9.4",
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ export const adminBookingSchema = z.object({
|
|||||||
endTime: z.string().regex(TIME_REGEX),
|
endTime: z.string().regex(TIME_REGEX),
|
||||||
customerName: z.string(),
|
customerName: z.string(),
|
||||||
customerPhone: z.string(),
|
customerPhone: z.string(),
|
||||||
|
customerEmail: z.string().optional(),
|
||||||
|
price: z.number().nonnegative(),
|
||||||
status: bookingStatusSchema,
|
status: bookingStatusSchema,
|
||||||
createdAt: z.string().datetime(),
|
createdAt: z.string().datetime(),
|
||||||
updatedAt: z.string().datetime(),
|
updatedAt: z.string().datetime(),
|
||||||
@@ -52,6 +54,11 @@ export const createAdminBookingSchema = z.object({
|
|||||||
.trim()
|
.trim()
|
||||||
.min(6, 'El telefono debe tener al menos 6 caracteres.')
|
.min(6, 'El telefono debe tener al menos 6 caracteres.')
|
||||||
.max(30, 'El telefono no puede superar los 30 caracteres.'),
|
.max(30, 'El telefono no puede superar los 30 caracteres.'),
|
||||||
|
customerEmail: z
|
||||||
|
.string()
|
||||||
|
.email('El email ingresado no es valido.')
|
||||||
|
.optional()
|
||||||
|
.or(z.literal('')),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const updateAdminBookingStatusSchema = z.object({
|
export const updateAdminBookingStatusSchema = z.object({
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export const publicBookingSportSchema = z.object({
|
|||||||
export const publicBookingSlotSchema = z.object({
|
export const publicBookingSlotSchema = z.object({
|
||||||
startTime: z.string().regex(TIME_REGEX),
|
startTime: z.string().regex(TIME_REGEX),
|
||||||
endTime: z.string().regex(TIME_REGEX),
|
endTime: z.string().regex(TIME_REGEX),
|
||||||
|
price: z.number().nonnegative(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const publicAvailabilityCourtSchema = z.object({
|
export const publicAvailabilityCourtSchema = z.object({
|
||||||
@@ -56,6 +57,11 @@ export const createPublicBookingSchema = z.object({
|
|||||||
.trim()
|
.trim()
|
||||||
.min(6, 'El telefono debe tener al menos 6 caracteres.')
|
.min(6, 'El telefono debe tener al menos 6 caracteres.')
|
||||||
.max(30, 'El telefono no puede superar los 30 caracteres.'),
|
.max(30, 'El telefono no puede superar los 30 caracteres.'),
|
||||||
|
customerEmail: z
|
||||||
|
.string()
|
||||||
|
.email('El email ingresado no es valido.')
|
||||||
|
.optional()
|
||||||
|
.or(z.literal('')),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const publicBookingSchema = z.object({
|
export const publicBookingSchema = z.object({
|
||||||
@@ -72,20 +78,25 @@ export const publicBookingSchema = z.object({
|
|||||||
endTime: z.string().regex(TIME_REGEX),
|
endTime: z.string().regex(TIME_REGEX),
|
||||||
customerName: z.string(),
|
customerName: z.string(),
|
||||||
customerPhone: z.string(),
|
customerPhone: z.string(),
|
||||||
|
customerEmail: z.string().optional(),
|
||||||
status: z.enum(['CONFIRMED', 'CANCELLED', 'COMPLETED']),
|
status: z.enum(['CONFIRMED', 'CANCELLED', 'COMPLETED']),
|
||||||
|
price: z.number().nonnegative(),
|
||||||
createdAt: z.string().datetime(),
|
createdAt: z.string().datetime(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const publicBookingConfirmationSchema = z.object({
|
export const publicBookingConfirmationSchema = z.object({
|
||||||
bookingCode: z.string().regex(BOOKING_CODE_REGEX),
|
bookingCode: z.string().regex(BOOKING_CODE_REGEX),
|
||||||
complexName: z.string(),
|
complexName: z.string(),
|
||||||
|
complexAddress: z.string().optional(),
|
||||||
complexSlug: z.string(),
|
complexSlug: z.string(),
|
||||||
date: z.string().regex(ISO_DATE_REGEX),
|
date: z.string().regex(ISO_DATE_REGEX),
|
||||||
startTime: z.string().regex(TIME_REGEX),
|
startTime: z.string().regex(TIME_REGEX),
|
||||||
endTime: z.string().regex(TIME_REGEX),
|
endTime: z.string().regex(TIME_REGEX),
|
||||||
|
price: z.number().nonnegative(),
|
||||||
courtName: z.string(),
|
courtName: z.string(),
|
||||||
sport: publicBookingSportSchema,
|
sport: publicBookingSportSchema,
|
||||||
status: z.enum(['CONFIRMED', 'CANCELLED', 'COMPLETED']),
|
status: z.enum(['CONFIRMED', 'CANCELLED', 'COMPLETED']),
|
||||||
|
customerEmail: z.string().optional(),
|
||||||
createdAt: z.string().datetime(),
|
createdAt: z.string().datetime(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user