112 lines
2.5 KiB
TypeScript
112 lines
2.5 KiB
TypeScript
import { CreateAdProps, Frequency } from '@modules/ad/core/domain/ad.types';
|
|
import { PointProps } from '@modules/ad/core/domain/value-objects/point.value-object';
|
|
import { ScheduleItemProps } from '@modules/ad/core/domain/value-objects/schedule-item.value-object';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
export const Nice: PointProps = {
|
|
lat: 43.7102,
|
|
lon: 7.262,
|
|
};
|
|
|
|
export const Marseille: PointProps = {
|
|
lat: 43.2965,
|
|
lon: 5.3698,
|
|
};
|
|
|
|
export const SaintRaphael: PointProps = {
|
|
lat: 43.4268,
|
|
lon: 6.769,
|
|
};
|
|
|
|
export const Toulon: PointProps = {
|
|
lat: 43.1167,
|
|
lon: 5.95,
|
|
};
|
|
|
|
export function monday(time: string): ScheduleItemProps {
|
|
return { day: 1, time: time, margin: 900 };
|
|
}
|
|
|
|
export function wednesday(time: string): ScheduleItemProps {
|
|
return { day: 3, time: time, margin: 900 };
|
|
}
|
|
export function thursday(time: string): ScheduleItemProps {
|
|
return { day: 4, time: time, margin: 900 };
|
|
}
|
|
|
|
export function weekdays(time: string): ScheduleItemProps[] {
|
|
return [1, 2, 3, 4, 5].map<ScheduleItemProps>((day) => ({
|
|
day: day,
|
|
time: time,
|
|
margin: 900,
|
|
}));
|
|
}
|
|
|
|
function createAdPropsDefaults(): CreateAdProps {
|
|
return {
|
|
id: uuidv4(),
|
|
driver: false,
|
|
passenger: false,
|
|
frequency: Frequency.PUNCTUAL,
|
|
fromDate: '',
|
|
toDate: '',
|
|
schedule: [],
|
|
seatsProposed: 1,
|
|
seatsRequested: 1,
|
|
strict: false,
|
|
pause: false,
|
|
waypoints: [],
|
|
points: [],
|
|
driverDuration: 0,
|
|
driverDistance: 0,
|
|
passengerDuration: 0,
|
|
passengerDistance: 0,
|
|
fwdAzimuth: 0,
|
|
backAzimuth: 0,
|
|
};
|
|
}
|
|
|
|
export function driverNiceMarseille(
|
|
frequency: Frequency,
|
|
dates: string[],
|
|
schedule: ScheduleItemProps[],
|
|
): CreateAdProps {
|
|
return {
|
|
...createAdPropsDefaults(),
|
|
driver: true,
|
|
frequency: frequency,
|
|
fromDate: dates[0],
|
|
toDate: dates[1],
|
|
schedule: schedule,
|
|
waypoints: [Nice, Marseille],
|
|
points: [Nice, SaintRaphael, Toulon, Marseille],
|
|
driverDuration: 7668,
|
|
driverDistance: 199000,
|
|
passengerDuration: 7668,
|
|
passengerDistance: 199000,
|
|
fwdAzimuth: 273,
|
|
backAzimuth: 93,
|
|
};
|
|
}
|
|
|
|
export function passengerToulonMarseille(
|
|
frequency: Frequency,
|
|
dates: string[],
|
|
schedule: ScheduleItemProps[],
|
|
): CreateAdProps {
|
|
return {
|
|
...createAdPropsDefaults(),
|
|
passenger: true,
|
|
frequency: frequency,
|
|
fromDate: dates[0],
|
|
toDate: dates[1],
|
|
schedule: schedule,
|
|
waypoints: [Toulon, Marseille],
|
|
points: [Toulon, Marseille],
|
|
driverDuration: 2460,
|
|
driverDistance: 64000,
|
|
passengerDuration: 2460,
|
|
passengerDistance: 64000,
|
|
};
|
|
}
|