From 8d8f4e94ee863fe1566863c66f3e6b2d1af8ec0e Mon Sep 17 00:00:00 2001 From: Zaid Marzguioui Date: Wed, 1 Apr 2026 13:14:53 +0200 Subject: [PATCH] fix(api): convert empty strings to null for date/optional DB columns Course and event creation Server Actions were failing with 'Something went wrong' because empty form strings ('') were being inserted into date/uuid columns which reject empty strings. Now converts '' to null for all optional fields (dates, descriptions, IDs, contact info). --- Dockerfile | 2 +- .../features/course-management/src/server/api.ts | 10 +++++----- packages/features/event-management/src/server/api.ts | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7a6923212..ab730d3a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /app # --- Install + Build in one stage --- FROM base AS builder # CACHE_BUST: change this value to force a full rebuild (busts Docker layer cache) -ARG CACHE_BUST=10 +ARG CACHE_BUST=11 RUN echo "Cache bust: ${CACHE_BUST}" COPY . . RUN pnpm install --no-frozen-lockfile diff --git a/packages/features/course-management/src/server/api.ts b/packages/features/course-management/src/server/api.ts index 13adac1d3..83501fb15 100644 --- a/packages/features/course-management/src/server/api.ts +++ b/packages/features/course-management/src/server/api.ts @@ -31,12 +31,12 @@ export function createCourseManagementApi(client: SupabaseClient) { async createCourse(input: CreateCourseInput) { const { data, error } = await client.from('courses').insert({ - account_id: input.accountId, course_number: input.courseNumber, name: input.name, - description: input.description, category_id: input.categoryId, instructor_id: input.instructorId, - location_id: input.locationId, start_date: input.startDate, end_date: input.endDate, - fee: input.fee, reduced_fee: input.reducedFee, capacity: input.capacity, + account_id: input.accountId, course_number: input.courseNumber || null, name: input.name, + description: input.description || null, category_id: input.categoryId || null, instructor_id: input.instructorId || null, + location_id: input.locationId || null, start_date: input.startDate || null, end_date: input.endDate || null, + fee: input.fee, reduced_fee: input.reducedFee ?? null, capacity: input.capacity, min_participants: input.minParticipants, status: input.status, - registration_deadline: input.registrationDeadline, notes: input.notes, + registration_deadline: input.registrationDeadline || null, notes: input.notes || null, }).select().single(); if (error) throw error; return data; diff --git a/packages/features/event-management/src/server/api.ts b/packages/features/event-management/src/server/api.ts index 77597603d..b6a80c963 100644 --- a/packages/features/event-management/src/server/api.ts +++ b/packages/features/event-management/src/server/api.ts @@ -47,12 +47,12 @@ export function createEventManagementApi(client: SupabaseClient) { async createEvent(input: CreateEventInput) { const { data, error } = await client.from('events').insert({ - account_id: input.accountId, name: input.name, description: input.description, - event_date: input.eventDate, event_time: input.eventTime, end_date: input.endDate, - location: input.location, capacity: input.capacity, min_age: input.minAge, - max_age: input.maxAge, fee: input.fee, status: input.status, - registration_deadline: input.registrationDeadline, - contact_name: input.contactName, contact_email: input.contactEmail, contact_phone: input.contactPhone, + account_id: input.accountId, name: input.name, description: input.description || null, + event_date: input.eventDate || null, event_time: input.eventTime || null, end_date: input.endDate || null, + location: input.location || null, capacity: input.capacity, min_age: input.minAge ?? null, + max_age: input.maxAge ?? null, fee: input.fee, status: input.status, + registration_deadline: input.registrationDeadline || null, + contact_name: input.contactName || null, contact_email: input.contactEmail || null, contact_phone: input.contactPhone || null, }).select().single(); if (error) throw error; return data;