mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 00:38:11 +00:00
Package seat selection updates, round trip alternative trips updates
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user