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

fix: set bank account information to undefined when toggling between bank information input fields #427

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
convertFilesToBase64,
getCurrentDateString,
getCurrentTimeString,
setBankAccountStatusAndResetBankInformation,
setLineAndResetStops,
setTransportModeAndResetLineAndStops,
} from '../utils';
Expand Down Expand Up @@ -220,6 +221,13 @@ export const ticketControlFormMachine = setup({
if (inputName === 'agreesFirstAgreement' && !value)
return disagreeAgreements(context);

if (inputName === 'hasInternationalBankAccount') {
return setBankAccountStatusAndResetBankInformation(
context,
value as boolean,
);
}

context.errorMessages[inputName] = [];
return {
...context,
Expand Down
12 changes: 11 additions & 1 deletion src/page-modules/contact/ticketing/ticketingStateMachine.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { assign, fromPromise, setup } from 'xstate';
import { ticketingFormEvents, TicketType } from './events';
import { commonInputValidator, InputErrorMessages } from '../validation';
import { convertFilesToBase64 } from '../utils';
import {
convertFilesToBase64,
setBankAccountStatusAndResetBankInformation,
} from '../utils';

export enum FormCategory {
PriceAndTicketTypes = 'priceAndTicketTypes',
Expand Down Expand Up @@ -259,6 +262,13 @@ export const ticketingStateMachine = setup({
};
}

if (inputName === 'hasInternationalBankAccount') {
return setBankAccountStatusAndResetBankInformation(
context,
value as boolean,
);
}

return {
...context,
[inputName]: value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
convertFilesToBase64,
getCurrentDateString,
getCurrentTimeString,
setBankAccountStatusAndResetBankInformation,
setLineAndResetStops,
setTransportModeAndResetLineAndStops,
} from '../utils';
Expand Down Expand Up @@ -190,6 +191,13 @@ export const fetchMachine = setup({
if (inputName === 'isIntialAgreementChecked')
return setInitialAgreementAndFormType(context, value);

if (inputName === 'hasInternationalBankAccount') {
return setBankAccountStatusAndResetBankInformation(
context,
value as boolean,
);
}

context.errorMessages[inputName] = [];
return {
...context,
Expand Down
13 changes: 13 additions & 0 deletions src/page-modules/contact/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,16 @@ export const setLineAndResetStops = (context: any, line: Line | undefined) => {
},
};
};

export const setBankAccountStatusAndResetBankInformation = (
context: any,
hasInternationalBankAccount: boolean,
) => {
return {
...context,
hasInternationalBankAccount: hasInternationalBankAccount,
bankAccountNumber: undefined,
IBAN: undefined,
SWIFT: undefined,
};
};
Loading