Skip to content

Commit 527638d

Browse files
author
Ruben van Leeuwen
committed
1830: Moves buttons to componment in footer
1 parent 29ffb3f commit 527638d

File tree

3 files changed

+64
-48
lines changed

3 files changed

+64
-48
lines changed

frontend/packages/pydantic-forms/src/components/form/Footer.tsx

Lines changed: 60 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,57 +24,77 @@ const Footer = () => {
2424

2525
const t = useTranslations('footer');
2626

27-
return (
28-
<div style={{ height: '200px' }}>
29-
{footerComponent && <div>{footerComponent}</div>}{' '}
30-
<div style={{ display: 'flex', gap: '16px' }}>
31-
{rhf.formState.isValid &&
32-
!allowUntouchedSubmit &&
33-
!rhf.formState.isDirty && (
34-
<div>Het formulier is nog niet aangepast</div>
35-
)}
27+
const PreviousButton = () => (
28+
<button
29+
type="button"
30+
onClick={() => onPrevious?.()}
31+
style={{ padding: '12px' }}
32+
>
33+
{t('previous')}
34+
</button>
35+
);
3636

37+
const ResetButton = () => {
38+
return (
39+
resetButtonAlternative ?? (
3740
<button
3841
type="button"
39-
onClick={() => onPrevious?.()}
42+
onClick={(e) => {
43+
resetForm(e);
44+
}}
4045
style={{ padding: '12px' }}
4146
>
42-
Back
47+
{t('reset')}
4348
</button>
44-
{resetButtonAlternative ?? (
45-
<button
46-
type="button"
47-
onClick={(e) => {
48-
resetForm(e);
49-
}}
50-
style={{ padding: '12px' }}
51-
>
52-
{t('reset')}
53-
</button>
54-
)}
55-
{!!onCancel &&
56-
(cancelButton ?? (
57-
<button
58-
type="button"
59-
onClick={onCancel}
60-
style={{ padding: '12px' }}
61-
>
62-
{t('cancel')}
63-
</button>
64-
))}
49+
)
50+
);
51+
};
6552

53+
const CancelButton = () => {
54+
return (
55+
cancelButton ?? (
6656
<button
67-
type="submit"
57+
type="button"
58+
onClick={onCancel}
6859
style={{ padding: '12px' }}
69-
disabled={
70-
!rhf.formState.isValid ||
71-
(!allowUntouchedSubmit &&
72-
!rhf.formState.isDirty &&
73-
!rhf.formState.isSubmitting)
74-
}
7560
>
76-
{sendLabel ?? t('send')}
61+
{t('cancel')}
7762
</button>
63+
)
64+
);
65+
};
66+
67+
const SubmitButton = () => (
68+
<button
69+
type="submit"
70+
style={{ padding: '12px' }}
71+
disabled={
72+
!rhf.formState.isValid ||
73+
(!allowUntouchedSubmit &&
74+
!rhf.formState.isDirty &&
75+
!rhf.formState.isSubmitting)
76+
}
77+
>
78+
{sendLabel ?? t('send')}
79+
</button>
80+
);
81+
82+
return (
83+
<div style={{ height: '200px' }}>
84+
{footerComponent && <div>{footerComponent}</div>}{' '}
85+
<div style={{ display: 'flex', gap: '16px' }}>
86+
{rhf.formState.isValid &&
87+
!allowUntouchedSubmit &&
88+
!rhf.formState.isDirty && (
89+
<div>Het formulier is nog niet aangepast</div>
90+
)}
91+
92+
<PreviousButton />
93+
<ResetButton />
94+
95+
{!!onCancel && <CancelButton />}
96+
97+
<SubmitButton />
7898
</div>
7999
<div
80100
style={{

frontend/packages/pydantic-forms/src/messages/en-GB.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"cancel": "Cancel",
44
"send": "Send",
55
"reset": "Reset",
6+
"previous": "Previous",
7+
"next": "Next",
68
"notModifiedYet": "The form has not been modified yet",
79
"notFilledYet": "The form has not been filled in yet"
810
},

frontend/packages/pydantic-forms/src/messages/nl-NL.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@
55
"reset": "Resetten",
66
"notModifiedYet": "Het formulier is nog niet aangepast",
77
"notFilledYet": "Het formulier is nog niet ingevuld",
8-
"yola": {
9-
"poweredBy": "Powered by"
10-
},
11-
"hola": {
12-
"dolla": {
13-
"poweredBy": "Powered by"
14-
}
15-
}
8+
"previous": "Vorige",
9+
"next": "Volgende"
1610
},
1711
"renderForm": {
1812
"loading": "Formulier wordt geladen...",

0 commit comments

Comments
 (0)