Package seat selection updates, round trip alternative trips updates

This commit is contained in:
Stephanos A
2026-07-07 15:17:25 +03:00
parent 30661a2699
commit f424ca9f58
5 changed files with 394 additions and 75 deletions

View File

@@ -64,7 +64,7 @@ export class SearchService {
const outbound = [...direct, ...transit];
if (outbound.length === 0) {
if (outbound.length === 0 && dto.journeyType !== 'ROUND_TRIP') {
const alternativesOutbound = await this.searchAlternatives(
dto.originStationId,
dto.destinationStationId,
@@ -74,7 +74,7 @@ export class SearchService {
dto.nationality,
);
return {
journeyType: dto.journeyType === 'ROUND_TRIP' ? 'ROUND_TRIP' : 'ONE_WAY',
journeyType: 'ONE_WAY',
outbound: [],
alternativeOutbound: alternativesOutbound,
requestedDate: dto.date,
@@ -110,19 +110,29 @@ export class SearchService {
new Date(s.departureAt ?? s.leg1?.departureAt).getTime() > latestOutboundArrival
);
if (inbound.length === 0) {
const alternativeInbound = await this.searchAlternatives(
dto.destinationStationId,
dto.originStationId,
dto.returnDate ?? dto.date,
dto.adultCount,
dto.childCount,
dto.nationality,
);
return { journeyType: 'ROUND_TRIP', outbound, inbound: [], alternativeInbound };
const returnDate = dto.returnDate ?? dto.date;
if (outbound.length === 0 || inbound.length === 0) {
const [alternativeOutbound, alternativeInbound] = await Promise.all([
outbound.length === 0
? this.searchAlternatives(dto.originStationId, dto.destinationStationId, dto.date, dto.adultCount, dto.childCount, dto.nationality)
: Promise.resolve([]),
inbound.length === 0
? this.searchAlternatives(dto.destinationStationId, dto.originStationId, returnDate, dto.adultCount, dto.childCount, dto.nationality)
: Promise.resolve([]),
]);
return {
journeyType: 'ROUND_TRIP',
outbound,
inbound,
alternativeOutbound,
alternativeInbound,
requestedDate: dto.date,
requestedReturnDate: returnDate,
};
}
return { journeyType: 'ROUND_TRIP', outbound, inbound };
return { journeyType: 'ROUND_TRIP', outbound, inbound, requestedDate: dto.date, requestedReturnDate: returnDate };
}
return { journeyType: 'ONE_WAY', outbound };

View File

@@ -90,6 +90,7 @@ export class SeatsService {
label: a.coach.number,
mode: a.coach.status,
name: `Coach ${a.coach.number}`,
coachTypeId: a.coach.coachType?.id ?? null,
coachTypeName,
isBedCoach,
bedCategory,
@@ -665,6 +666,7 @@ export class SeatsService {
return {
coachId: a.coach.id,
coachTypeId: a.coach.coachType?.id ?? null,
coachNumber: a.coach.number,
positionNumber: a.positionNumber,
coachTypeName: a.coach.coachType?.name ?? '',