diff --git a/packages/react-components/src/Accounts/Accounts.tsx b/packages/react-components/src/Accounts/Accounts.tsx index fcdf847a..fb03d73a 100644 --- a/packages/react-components/src/Accounts/Accounts.tsx +++ b/packages/react-components/src/Accounts/Accounts.tsx @@ -56,6 +56,8 @@ const Accounts: React.FC = ({ host, token, userGroupsDefaultSele const [deletedDialog, setDeletedDialog] = useState(false); const [deleteRow, setDeleteRow] = useState({}); const [filteringColumnExtensions, setFilteringColumnExtensions] = useState([]); + const [error, setError] = useState(false); + const [errorMessage, setErrorMessage] = useState(''); const getRowId = (row) => row.id; const metadataHeader = metadata @@ -129,21 +131,23 @@ const Accounts: React.FC = ({ host, token, userGroupsDefaultSele const handleSubmit = (row, isNew = false) => { if (isNew) { - return ( - createAccount(host, token, { ...row }).subscribe(() => { + return createAccount(host, token, { ...row }).subscribe( + () => { fetchData(); - }), + }, (error) => { console.log('Create Account: ', error); } ); } else { - return ( - updateAccount(host, token, { ...row }).subscribe(() => { + return updateAccount(host, token, { ...row }).subscribe( + () => { fetchData(); - }), + }, (error) => { - console.log('Update Accounts: ', error); + setError(true); + setErrorMessage('Passwords must be at least 7 characters'); + console.log('Update Account: ', error); } ); } @@ -202,6 +206,8 @@ const Accounts: React.FC = ({ host, token, userGroupsDefaultSele onSave={handleSubmit} hasPassword userGroupsDefaultSelected={userGroupsDefaultSelected} + errorAccount={error} + errorMessage={errorMessage} /> diff --git a/packages/react-components/src/common/Table/Popup.tsx b/packages/react-components/src/common/Table/Popup.tsx index d8a2e398..12018d0a 100644 --- a/packages/react-components/src/common/Table/Popup.tsx +++ b/packages/react-components/src/common/Table/Popup.tsx @@ -44,6 +44,8 @@ const Popup: React.FC = ({ metadata, hasPassword, userGroupsDefaultSelected, + errorMessage, + errorAccount, }) => { const [error, setError] = useState(false); const [passwordStrengthColor, setPasswordStrengthColor] = useState('red'); @@ -141,7 +143,8 @@ const Popup: React.FC = ({ variant="standard" required={isNew} value={row.password || ''} - error={!passwordValid} + error={!passwordValid || errorAccount} + helperText={errorMessage} InputProps={{ endAdornment }} onChange={onChange} autoComplete="new-password" @@ -156,9 +159,12 @@ const Popup: React.FC = ({ required={isNew} label="Repeat Password" value={row.repeatPassword || ''} - error={!passwordValid} + error={!passwordValid || errorAccount} onChange={onChange} - helperText={!passwordValid && 'Passwords do not match'} + helperText={ + (!passwordValid && 'Passwords do not match') || + errorMessage + } autoComplete="new-password" /> diff --git a/packages/react-components/src/common/Table/PopupEditing.tsx b/packages/react-components/src/common/Table/PopupEditing.tsx index 68e3526e..a117fa37 100644 --- a/packages/react-components/src/common/Table/PopupEditing.tsx +++ b/packages/react-components/src/common/Table/PopupEditing.tsx @@ -12,6 +12,8 @@ const PopupEditing = React.memo( onSave, hasPassword, userGroupsDefaultSelected, + errorAccount, + errorMessage, }: PopupEditingProps) => (