feat: add update and delete functionality for courses, events, and species; enhance attendance tracking and category creation
Some checks failed
Workflow / ʦ TypeScript (push) Failing after 4m53s
Workflow / ⚫️ Test (push) Has been skipped

This commit is contained in:
T. Zehetbauer
2026-04-01 16:03:50 +02:00
parent 7b078f298b
commit c6b2824da8
48 changed files with 2036 additions and 390 deletions

View File

@@ -33,19 +33,7 @@ export const createRecord = authActionClient
}
// Validate data against field definitions
const fields = (
moduleWithFields as unknown as {
fields: Array<{
name: string;
field_type: string;
is_required: boolean;
min_value?: number | null;
max_value?: number | null;
max_length?: number | null;
regex_pattern?: string | null;
}>;
}
).fields;
const { fields } = moduleWithFields;
const validation = validateRecordData(
input.data as Record<string, unknown>,
fields as Parameters<typeof validateRecordData>[1],
@@ -98,19 +86,7 @@ export const updateRecord = authActionClient
throw new Error('Module not found');
}
const fields = (
moduleWithFields as unknown as {
fields: Array<{
name: string;
field_type: string;
is_required: boolean;
min_value?: number | null;
max_value?: number | null;
max_length?: number | null;
regex_pattern?: string | null;
}>;
}
).fields;
const { fields } = moduleWithFields;
const validation = validateRecordData(
input.data as Record<string, unknown>,
fields as Parameters<typeof validateRecordData>[1],

View File

@@ -6,6 +6,7 @@ import type {
CreateModuleInput,
UpdateModuleInput,
} from '../../schema/module.schema';
import type { ModuleWithFields } from '../../types';
/**
* Service for managing module definitions (CRUD).
@@ -38,15 +39,20 @@ export function createModuleDefinitionService(
return data;
},
async getModuleWithFields(moduleId: string) {
async getModuleWithFields(
moduleId: string,
): Promise<ModuleWithFields | null> {
const { data, error } = await client
.from('modules')
.select('*, fields:module_fields(*)')
.eq('id', moduleId)
.single();
if (error) throw error;
return data;
if (error) {
if (error.code === 'PGRST116') return null;
throw error;
}
return data as unknown as ModuleWithFields;
},
async createModule(input: CreateModuleInput) {

View File

@@ -0,0 +1,12 @@
import type { Tables } from '@kit/supabase/database';
/** A module row from the database */
export type Module = Tables<'modules'>;
/** A module field row from the database */
export type ModuleField = Tables<'module_fields'>;
/** Module with its field definitions joined */
export interface ModuleWithFields extends Module {
fields: ModuleField[];
}