From 8c9405f6189e691b21ab5a3ba2a7491cacc24c1c Mon Sep 17 00:00:00 2001 From: Kashif <48419247+yaKashif@users.noreply.github.com> Date: Tue, 10 Sep 2024 20:43:45 +0500 Subject: [PATCH] fix: crash when options.model.edit is not defined (#410) * fix: crash when options.model.edit is not defined * chore: add changeset --- .changeset/clever-coins-teach.md | 5 +++++ packages/next-admin/src/utils/server.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/clever-coins-teach.md diff --git a/.changeset/clever-coins-teach.md b/.changeset/clever-coins-teach.md new file mode 100644 index 00000000..8b41452e --- /dev/null +++ b/.changeset/clever-coins-teach.md @@ -0,0 +1,5 @@ +--- +"@premieroctet/next-admin": patch +--- + +fix crash when edit object is not defined in options.model diff --git a/packages/next-admin/src/utils/server.ts b/packages/next-admin/src/utils/server.ts index 9da6e8c2..153863bf 100644 --- a/packages/next-admin/src/utils/server.ts +++ b/packages/next-admin/src/utils/server.ts @@ -1014,7 +1014,7 @@ export const removeHiddenProperties = export const addCustomProperties = (resource: M, editOptions: EditOptions) => (schema: Schema) => { - const customFieldKeys = Object.keys(editOptions.customFields ?? {}); + const customFieldKeys = Object.keys(editOptions?.customFields ?? {}); customFieldKeys.forEach((property) => { const fieldOptions = editOptions?.customFields?.[property];