Skip to content

Commit

Permalink
chore: rewrite ticket control to use one state machine for all forms (#…
Browse files Browse the repository at this point in the history
…353)

* Rewrite to use only one state machine for all ticket control forms

* Add temporary success message.

* Specifies which inputs that should be validated when submitting a form from tricketControll

* Update validation for travelGuarantee.
  • Loading branch information
jonasbrunvoll authored Sep 25, 2024
1 parent e008754 commit 39628a5
Show file tree
Hide file tree
Showing 23 changed files with 540 additions and 753 deletions.
11 changes: 2 additions & 9 deletions src/page-modules/contact/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
export {
ContactPageLayout,
type ContactPageLayoutProps,
TicketControlPageLayout,
type TicketControlPageLayoutProps,
} from './layouts';
export { ContactPageLayout, type ContactPageLayoutProps } from './layouts';

export { PostponePaymentForm } from './ticket-control';
export { RefundForm } from './travel-guarantee';
export { FeeComplaintForm } from './ticket-control/complaint';
export { type Line } from './server/journey-planner/validators';
export { shouldShowContactPage } from './utils';
export { FeedbackForm } from './ticket-control/feedback';
export { MeansOfTransportContent } from './means-of-transport';
export { default as TicketControlPageContent } from './ticket-control';
5 changes: 0 additions & 5 deletions src/page-modules/contact/layouts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@ export {
default as ContactPageLayout,
type ContactPageLayoutProps,
} from './contact-page-layout';

export {
default as TicketControlPageLayout,
type TicketControlPageLayoutProps,
} from './ticket-control-page-layout';
63 changes: 0 additions & 63 deletions src/page-modules/contact/layouts/ticket-control-page-layout.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export const meansOfTransportFormMachine = setup({
events: meansOfTransportFormEvents,
},
guards: {
validateInputs: ({ context }) => commonInputValidator(context),
validateInputs: ({ context }) => {
context.errorMessages = commonInputValidator(context);
return Object.keys(context.errorMessages).length > 0 ? false : true;
},
},
actions: {
onInputChange: assign(({ context, event }) => {
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions src/page-modules/contact/ticket-control/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { commonEvents } from '../commoneEvents';
const ticketControlSpecificFormEvents = {} as {
type: 'ON_INPUT_CHANGE';
inputName:
| 'formType'
| 'feeNumber'
| 'invoiceNumber'
| 'appPhoneNumber'
Expand Down
Loading

0 comments on commit 39628a5

Please sign in to comment.