Fix car link: use airport coords and IATA instead of factory location
This commit is contained in:
23
server.js
23
server.js
@@ -305,16 +305,17 @@ function generateHotelLink({ cityName, checkin, checkout, adults, refundableOnly
|
||||
return url;
|
||||
}
|
||||
|
||||
function generateCarLink({ cityName, iataCode, pickupDate, dropoffDate, lat, lng }) {
|
||||
function generateCarLink({ cityName, iataCode, pickupDate, dropoffDate, lat, lng, airportName }) {
|
||||
const pu = new Date(pickupDate);
|
||||
const doDate = new Date(dropoffDate);
|
||||
const displayName = airportName || (iataCode ? `Flughafen ${iataCode}` : cityName);
|
||||
const params = new URLSearchParams({
|
||||
preflang: 'de',
|
||||
prefcurrency: 'EUR',
|
||||
driversAge: '30',
|
||||
locationName: iataCode ? `Flughafen ${cityName}` : cityName,
|
||||
locationName: displayName,
|
||||
locationIata: iataCode || '',
|
||||
dropLocationName: iataCode ? `Flughafen ${cityName}` : cityName,
|
||||
dropLocationName: displayName,
|
||||
dropLocationIata: iataCode || '',
|
||||
puDay: pu.getUTCDate(),
|
||||
puMonth: pu.getUTCMonth() + 1,
|
||||
@@ -438,10 +439,24 @@ app.post('/api/search', async (req, res) => {
|
||||
const hotelLink = generateHotelLink({
|
||||
cityName: destinationCity, checkin, checkout, adults, refundableOnly,
|
||||
});
|
||||
|
||||
// Flughafen-Koordinaten für Mietwagen (Abholung am Flughafen, nicht an der Fabrik)
|
||||
let airportCoords = null;
|
||||
let airportName = null;
|
||||
if (destIATA) {
|
||||
try {
|
||||
const r = await geocodeAddress(`${destIATA} airport`);
|
||||
airportCoords = r;
|
||||
airportName = `Flughafen ${destIATA}`;
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
const carLink = generateCarLink({
|
||||
cityName: destinationCity, iataCode: destIATA,
|
||||
pickupDate: checkin, dropoffDate: checkout,
|
||||
lat: destCoords?.lat, lng: destCoords?.lng,
|
||||
lat: airportCoords?.lat ?? destCoords?.lat,
|
||||
lng: airportCoords?.lng ?? destCoords?.lng,
|
||||
airportName,
|
||||
});
|
||||
|
||||
res.json({
|
||||
|
||||
Reference in New Issue
Block a user