Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning state to beneficiary validation #699

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 54 additions & 23 deletions clients/banking/src/components/TransferWizardBeneficiary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,28 @@ export const TransferWizardBeneficiary = ({
label={t("transfer.new.beneficiary.name")}
render={id => (
<Field name="name">
{({ value, onChange, onBlur, error, valid, ref }) => (
<LakeTextInput
id={id}
ref={ref}
value={value}
error={error}
valid={valid}
onChangeText={onChange}
onBlur={onBlur}
/>
)}
{({ value, onChange, onBlur, error, valid, ref }) => {
const shouldWarn = match(
beneficiaryVerification.mapOk(query => query.beneficiaryVerification),
)
.with(
AsyncData.P.Done(Result.P.Ok({ __typename: P.not("BeneficiaryMatch") })),
() => true,
)
.otherwise(() => false);
return (
<LakeTextInput
id={id}
ref={ref}
value={value}
error={error}
valid={!shouldWarn && valid}
onChangeText={onChange}
onBlur={onBlur}
warning={shouldWarn}
/>
);
}}
</Field>
)}
/>
Expand All @@ -310,18 +321,38 @@ export const TransferWizardBeneficiary = ({
label={t("transfer.new.iban.label")}
render={id => (
<Field name="iban">
{({ value, onChange, onBlur, error, valid, ref }) => (
<LakeTextInput
id={id}
ref={ref}
placeholder={t("transfer.new.iban.placeholder")}
value={printIbanFormat(value)}
error={error}
valid={valid}
onChangeText={onChange}
onBlur={onBlur}
/>
)}
{({ value, onChange, onBlur, error, valid, ref }) => {
const shouldWarn = match(
beneficiaryVerification.mapOk(query => query.beneficiaryVerification),
)
.with(
AsyncData.P.Done(
Result.P.Ok(
P.union(
{
__typename: "InvalidBeneficiaryVerification",
},
{ __typename: "BeneficiaryMismatch", accountStatus: "Inactive" },
),
),
),
() => true,
)
.otherwise(() => false);
return (
<LakeTextInput
id={id}
ref={ref}
placeholder={t("transfer.new.iban.placeholder")}
value={printIbanFormat(value)}
error={error}
valid={!shouldWarn && valid}
onChangeText={onChange}
onBlur={onBlur}
warning={shouldWarn}
/>
);
}}
</Field>
)}
/>
Expand Down
Loading