feat: add initial seed data migration and form builder components

- Created migration 0001_seed_data.sql to insert minimal seed data for users, accounts, and roles.
- Added meta journal for migration tracking.
- Implemented FormBuilder component for dynamic form field creation and management.
- Developed FormFieldRenderer component to render various types of form fields based on user input.
- Introduced constants for trust levels and status configurations.
- Defined types for form fields and trial data structures to enhance type safety and clarity.
This commit is contained in:
2026-03-26 14:56:00 -04:00
parent 1c7f0297a6
commit 7c360dc860
29 changed files with 1551 additions and 4779 deletions
+14 -4
View File
@@ -137,7 +137,7 @@ const trialSchema = z.object({
experimentId: z.string().uuid("Please select an experiment"),
participantId: z.string().uuid("Please select a participant"),
scheduledAt: z.date(),
wizardId: z.string().uuid().optional(),
wizardId: z.string().uuid().optional().or(z.literal("")),
notes: z.string().max(1000, "Notes cannot exceed 1000 characters").optional(),
sessionNumber: z
.number()
@@ -269,8 +269,18 @@ export function TrialForm({ mode, trialId, studyId }: TrialFormProps) {
}
}, [trial, mode, form]);
const createTrialMutation = api.trials.create.useMutation();
const updateTrialMutation = api.trials.update.useMutation();
const createTrialMutation = api.trials.create.useMutation({
onError: (error) => {
console.error("Create trial error:", error);
setError(error.message);
},
});
const updateTrialMutation = api.trials.update.useMutation({
onError: (error) => {
console.error("Update trial error:", error);
setError(error.message);
},
});
// Form submission
const onSubmit = async (data: TrialFormData) => {
@@ -283,7 +293,7 @@ export function TrialForm({ mode, trialId, studyId }: TrialFormProps) {
experimentId: data.experimentId,
participantId: data.participantId,
scheduledAt: data.scheduledAt,
wizardId: data.wizardId,
wizardId: data.wizardId || undefined,
sessionNumber: data.sessionNumber ?? 1,
notes: data.notes ?? undefined,
});