Skip to content

Commit

Permalink
fix: asset creation inside ebios study (#1460)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene authored Feb 3, 2025
1 parent 7476191 commit d5afb49
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion frontend/src/lib/utils/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,17 @@ export const loadDetail = async ({ event, model, id }) => {

const deleteForm = await superValidate(zod(z.object({ id: z.string().uuid() })));
const createSchema = modelSchema(e.urlModel);
initialData[e.field] = data.id;
const fieldSchema = createSchema.shape[e.field];
let isArrayField = false;

if (fieldSchema) {
let currentSchema = fieldSchema;
while (currentSchema instanceof z.ZodOptional || currentSchema instanceof z.ZodNullable) {
currentSchema = currentSchema._def.innerType;
}
isArrayField = currentSchema instanceof z.ZodArray;
}
initialData[e.field] = isArrayField ? [data.id] : data.id;
if (data.folder) {
if (!new RegExp(UUID_REGEX).test(data.folder)) {
const objectEndpoint = `${endpoint}object/`;
Expand Down

0 comments on commit d5afb49

Please sign in to comment.