diff --git a/CHANGELOG.md b/CHANGELOG.md index ad0011279..6c28d95c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ changes. - Fix missing off chain references in DRep details [Issue 3490](https://github.com/IntersectMBO/govtool/issues/3490) - Fix blank screen and type error on linkReferences when navigating to edit dRep page that has no links [Issue 3714](https://github.com/IntersectMBO/govtool/issues/3714) +- Fix adding two link input fields when editing the dRep form when no links are present initially [Issue 3709](https://github.com/IntersectMBO/govtool/issues/3709) ### Changed diff --git a/govtool/frontend/src/components/organisms/EditDRepInfoSteps/EditDRepForm.tsx b/govtool/frontend/src/components/organisms/EditDRepInfoSteps/EditDRepForm.tsx index 1efc085e7..268e8936d 100644 --- a/govtool/frontend/src/components/organisms/EditDRepInfoSteps/EditDRepForm.tsx +++ b/govtool/frontend/src/components/organisms/EditDRepInfoSteps/EditDRepForm.tsx @@ -4,6 +4,7 @@ import { Box } from "@mui/material"; import { useCardano } from "@context"; import { + defaultEditDRepInfoValues, useEditDRepInfoForm, useGetDRepDetailsQuery, useTranslation, @@ -44,15 +45,21 @@ export const EditDRepForm = ({ reset({ ...data, - objectives: data?.objectives ?? "", - motivations: data?.motivations ?? "", - qualifications: data?.qualifications ?? "", - paymentAddress: data?.paymentAddress ?? "", - image: data?.image ?? "", - linkReferences: data?.linkReferences ?? [getEmptyReference("Link")], - identityReferences: data?.identityReferences ?? [ - getEmptyReference("Identity"), - ], + objectives: data?.objectives ?? defaultEditDRepInfoValues.objectives, + motivations: data?.motivations ?? defaultEditDRepInfoValues.motivations, + qualifications: + data?.qualifications ?? defaultEditDRepInfoValues.qualifications, + paymentAddress: + data?.paymentAddress ?? defaultEditDRepInfoValues.paymentAddress, + image: data?.image ?? defaultEditDRepInfoValues.image, + linkReferences: + Array.isArray(data?.linkReferences) && data.linkReferences.length > 0 + ? data.linkReferences + : defaultEditDRepInfoValues.linkReferences, + identityReferences: + Array.isArray(data?.identityReferences) && data.identityReferences.length > 0 + ? data.identityReferences + : defaultEditDRepInfoValues.identityReferences, }); } }, [yourselfDRep, loadUserData]); @@ -74,9 +81,3 @@ export const EditDRepForm = ({ ); }; - -const getEmptyReference = (type: "Link" | "Identity") => ({ - "@type": type, - uri: "", - label: "", -});