Skip to content
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,7 +4,6 @@ import { ReasonForTransportFailure, TransportModeType } from '../../../types';
import { Line } from '../../..';
import { RefundFormEvents } from '../../events';
import { RefundContextProps } from '../../refundFormMachine';
import { Typo } from '@atb/components/typography';
import {
Fieldset,
Input,
Expand All @@ -31,26 +30,9 @@ export const RefundTaxiForm = ({ state, send }: RefundTaxiFormProps) => {
return (
<>
<Fieldset title={t(PageText.Contact.refund.refundTaxi.taxiReceipt.title)}>
<Typo.p textType="body__primary">
{t(PageText.Contact.refund.refundTaxi.taxiReceipt.info)}
</Typo.p>

<FileInput
id="attachments"
iconLabel={t(PageText.Contact.input.feedback.attachment.generic)}
name="attachments"
onChange={(files) => {
send({
type: 'ON_INPUT_CHANGE',
inputName: 'attachments',
value: files,
});
}}
errorMessage={t(state.context?.errorMessages['attachments']?.[0])}
/>
<Input
id="amount"
label={t(PageText.Contact.input.amount.label)}
label={t(PageText.Contact.input.amount.info)}
type="text"
name="amount"
value={state.context.amount || ''}
Expand All @@ -64,9 +46,26 @@ export const RefundTaxiForm = ({ state, send }: RefundTaxiFormProps) => {
})
}
/>
<Typo.p textType="body__primary">
{t(PageText.Contact.input.amount.info)}
</Typo.p>

<FileInput
id="attachments"
label={t(PageText.Contact.refund.refundTaxi.taxiReceipt.info)}
iconLabel={t(PageText.Contact.input.feedback.attachment.receipt)}
name="attachments"
isRequired
onChange={(files) => {
send({
type: 'ON_INPUT_CHANGE',
inputName: 'attachments',
value: files,
});
}}
errorMessage={
state.context?.errorMessages['attachments']?.[0]
? t(state.context?.errorMessages['attachments']?.[0])
: undefined
}
/>
</Fieldset>
<Fieldset
title={t(PageText.Contact.refund.refundTaxi.aboutYourTrip.title)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { PageText, useTranslation } from '@atb/translations';
import { RefundFormEvents } from '../../events';
import { Typo } from '@atb/components/typography';
import {
Fieldset,
FileInput,
Input,
Select,
Textarea,
FileInput,
Radio,
} from '../../../components';
import { RefundContextProps } from '../../refundFormMachine';
import { Checkbox } from '@atb/components/checkbox';
import { TicketType } from '@atb/page-modules/contact/types';
import { TicketType, TicketTypeId } from '@atb/page-modules/contact/types';

type OtherTicketRefundProps = {
state: { context: RefundContextProps };
Expand All @@ -22,6 +20,12 @@ type RefundSectionProps = Pick<OtherTicketRefundProps, 'state' | 'send'>;

const RefundSection = ({ state, send }: RefundSectionProps) => {
const { t } = useTranslation();
const ticketTypeOptions = PageText.Contact.input.ticketType.options.filter(
(option) =>
option.id == TicketTypeId.SingleTicket ||
option.id == TicketTypeId.PeriodTicket,
);

return (
<Fieldset
title={t(PageText.Contact.ticketing.refund.otherTicketRefund.label)}
Expand All @@ -41,43 +45,41 @@ const RefundSection = ({ state, send }: RefundSectionProps) => {
});
}}
placeholder={t(PageText.Contact.input.ticketType.optionLabelRefund)}
options={PageText.Contact.input.ticketType.options}
options={ticketTypeOptions}
isRequired
error={
state.context?.errorMessages['ticketType']?.[0]
? t(state.context?.errorMessages['ticketType'][0])
: undefined
}
/>
<div>
<Radio
label={t(PageText.Contact.input.travelCardNumber.labelRadioButton)}
name="showInputTravelCardNumber"
checked={state.context.showInputTravelCardNumber}
onChange={() =>
send({
type: 'ON_INPUT_CHANGE',
inputName: 'showInputTravelCardNumber',
value: !state.context.showInputTravelCardNumber,
})
}
/>

<Radio
label={t(PageText.Contact.input.customerNumber.label)}
name="isAppTicketStorageMode"
checked={!state.context.showInputTravelCardNumber}
onChange={() =>
send({
type: 'ON_INPUT_CHANGE',
inputName: 'showInputTravelCardNumber',
value: !state.context.showInputTravelCardNumber,
})
}
/>
</div>
<Input
id="orderId"
label={t(PageText.Contact.input.orderId.label(false))}
type="text"
name="orderId"
value={state.context.orderId || ''}
isRequired
errorMessage={state.context?.errorMessages['orderId']?.[0]}
onChange={(e) =>
send({
type: 'ON_INPUT_CHANGE',
inputName: 'orderId',
value: e.target.value,
})
}
modalContent={{
description: t(PageText.Contact.input.orderId.description),
instruction: t(PageText.Contact.input.orderId.instruction),
bulletPoints:
PageText.Contact.input.orderId.descriptionBulletPoints.map(
(bulletPoint) => t(bulletPoint),
),
}}
/>

{state.context.showInputTravelCardNumber && (
{state.context.ticketType?.id === TicketTypeId.PeriodTicket && (
<Input
id="travelCardNumber"
label={t(PageText.Contact.input.travelCardNumber.label)}
Expand All @@ -99,51 +101,21 @@ const RefundSection = ({ state, send }: RefundSectionProps) => {
/>
)}

{!state.context.showInputTravelCardNumber && (
<Input
id="customerNumber"
label={t(PageText.Contact.input.customerNumber.label)}
type="text"
name="customerNumber"
value={state.context.customerNumber || ''}
isRequired
errorMessage={state.context?.errorMessages['customerNumber']?.[0]}
onChange={(e) =>
send({
type: 'ON_INPUT_CHANGE',
inputName: 'customerNumber',
value: e.target.value,
})
}
modalContent={{
description: t(PageText.Contact.input.customerNumber.description),
}}
/>
)}

<Input
id="orderId"
label={t(PageText.Contact.input.orderId.label(false))}
id="amount"
label={t(PageText.Contact.input.amount.info)}
type="text"
name="orderId"
value={state.context.orderId || ''}
name="amount"
value={state.context.amount || ''}
isRequired
errorMessage={state.context?.errorMessages['orderId']?.[0]}
errorMessage={state.context?.errorMessages['amount']?.[0]}
onChange={(e) =>
send({
type: 'ON_INPUT_CHANGE',
inputName: 'orderId',
inputName: 'amount',
value: e.target.value,
})
}
modalContent={{
description: t(PageText.Contact.input.orderId.description),
instruction: t(PageText.Contact.input.orderId.instruction),
bulletPoints:
PageText.Contact.input.orderId.descriptionBulletPoints.map(
(bulletPoint) => t(bulletPoint),
),
}}
/>

<Textarea
Expand All @@ -164,38 +136,24 @@ const RefundSection = ({ state, send }: RefundSectionProps) => {
: undefined
}
/>

<Input
id="amount"
label={t(PageText.Contact.input.amount.label)}
type="text"
name="amount"
value={state.context.amount || ''}
isRequired
errorMessage={state.context?.errorMessages['amount']?.[0]}
onChange={(e) =>
send({
type: 'ON_INPUT_CHANGE',
inputName: 'amount',
value: e.target.value,
})
}
/>
<Typo.p textType="body__primary">
{t(PageText.Contact.input.amount.info)}
</Typo.p>

<FileInput
id="attachments"
name="attachments"
label={t(PageText.Contact.refund.refundTaxi.taxiReceipt.info)}
iconLabel={t(PageText.Contact.input.feedback.attachment.receipt)}
name="attachments"
isRequired
onChange={(files) => {
send({
type: 'ON_INPUT_CHANGE',
inputName: 'attachments',
value: files,
});
}}
errorMessage={
state.context?.errorMessages['attachments']?.[0]
? t(state.context?.errorMessages['attachments']?.[0])
: undefined
}
/>
</Fieldset>
);
Expand Down
7 changes: 3 additions & 4 deletions src/page-modules/contact/refund/refundFormMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
TransportModeType,
ReasonForTransportFailure,
TicketType,
TicketTypeId,
} from '../types';
import { assign, fromPromise, setup } from 'xstate';
import { Line } from '../server/journey-planner/validators';
Expand Down Expand Up @@ -106,7 +107,6 @@ export type RefundContextProps = {

isInitialAgreementChecked: boolean;
hasInternationalBankAccount: boolean;
showInputTravelCardNumber: boolean;
errorMessages: InputErrorMessages;
firstIncorrectErrorMessage?: string;
};
Expand Down Expand Up @@ -165,7 +165,6 @@ const setInputToValidate = (context: RefundContextProps) => {
travelCardNumber,
refundReason,
purchasePlatform,
showInputTravelCardNumber,
} = context;

const commonFields = {
Expand Down Expand Up @@ -226,7 +225,8 @@ const setInputToValidate = (context: RefundContextProps) => {
email,
phoneNumber,
orderId,
...(showInputTravelCardNumber
attachments,
...(ticketType && ticketType.id === TicketTypeId.PeriodTicket
? { travelCardNumber }
: { customerNumber }),
...(hasInternationalBankAccount
Expand Down Expand Up @@ -386,7 +386,6 @@ export const refundStateMachine = setup({
context: {
isInitialAgreementChecked: false,
hasInternationalBankAccount: false,
showInputTravelCardNumber: true,
errorMessages: {},
},
on: {
Expand Down
13 changes: 12 additions & 1 deletion src/page-modules/contact/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ import { TranslatedString } from '@atb/translations';

export type TransportModeType = 'bus' | 'expressboat' | 'ferry';
export type ReasonForTransportFailure = { id: string; name: TranslatedString };
export type TicketType = { id: string; name: TranslatedString };
export enum TicketTypeId {
SingleTicket = 'singleTicket',
PeriodTicket = 'periodTicket',
FramYoung = 'framYoung',
FramStudent = 'framStudent',
FramAdult = 'framAdult',
FramSenior = 'framSenior',
}
export type TicketType = {
id: TicketTypeId;
name: TranslatedString;
};
export type PurchasePlatformType =
| 'framApp'
| 'enturApp'
Expand Down
16 changes: 8 additions & 8 deletions src/translations/pages/contact.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
ReasonForTransportFailure,
TicketType,
TicketTypeId,
} from '@atb/page-modules/contact/types';
import { translation as _ } from '@atb/translations/commons';
import { orgSpecificTranslations } from '../utils';
Expand Down Expand Up @@ -1454,34 +1454,34 @@ const ContactInternal = {
),
options: [
{
id: 'singleTicket',
id: TicketTypeId.SingleTicket,
name: _('Enkeltbillett', 'Single ticket', 'Enkeltbillett'),
},
{
id: 'periodTicket',
id: TicketTypeId.PeriodTicket,
name: _(
'Periodebillett (sonebasert)',
'Period ticket (zone-based)',
'Periodebillett (sonebasert)',
),
},
{
id: 'framYoung',
id: TicketTypeId.FramYoung,
name: _('FRAM Ung', 'FRAM Ung', 'FRAM Ung'),
},
{
id: 'framStudent',
id: TicketTypeId.FramStudent,
name: _('FRAM Student', 'FRAM Student', 'FRAM Student'),
},
{
id: 'framAdult',
id: TicketTypeId.FramAdult,
name: _('FRAM Vaksen', 'FRAM Vaksen', 'FRAM Vaksen'),
},
{
id: 'framSenior',
id: TicketTypeId.FramSenior,
name: _('FRAM Honnør', 'FRAM Honnør', 'FRAM Honnør'),
},
] as TicketType[],
],
errorMessages: {
empty: _(
'Billett for refusjon mangler',
Expand Down