Skip to content

Commit 795bbcd

Browse files
committed
User friendly error when set pasword link is expired
Ref HadleyLab/ucfwealth#42
1 parent 7703fe2 commit 795bbcd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

contrib/fhir-emr

Submodule fhir-emr updated 34 files

src/containers/SetPassword/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { t } from '@lingui/macro';
2-
import { Button } from 'antd';
2+
import { Button, notification } from 'antd';
33
import { useParams } from 'react-router-dom';
44

55
import { QuestionnaireResponseForm } from '@beda.software/emr/components';
@@ -9,13 +9,16 @@ import { AuthLayout } from 'src/components/AuthLayout';
99

1010
import { S } from './styles';
1111
import { authorize } from '../SignIn';
12+
import { OperationOutcome } from 'fhir/r4b';
13+
import { useNavigate } from 'react-router-dom';
1214

1315
interface Props {
1416
originPathName?: string;
1517
}
1618

1719
export function SetPassword(props: Props) {
1820
const { code } = useParams<{ code: string }>();
21+
const navigate = useNavigate();
1922

2023
return (
2124
<AuthLayout illustrationNumber={3}>
@@ -27,6 +30,10 @@ export function SetPassword(props: Props) {
2730
onSuccess={() => {
2831
authorize({ nextUrl: props.originPathName })
2932
}}
33+
onFailure={(error: OperationOutcome) => {
34+
const message = error.issue.map(i => i.diagnostics).join(',');
35+
notification.error({ message });
36+
}}
3037
saveButtonTitle={t`Save`}
3138
initialQuestionnaireResponse={{
3239
id: 'reset-password',
@@ -53,6 +60,9 @@ export function SetPassword(props: Props) {
5360
>
5461
{t`Submit`}
5562
</Button>
63+
<Button type="link" onClick={() => navigate('/forgot-password')}>
64+
{t`Request a new link`}
65+
</Button>
5666
</S.Buttons>
5767
)}
5868
/>

0 commit comments

Comments
 (0)