fix: update recurringGroupId assignment and improve type definitions in helpers

This commit is contained in:
Jose Selesan
2026-06-26 14:58:40 -03:00
parent c7e685ea08
commit ab69711e87
7 changed files with 33 additions and 14 deletions

View File

@@ -1,6 +1,5 @@
import { db } from '@/lib/prisma';
import { buildUniqueSlug, slugify } from '@/lib/slug';
import { ensureActiveSport } from '@/modules/court/shared/guards';
import type { CreateComplexInput } from '@repo/api-contract';
import { v7 as uuidv7 } from 'uuid';
@@ -65,7 +64,15 @@ export async function createComplex(input: CreateComplexInternalInput) {
}
if (input.setupCourts && input.courtSportId) {
const sport = await ensureActiveSport(input.courtSportId);
const sport = await tx.sport.findFirst({
where: { id: input.courtSportId, isActive: true },
select: { name: true },
});
if (!sport) {
throw new Error('El deporte seleccionado no existe o esta inactivo.');
}
const availability = (input.courtDaysOfWeek ?? []).map((day) => ({
dayOfWeek: day as DayOfWeek,
startTime: input.courtStartTime ?? '08:00',