Skip to content

Commit

Permalink
Merge pull request #114 from premieroctet/fix/parse-error
Browse files Browse the repository at this point in the history
Fix parse error on relationship
  • Loading branch information
cregourd authored Jan 16, 2024
2 parents 6713773 + 8af3cc9 commit 53fa342
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-elephants-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin": patch
---

Fix parse error on relationship
7 changes: 3 additions & 4 deletions packages/next-admin/src/utils/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,9 @@ export const parseFormData = <M extends ModelName>(
const dmmfPropertyType = dmmfProperty.type;
const dmmfPropertyKind = dmmfProperty.kind;
if (dmmfPropertyKind === "object") {
if (Boolean(formData[dmmfPropertyName])) {
parsedData[dmmfPropertyName] = JSON.parse(
formData[dmmfPropertyName] as string
) as ModelWithoutRelationships<M>[typeof dmmfPropertyName];
if (formData[dmmfPropertyName]) {
parsedData[dmmfPropertyName] =
formData[dmmfPropertyName] as unknown as ModelWithoutRelationships<M>[typeof dmmfPropertyName];
} else {
parsedData[dmmfPropertyName] =
null as ModelWithoutRelationships<M>[typeof dmmfPropertyName];
Expand Down

0 comments on commit 53fa342

Please sign in to comment.