Skip to content

Commit

Permalink
Fix parse error on relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
cregourd committed Jan 16, 2024
1 parent 6713773 commit 8af3cc9
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 8af3cc9

Please sign in to comment.