Skip to content

Commit 3f35af2

Browse files
1aurendzdavis
authored andcommitted
[E] Add link to maker error
1 parent db7b64a commit 3f35af2

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

client/src/backend/components/collaborator/AddForm/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import React, { useEffect, useState } from "react";
1+
import { useEffect, useState } from "react";
22
import PropTypes from "prop-types";
33
import { FormContext } from "helpers/contexts";
44
import Form, { Unwrapped } from "global/components/form";
55
import InputError from "global/components/form/InputError";
6-
import { useTranslation } from "react-i18next";
6+
import { useTranslation, Trans } from "react-i18next";
77
import { useNavigate } from "react-router-dom-v5-compat";
88
import { makersAPI, collaboratorsAPI } from "api";
99
import { useApiCallback } from "hooks";
1010
import capitalize from "lodash/capitalize";
11+
import * as Styled from "./styles";
1112

1213
export default function AddCollaboratorForm({
1314
entityId,
@@ -53,7 +54,12 @@ export default function AddCollaboratorForm({
5354
if (!maker?.id) {
5455
return setFormErrors([
5556
{
56-
detail: t("projects.contributor_maker_error"),
57+
detail: (
58+
<Trans
59+
i18nKey="projects.contributor_maker_error"
60+
components={[<Styled.ErrorLink to="/backend/records/makers" />]}
61+
/>
62+
),
5763
source: "maker"
5864
}
5965
]);

client/src/backend/components/collaborator/AddForm/styles.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import styled from "@emotion/styled";
2+
import { Link } from "react-router-dom-v5-compat";
23

34
export const RoleButton = styled.button`
45
display: flex;
@@ -22,3 +23,9 @@ export const RoleGroup = styled.div`
2223
margin-block-start: 40px;
2324
}
2425
`;
26+
27+
export const ErrorLink = styled(Link)`
28+
&:hover {
29+
color: var(--color);
30+
}
31+
`;

client/src/config/app/locale/en-US/json/backend/projects.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"manage_resource_collections": "Manage Resource Collections",
1212
"contributors_header": "Manage Contributors",
1313
"add_contributor_label": "Add Contributor",
14-
"contributor_maker_error": "Maker is required. If adding a new maker, you must first create the maker in the records tab before adding as a collaborator.",
14+
"contributor_maker_error": "Maker is required. If this is a new maker, you must <0>first create the maker</0> before adding as a contributor.",
1515
"contributor_role_error": "Please select at least one role.",
1616
"forms": {
1717
"title_label": "Title",

client/src/global/components/form/InputError/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default class InputError extends Component {
1616
};
1717

1818
errorString(error) {
19+
if (typeof error.detail === "object") return error.detail;
1920
if (error.detail.split(".").length > 1) {
2021
return error.detail;
2122
}

0 commit comments

Comments
 (0)