Skip to content

Commit

Permalink
"Create new form" hotfix (#127)
Browse files Browse the repository at this point in the history
* Fix issue preventing navigation to new form.

* Prevent saving empty forms with the initial periodic save behavior.
  • Loading branch information
danielnaab authored May 10, 2024
1 parent 5eb467e commit beb29c8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
26 changes: 24 additions & 2 deletions packages/design/src/FormManager/FormList/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ export const createFormListSlice =
name: url,
data,
});
return context.formService.addForm(builder.form);
const result = await context.formService.addForm(builder.form);
if (result.success) {
return {
success: true,
data: result.data.id,
};
} else {
return {
success: false,
error: result.error,
};
}
},
createNewFormByPDFUpload: async fileDetails => {
const builder = new BlueprintBuilder();
Expand All @@ -43,7 +54,18 @@ export const createFormListSlice =
description: '',
});
await builder.addDocument(fileDetails);
return await context.formService.addForm(builder.form);
const result = await context.formService.addForm(builder.form);
if (result.success) {
return {
success: true,
data: result.data.id,
};
} else {
return {
success: false,
error: result.error,
};
}
},
});

Expand Down
2 changes: 1 addition & 1 deletion packages/design/src/FormManager/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const savePeriodically = (store: UseBoundStore<StoreApi<FormManagerStore>>) => {
let lastForm: Blueprint;
setInterval(async () => {
const { form, saveForm } = store.getState();
if (lastForm !== form) {
if (lastForm && lastForm !== form) {
await saveForm(form);
lastForm = form;
}
Expand Down

0 comments on commit beb29c8

Please sign in to comment.