New fields for complex

This commit is contained in:
Jose Selesan
2026-04-09 16:18:58 -03:00
parent ae90562d88
commit 3cba2fa485
15 changed files with 603 additions and 7 deletions

View File

@@ -7,6 +7,9 @@ export type CreateComplexInput = {
physicalAddress: string
adminEmail: string
planCode?: string
city?: string
state?: string
country?: string
}
export type UpdateComplexInput = {
@@ -15,6 +18,9 @@ export type UpdateComplexInput = {
complexSlug?: string
adminEmail?: string
planCode?: string | null
city?: string | null
state?: string | null
country?: string | null
}
function slugify(value: string): string {
@@ -68,6 +74,9 @@ export async function createComplex(input: CreateComplexInput) {
id: uuidv7(),
complexName: input.complexName,
physicalAddress: input.physicalAddress.trim(),
city: input.city?.trim() || null,
state: input.state?.trim() || null,
country: input.country?.trim() || null,
complexSlug,
adminEmail: input.adminEmail,
planCode: input.planCode,
@@ -125,6 +134,18 @@ export async function updateComplex(id: string, input: UpdateComplexInput) {
data.physicalAddress = input.physicalAddress?.trim() ?? null
}
if (input.city !== undefined) {
data.city = input.city?.trim() ?? null
}
if (input.state !== undefined) {
data.state = input.state?.trim() ?? null
}
if (input.country !== undefined) {
data.country = input.country?.trim() ?? null
}
return db.complex.update({
where: { id },
data: data as Prisma.ComplexUncheckedUpdateInput,