Skip to content

Commit

Permalink
fix: update resource folder form field
Browse files Browse the repository at this point in the history
  • Loading branch information
deeonwuli committed Jan 13, 2025
1 parent eb659d8 commit 2df05d7
Showing 1 changed file with 39 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function mapResourceToInitialFormState(

const fromIdsDictionary = (key: keyof typeof resourceFieldIds) =>
getFieldIdFromIdsDictionary(key, resourceFieldIds);

const { isAdmin } = resourcePermissions;

return {
Expand All @@ -37,58 +36,71 @@ export function mapResourceToInitialFormState(
isValid: false,
sections: [
{
title: "Resource type",
id: `${fromIdsDictionary("resourceType")}_section`,
title: "Resource name",
id: `${fromIdsDictionary("resourceLabel")}_section`,
isVisible: true,
required: true,
fields: [
{
id: fromIdsDictionary("resourceType"),
placeholder: "Select a resource type",
id: fromIdsDictionary("resourceLabel"),
isVisible: true,
errors: [],
type: "select",
multiple: false,
options: resourceTypeOptions,
value: resource?.resourceType || "",
type: "text",
value: resource?.resourceLabel || "",
required: true,
},
],
},
{
title: "Resource name",
id: `${fromIdsDictionary("resourceLabel")}_section`,
title: "Resource type",
id: `${fromIdsDictionary("resourceType")}_section`,
isVisible: true,
required: true,
fields: [
{
id: fromIdsDictionary("resourceLabel"),
id: fromIdsDictionary("resourceType"),
placeholder: "Select a resource type",
isVisible: true,
errors: [],
type: "text",
value: resource?.resourceLabel || "",
type: "select",
multiple: false,
options: resourceTypeOptions,
value: resource?.resourceType || "",
required: true,
},
],
},

{
title: "Resource folder",
id: `${fromIdsDictionary("resourceFolder")}_section`,
isVisible: isResourceDocument,
required: true,
fields: [
{
id: fromIdsDictionary("resourceFolder"),
isVisible: isResourceDocument,
errors: [],
type: "select",
options: resourceFolderOptions,
multiple: false,
addNewOption: isAdmin,
value: isResourceDocument ? resource.resourceFolder : "",
required: true,
},
],
fields:
resourceFolderOptions.length === 0
? [
{
id: fromIdsDictionary("resourceFolder"),
isVisible: isResourceDocument,
errors: [],
type: "text",
value: isResourceDocument ? resource.resourceFolder : "",
required: true,
},
]
: [
{
id: fromIdsDictionary("resourceFolder"),
isVisible: isResourceDocument,
errors: [],
type: "select",
options: resourceFolderOptions,
multiple: false,
addNewOption: isAdmin,
value: isResourceDocument ? resource.resourceFolder : "",
required: true,
},
],
},
{
title: "Resource file",
Expand Down

0 comments on commit 2df05d7

Please sign in to comment.