Skip to content

Commit 0df59e4

Browse files
committed
add previous button to privacy statement
1 parent aa27be3 commit 0df59e4

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

frontend/app/routes/protected/person-case/layout.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ export default function Layout({ actionData, loaderData, matches, params }: Rout
3030
const abandonAction = i18n.language == 'fr' ? abandonRoute.paths.fr : abandonRoute.paths.en;
3131

3232
if (!tabId) {
33-
// if there is no tab id, render a spinner and wait for one to be generated
34-
// TODO ::: GjB ::: this is horribly styled
35-
return <FontAwesomeIcon className="m-8" icon={faSpinner} size="5x" spinPulse={true} />;
33+
return <FontAwesomeIcon className="m-8 animate-[spin_3s_infinite_linear] text-slate-800" icon={faSpinner} size="3x" />;
3634
}
3735

3836
return (

frontend/app/routes/protected/person-case/privacy-statement.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ export async function action({ context, params, request }: Route.ActionArgs) {
4848
const action = formData.get('action');
4949

5050
switch (action) {
51+
case 'back': {
52+
machineActor.send({ type: 'exit' });
53+
throw i18nRedirect('routes/protected/index.tsx', request);
54+
}
55+
5156
case 'next': {
5257
const parseResult = v.safeParse(privacyStatementSchema, {
5358
agreedToTerms: formData.get('agreedToTerms') ? true : undefined,
@@ -119,6 +124,9 @@ export default function PrivacyStatement({ loaderData, params }: Route.Component
119124
<Button name="action" value="next" variant="primary" id="continue-button" disabled={isSubmitting}>
120125
{t('protected:person-case.next')}
121126
</Button>
127+
<Button name="action" value="back" id="back-button" disabled={isSubmitting}>
128+
{t('protected:person-case.previous')}
129+
</Button>
122130
</div>
123131
</fetcher.Form>
124132
</FetcherErrorSummary>

frontend/app/routes/protected/person-case/state-machine.server.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type MachineContext = Partial<InPersonSinApplication> & Partial<{ formData: Form
3434
type MachineEvents =
3535
| { type: 'prev' }
3636
| { type: 'cancel' }
37+
| { type: 'exit' }
3738
| { type: 'setFormData'; data: FormData }
3839
| { type: 'submitBirthDetails'; data: BirthDetailsData }
3940
| { type: 'submitContactInfo'; data: ContactInformationData }
@@ -101,13 +102,12 @@ export const machine = setup({
101102
target: '.privacy-statement',
102103
actions: assign(initialContext),
103104
},
104-
setFormData: {
105-
actions: assign(({ context, event }) => ({
106-
formData: { ...context.formData, ...event.data },
107-
})),
105+
exit: {
106+
target: '.exited',
108107
},
109108
},
110109
states: {
110+
'exited': { type: 'final' },
111111
'privacy-statement': {
112112
meta: { route: 'routes/protected/person-case/privacy-statement.tsx' },
113113
on: {

0 commit comments

Comments
 (0)