diff --git a/src/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx b/src/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx index d54364f9a..ad1968139 100644 --- a/src/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx +++ b/src/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx @@ -19,7 +19,6 @@ import { commonMessages } from "@saleor/intl"; import { ConfirmButtonTransitionState, makeStyles } from "@saleor/macaw-ui"; import { FetchMoreProps, RelayToFlat, SearchPageProps } from "@saleor/types"; import { getFormErrors } from "@saleor/utils/errors"; -import getStaffErrorMessage from "@saleor/utils/errors/staff"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; @@ -81,6 +80,14 @@ const StaffAddMemberDialog: React.FC = props => { dialogErrors, ); + const getFieldProps = (name: string) => ({ + disabled: props.disabled, + error: !!formErrors[name], + helperText: formErrors[name]?.message, + label: intl.formatMessage(commonMessages[name]), + name, + }); + return (
@@ -96,25 +103,13 @@ const StaffAddMemberDialog: React.FC = props => {
= props => {
= props => { const imgInputAnchor = React.createRef(); const clickImgInput = () => imgInputAnchor.current.click(); - const formErrors = getFormErrors(["id"], errors || []); + const formErrors = getFormErrors( + ["id", "firstName", "lastName", "email"], + errors || [], + ); const hasAvatar = !!staffMember?.avatar?.url; + const getFieldProps = (name: string) => ({ + disabled: props.disabled, + error: !!formErrors[name], + helperText: formErrors[name]?.message, + label: intl.formatMessage(commonMessages[name]), + name, + value: data[name], + }); + return ( = props => {
diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index ba826ca8a..eec3cfbf9 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -248304,17 +248304,18 @@ exports[`Storyshots Views / Staff / Staff member details loading 1`] = ` class="MuiFormControl-root-id MuiTextField-root-id MuiFormControl-fullWidth-id" >