feat: add city/state/country to complex, new settings page with sidebar, and Biome linting
- Added city, state, and country optional fields to Complex model - Updated onboarding to include optional location fields - Created new settings page with sidebar navigation (Datos del Complejo, Canchas) - Replaced ESLint with Biome for frontend and backend linting - Added parallel dev script with concurrently - Migrated register-routes to use direct app.route() pattern
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
import { v7 as uuidv7 } from 'uuid'
|
||||
import { Prisma } from '@/generated/prisma/client'
|
||||
import { db } from '@/lib/prisma'
|
||||
import { Prisma } from '@/generated/prisma/client';
|
||||
import { db } from '@/lib/prisma';
|
||||
import { v7 as uuidv7 } from 'uuid';
|
||||
|
||||
export type CreateComplexInput = {
|
||||
complexName: string
|
||||
physicalAddress: string
|
||||
adminEmail: string
|
||||
planCode?: string
|
||||
city?: string
|
||||
state?: string
|
||||
country?: string
|
||||
}
|
||||
complexName: string;
|
||||
physicalAddress: string;
|
||||
adminEmail: string;
|
||||
planCode?: string;
|
||||
city?: string;
|
||||
state?: string;
|
||||
country?: string;
|
||||
};
|
||||
|
||||
export type UpdateComplexInput = {
|
||||
complexName?: string
|
||||
physicalAddress?: string | null
|
||||
complexSlug?: string
|
||||
adminEmail?: string
|
||||
planCode?: string | null
|
||||
city?: string | null
|
||||
state?: string | null
|
||||
country?: string | null
|
||||
}
|
||||
complexName?: string;
|
||||
physicalAddress?: string | null;
|
||||
complexSlug?: string;
|
||||
adminEmail?: string;
|
||||
planCode?: string | null;
|
||||
city?: string | null;
|
||||
state?: string | null;
|
||||
country?: string | null;
|
||||
};
|
||||
|
||||
function slugify(value: string): string {
|
||||
return value
|
||||
@@ -31,18 +31,15 @@ function slugify(value: string): string {
|
||||
.trim()
|
||||
.replace(/[^a-z0-9\s-]/g, '')
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/-+/g, '-')
|
||||
.replace(/-+/g, '-');
|
||||
}
|
||||
|
||||
async function buildUniqueSlug(
|
||||
source: string,
|
||||
excludeComplexId?: string,
|
||||
): Promise<string> {
|
||||
const base = slugify(source)
|
||||
const fallback = base.length > 0 ? base : `complex-${uuidv7().slice(0, 8)}`
|
||||
async function buildUniqueSlug(source: string, excludeComplexId?: string): Promise<string> {
|
||||
const base = slugify(source);
|
||||
const fallback = base.length > 0 ? base : `complex-${uuidv7().slice(0, 8)}`;
|
||||
|
||||
let candidate = fallback
|
||||
let index = 1
|
||||
let candidate = fallback;
|
||||
let index = 1;
|
||||
|
||||
while (true) {
|
||||
const existing = await db.complex.findFirst({
|
||||
@@ -57,17 +54,17 @@ async function buildUniqueSlug(
|
||||
: {}),
|
||||
},
|
||||
select: { id: true },
|
||||
})
|
||||
});
|
||||
|
||||
if (!existing) return candidate
|
||||
if (!existing) return candidate;
|
||||
|
||||
index += 1
|
||||
candidate = `${fallback}-${index}`
|
||||
index += 1;
|
||||
candidate = `${fallback}-${index}`;
|
||||
}
|
||||
}
|
||||
|
||||
export async function createComplex(input: CreateComplexInput) {
|
||||
const complexSlug = await buildUniqueSlug(input.complexName)
|
||||
const complexSlug = await buildUniqueSlug(input.complexName);
|
||||
|
||||
return db.complex.create({
|
||||
data: {
|
||||
@@ -81,19 +78,19 @@ export async function createComplex(input: CreateComplexInput) {
|
||||
adminEmail: input.adminEmail,
|
||||
planCode: input.planCode,
|
||||
},
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export async function getComplexById(id: string) {
|
||||
return db.complex.findUnique({
|
||||
where: { id },
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export async function getComplexBySlug(slug: string) {
|
||||
return db.complex.findUnique({
|
||||
where: { complexSlug: slug },
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export async function listMyComplexes(appUserId: string) {
|
||||
@@ -105,49 +102,49 @@ export async function listMyComplexes(appUserId: string) {
|
||||
orderBy: {
|
||||
createdAt: 'asc',
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
return complexUsers.map((complexUser) => complexUser.complex)
|
||||
return complexUsers.map((complexUser) => complexUser.complex);
|
||||
}
|
||||
|
||||
export async function updateComplex(id: string, input: UpdateComplexInput) {
|
||||
const data: Record<string, unknown> = {}
|
||||
const data: Record<string, unknown> = {};
|
||||
|
||||
if (input.complexName) {
|
||||
data.complexName = input.complexName
|
||||
data.complexSlug = await buildUniqueSlug(input.complexName, id)
|
||||
data.complexName = input.complexName;
|
||||
data.complexSlug = await buildUniqueSlug(input.complexName, id);
|
||||
}
|
||||
|
||||
if (input.complexSlug) {
|
||||
data.complexSlug = await buildUniqueSlug(input.complexSlug, id)
|
||||
data.complexSlug = await buildUniqueSlug(input.complexSlug, id);
|
||||
}
|
||||
|
||||
if (input.adminEmail) {
|
||||
data.adminEmail = input.adminEmail
|
||||
data.adminEmail = input.adminEmail;
|
||||
}
|
||||
|
||||
if (input.planCode !== undefined) {
|
||||
data.planCode = input.planCode
|
||||
data.planCode = input.planCode;
|
||||
}
|
||||
|
||||
if (input.physicalAddress !== undefined) {
|
||||
data.physicalAddress = input.physicalAddress?.trim() ?? null
|
||||
data.physicalAddress = input.physicalAddress?.trim() ?? null;
|
||||
}
|
||||
|
||||
if (input.city !== undefined) {
|
||||
data.city = input.city?.trim() ?? null
|
||||
data.city = input.city?.trim() ?? null;
|
||||
}
|
||||
|
||||
if (input.state !== undefined) {
|
||||
data.state = input.state?.trim() ?? null
|
||||
data.state = input.state?.trim() ?? null;
|
||||
}
|
||||
|
||||
if (input.country !== undefined) {
|
||||
data.country = input.country?.trim() ?? null
|
||||
data.country = input.country?.trim() ?? null;
|
||||
}
|
||||
|
||||
return db.complex.update({
|
||||
where: { id },
|
||||
data: data as Prisma.ComplexUncheckedUpdateInput,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user