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

feat: add note informing users about having to buy external ticket #294

Merged
merged 3 commits into from
May 14, 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
14 changes: 14 additions & 0 deletions src/page-modules/assistant/details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { getInterchangeDetails } from './trip-section/interchange-section';
import { getLegWaitDetails } from './trip-section/wait-section';
import { useRouter } from 'next/router';
import { tripQueryStringToQueryParams } from './utils';
import { MessageBox } from '@atb/components/message-box';
import { getBookingStatus } from '@atb/modules/flexible/utils';

export type AssistantDetailsProps = {
tripPattern: TripPatternWithDetails;
Expand All @@ -35,6 +37,12 @@ export function AssistantDetails({ tripPattern }: AssistantDetailsProps) {
tripSearchParams.append('filter', router.query.filter as string);
}

const requireTicketBooking = tripPattern.legs.some(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the same done in the app to know if booking is required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the app, there is a function to check whether a leg in the trip requires a ticket that can not be must be bought through the app. https://github.com/AtB-AS/mittatb-app/blob/eb680679c754e8e56848ffe7983779c0794468ba/src/travel-details-screens/components/Trip.tsx#L106-L109.

The solution I used in this PR is pretty much the same approach to determine whether the BookingSection should appear.

const bookingStatus = getBookingStatus(
leg.bookingArrangements,
leg.aimedStartTime,
7,
);

(leg) =>
getBookingStatus(leg.bookingArrangements, leg.aimedStartTime, 7) !==
'none',
);

return (
<div className={style.container}>
<div className={style.headerContainer}>
Expand Down Expand Up @@ -72,6 +80,12 @@ export function AssistantDetails({ tripPattern }: AssistantDetailsProps) {
</div>
</div>
<div className={style.tripContainer}>
{requireTicketBooking && (
<MessageBox
type="info"
message={t(PageText.Assistant.details.ticketBooking.globalMessage)}
/>
)}
{tripPattern.legs.map((leg, index) => (
<TripSection
key={index}
Expand Down
25 changes: 25 additions & 0 deletions src/translations/pages/assistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ const AssistantInternal = {
),
},
},
ticketBooking: {
globalMessage: _(
'Reisen krever billett som ikke er tilgjengelig i denne appen, eller som må kjøpes fra et annet selskap enn AtB.',
'This journey requires a ticket that is not available from this app, or must be purchased from a provider other than AtB.',
'Reisa krev billett som ikkje er tilgjengeleg i denne appen, eller som må kjøpast frå eit anna selskap enn AtB.',
),
},
},
};

Expand All @@ -472,6 +479,15 @@ export const Assistant = orgSpecificTranslations(AssistantInternal, {
),
},
},
details: {
ticketBooking: {
globalMessage: _(
'Reisen krever billett som ikke er tilgjengelig i denne appen, eller som må kjøpes fra et annet selskap enn Reis Nordland.',
'This journey requires a ticket that is not available from this app, or must be purchased from a provider other than Nordland.',
'Reisa krev billett som ikkje er tilgjengeleg i denne appen, eller som må kjøpast frå eit anna selskap enn Reis Nordland.',
),
},
},
},
fram: {
search: {
Expand All @@ -489,5 +505,14 @@ export const Assistant = orgSpecificTranslations(AssistantInternal, {
),
},
},
details: {
ticketBooking: {
globalMessage: _(
'Reisen krever billett som ikke er tilgjengelig i denne appen, eller som må kjøpes fra et annet selskap enn FRAM.',
'This journey requires a ticket that is not available from this app, or must be purchased from a provider other than FRAM.',
'Reisa krev billett som ikkje er tilgjengeleg i denne appen, eller som må kjøpast frå eit anna selskap enn FRAM.',
),
},
},
},
});
Loading