Skip to content

Commit

Permalink
simplification of iban checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamGrik committed Apr 26, 2024
1 parent 6e0a6ff commit 26e7e44
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 46 deletions.
5 changes: 3 additions & 2 deletions src/lib/calculation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,10 @@ export function calculate(input: TaxFormUserInput): TaxForm {
},

/** SECTION Danovy bonus */
ziadamVyplatitDanovyBonus: input?.ziadamVyplatitDanovyBonus ?? false,

ziadamVyplatitDanovyBonus: input?.ziadamVratitDanovyPreplatok ?? false,
ziadamVratitDanovyPreplatok: input?.ziadamVratitDanovyPreplatok ?? false,
ziadamVratitDanovyBonusUroky: input?.ziadamVratitDanovyBonusUroky ?? false,
ziadamVratitDanovyBonusUroky: input?.ziadamVratitDanovyPreplatok ?? false,
iban: input?.iban ? input?.iban.replace(/\s/g, '') : '',

datum: input.datum,
Expand Down
61 changes: 17 additions & 44 deletions src/pages/iban.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,17 @@ const Iban: Page<TaxBonusUserInput> = ({
<BackLink href={previousRoute} />
<Form className="form" noValidate>
<ErrorSummary<TaxBonusUserInput> errors={errors} />

{taxForm.mozeZiadatVyplatitDanovyBonus && (
<BooleanRadio
name="ziadamVyplatitDanovyBonus"
title="Žiadam o vyplatenie daňového bonusu alebo rozdielu daňového bonusu"
/>
)}

{taxForm.mozeZiadatVratitDanovyPreplatok && (
<BooleanRadio
name="ziadamVratitDanovyPreplatok"
title="Žiadam o vrátenie daňového preplatku"
/>
)}

{taxForm.mozeZiadatVratitDanovyBonusUroky && (
<BooleanRadio
name="ziadamVratitDanovyBonusUroky"
title="Žiadam o vyplatenie daňového bonusu na zaplatené úroky"
/>
)}

{(values.ziadamVyplatitDanovyBonus ||
values.ziadamVratitDanovyPreplatok ||
values.ziadamVratitDanovyBonusUroky) && (
<Input
{(
values.ziadamVratitDanovyPreplatok) && (
<>
<div className='govuk-label govuk-!-margin-bottom-3'>Daňový preplatok je vo výške:
<span className='govuk-label govuk-!-font-weight-bold'>{taxForm.r136_danovy_preplatok.toNumber()}</span>
</div>
<Input
name="iban"
type="text"
label="IBAN"
Expand All @@ -107,12 +92,12 @@ const Iban: Page<TaxBonusUserInput> = ({
)
setFieldValue('iban', iban)
}}
/>
/>
</>
)}

<button data-test="next" className="govuk-button" type="submit">
Pokračovať
</button>
<button data-test="next" className="govuk-button" type="submit">
Pokračovať
</button>
</Form>
</>
)}
Expand All @@ -126,13 +111,7 @@ export const makeValidate =
(taxForm: TaxForm) => (values: TaxBonusUserInput) => {
const errors: Partial<FormErrors<TaxBonusUserInput>> = {}

if (
taxForm.mozeZiadatVyplatitDanovyBonus &&
typeof values.ziadamVyplatitDanovyBonus === 'undefined'
) {
errors.ziadamVyplatitDanovyBonus = 'Vyznačte odpoveď na daňový bonus'
}


if (
taxForm.mozeZiadatVratitDanovyPreplatok &&
typeof values.ziadamVratitDanovyPreplatok === 'undefined'
Expand All @@ -141,18 +120,12 @@ export const makeValidate =
'Vyznačte odpoveď na daňový preplatok'
}

if (
taxForm.mozeZiadatVratitDanovyBonusUroky &&
typeof values.ziadamVratitDanovyBonusUroky === 'undefined'
) {
errors.ziadamVratitDanovyBonusUroky =
'Vyznačte odpoveď na daňový bonus'
}


if (
values.ziadamVyplatitDanovyBonus ||
values.ziadamVratitDanovyPreplatok ||
values.ziadamVratitDanovyBonusUroky

values.ziadamVratitDanovyPreplatok

) {
if (!values.iban || values.iban === '') {
// Medzinárodné bankové číslo účtu (angl. International Bank Account Number, skr. IBAN)
Expand Down

0 comments on commit 26e7e44

Please sign in to comment.