Compare commits
6 Commits
feat/onboa
...
3e314a9b9a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e314a9b9a | ||
| bc4716c48f | |||
|
|
0e69759549 | ||
|
|
88ea7e70da | ||
|
|
7a30f9a29b | ||
| 83fa1ea020 |
@@ -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()}`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -258,6 +258,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);
|
||||||
|
|
||||||
|
|||||||
@@ -329,9 +329,34 @@ export async function getPublicBookingConfirmation(complexSlug: string, bookingC
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -427,6 +452,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);
|
||||||
|
|
||||||
|
|||||||
@@ -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 />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -638,48 +631,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 +708,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 +756,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 +874,118 @@ 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,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 }) => {
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user