Skip to content

Commit

Permalink
fix: replace link with uri in all metadatas
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Jun 12, 2024
1 parent 2cd8eba commit ac93f5f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ export const CreateGovernanceActionForm = ({
}
});

const addLink = useCallback(() => append({ link: "" }), [append]);
const addLink = useCallback(() => append({ uri: "" }), [append]);

const removeLink = useCallback((index: number) => remove(index), [remove]);

const renderLinks = useCallback(
() =>
references.map((field, index) => (
<ControlledField.Input
{...register(`references.${index}.link`)}
{...register(`references.${index}.uri`)}
errors={errors}
endAdornment={
references.length > 1 ? (
Expand All @@ -107,7 +107,7 @@ export const CreateGovernanceActionForm = ({
label={`${t("forms.link")} ${index + 1}`}
layoutStyles={{ mb: 3 }}
placeholder={Placeholders.LINK}
name={`references.${index}.link`}
name={`references.${index}.uri`}
rules={{
pattern: {
value: URL_REGEX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const ReviewCreatedGovernanceAction = ({
});

const renderLinks = () => {
const references = values.references?.map((item) => item.link) ?? [];
const references = values.references?.map((item) => item.uri) ?? [];
const areReferences = references.some((item) => item);

return areReferences ? (
Expand All @@ -85,13 +85,13 @@ export const ReviewCreatedGovernanceAction = ({
{t("createGovernanceAction.supportingLinks")}
</Typography>
{references.map(
(link: string, index: number) =>
link && (
(uri: string, index: number) =>
uri && (
<LinkWithIcon
dataTestId={`governance-action-link-${index + 1}-content`}
icon={<img alt="link" src={ICONS.link} />}
label={link}
onClick={() => onClickLink(link)}
label={uri}
onClick={() => onClickLink(uri)}
sx={{ mb: 1.75 }}
/>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const EditDRepForm = ({

const onClickContinue = () => setStep(2);

const addLink = useCallback(() => append({ link: "" }), [append]);
const addLink = useCallback(() => append({ uri: "" }), [append]);

const removeLink = useCallback((index: number) => remove(index), [remove]);

Expand All @@ -61,15 +61,17 @@ export const EditDRepForm = ({
state
? {
...state,
links: state.references.map((link: string) => ({
link,
references: state.references.map((uri: string) => ({
uri,
})),
}
: {
...yourselfDRepList?.[0],
links: yourselfDRepList?.[0].references.map((link: string) => ({
link,
})),
references: yourselfDRepList?.[0].references.map(
(uri: string) => ({
uri,
}),
),
},
);
}, [yourselfDRepList]);
Expand All @@ -78,7 +80,7 @@ export const EditDRepForm = ({
() =>
references.map((field, index) => (
<ControlledField.Input
{...register(`references.${index}.link`)}
{...register(`references.${index}.uri`)}
errors={errors}
endAdornment={
references.length > 1 ? (
Expand All @@ -96,7 +98,7 @@ export const EditDRepForm = ({
label={t("forms.link") + ` ${index + 1}`}
layoutStyles={{ mb: 3 }}
placeholder={Placeholders.LINK}
name={`references.${index}.link`}
name={`references.${index}.uri`}
rules={Rules.LINK}
/>
)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const RegisterAsDRepForm = ({

const onClickBack = () => setStep(1);

const addLink = useCallback(() => append({ link: "" }), [append]);
const addLink = useCallback(() => append({ uri: "" }), [append]);

const removeLink = useCallback((index: number) => remove(index), [remove]);

Expand All @@ -51,7 +51,7 @@ export const RegisterAsDRepForm = ({
() =>
references.map((field, index) => (
<ControlledField.Input
{...register(`references.${index}.link`)}
{...register(`references.${index}.uri`)}
errors={errors}
endAdornment={
references.length > 1 ? (
Expand All @@ -69,7 +69,7 @@ export const RegisterAsDRepForm = ({
label={t("forms.link") + ` ${index + 1}`}
layoutStyles={{ mb: 3 }}
placeholder={Placeholders.LINK}
name={`references.${index}.link`}
name={`references.${index}.uri`}
rules={Rules.LINK}
/>
)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ import {
import { useValidateMutation } from "../mutations";

export type CreateGovernanceActionValues = {
references?: { link: string }[];
references?: { uri: string }[];
storeData?: boolean;
storingURL: string;
governance_action_type?: GovernanceActionType;
} & Partial<Record<keyof GovernanceActionFieldSchemas, string>>;

export const defaulCreateGovernanceActionValues: CreateGovernanceActionValues =
{
references: [{ link: "" }],
references: [{ uri: "" }],
storeData: false,
storingURL: "",
};
Expand Down
4 changes: 2 additions & 2 deletions govtool/frontend/src/hooks/forms/useEditDRepInfoForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type EditDRepInfoValues = {
bio?: string;
dRepName: string;
email?: string;
references?: Array<{ link: string }>;
references?: Array<{ uri: string }>;
storeData?: boolean;
storingURL: string;
};
Expand All @@ -36,7 +36,7 @@ export const defaultEditDRepInfoValues: EditDRepInfoValues = {
bio: "",
dRepName: "",
email: "",
references: [{ link: "" }],
references: [{ uri: "" }],
storeData: false,
storingURL: "",
};
Expand Down
4 changes: 2 additions & 2 deletions govtool/frontend/src/hooks/forms/useRegisterAsdRepForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type RegisterAsDRepValues = {
bio?: string;
dRepName: string;
email?: string;
references?: Array<{ link: string }>;
references?: Array<{ uri: string }>;
storeData?: boolean;
storingURL: string;
};
Expand All @@ -38,7 +38,7 @@ export const defaultRegisterAsDRepValues: RegisterAsDRepValues = {
bio: "",
dRepName: "",
email: "",
references: [{ link: "" }],
references: [{ uri: "" }],
storeData: false,
storingURL: "",
};
Expand Down

0 comments on commit ac93f5f

Please sign in to comment.