Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 4x 20x 4x 4x 4x 4x 4x 4x 4x 16x 4x 4x 16x 4x 4x 4x 4x 4x | import _routeData from '../../configs/routes';
import { RouteInfo } from 'types';
import { TFunction } from 'i18next';
const routeData = _routeData.filter((item: RouteInfo) => {
if (
item.isSeasonTrip &&
!!item.seasonStartDay &&
!!item.seasonStartMonth &&
!!item.seasonFinishDay &&
!!item.seasonFinishMonth
) {
let now: Date | number = new Date();
const currentYear = now.getFullYear();
now.setHours(0, 0, 0);
now = now.getTime();
const seasonVisibleStart = new Date(
currentYear,
item.seasonStartMonth - 2,
item.seasonStartDay
).getTime();
const seasonVisibleEnd = new Date(
currentYear,
item.seasonFinishMonth - 1,
item.seasonFinishDay + 1
).getTime();
return now >= seasonVisibleStart && now <= seasonVisibleEnd;
} else return true;
});
export const guests = [
{ value: '0', name: '0' },
{ value: '1', name: '1' },
{ value: '2', name: '2' },
{ value: '3', name: '3' },
{ value: '4', name: '4' },
{ value: '5', name: '5' },
{ value: '6', name: '6' },
{ value: '7', name: '7' },
{ value: '8', name: '8' },
{ value: '9', name: '9' },
{ value: '10', name: '10' }
];
export const routes = routeData.map((item: RouteInfo) => {
return {
value: item.id.toString(),
name: item.name
};
});
export const getPassengersLabel = (
adults: number,
children: number,
babies: number,
dogs: number,
withVehicle: boolean,
t: TFunction
) => {
const adultsStr =
adults > 0
? `${adults} ${t('cart.adult', {
...(withVehicle ? { context: 'vehicle' } : { count: adults })
})}`
: null;
const childrenStr =
children > 0 ? `${children} ${t('cart.child', { count: children })}` : null;
const babiesStr =
babies > 0 ? `${babies} ${t('cart.baby', { count: babies })}` : null;
const dogsStr = dogs > 0 ? `${dogs} ${t('cart.dog', { count: dogs })}` : null;
return [adultsStr, childrenStr, babiesStr, dogsStr]
.filter((item: string | null) => !!item)
.join(', ');
};
export const getReturnRoutes = (route: RouteInfo | null) => {
if (!route || route.excursion) return [];
const filtered = routeData.filter(
item =>
item.portTo !== route.portTo &&
item.portFrom !== route.portFrom &&
!item.excursion
);
return filtered.map(item => {
return {
value: item.id.toString(),
name: item.name
};
});
};
export const getRoute = (routeId: number) => {
const filtered = routeData.filter(item => item.id === routeId);
if (filtered.length > 0) return filtered[0];
else return null;
};
export const getMinDateValue = (route: RouteInfo | null) => {
if (!route || !route.isSeasonTrip) return null;
else if (!route.seasonStartDay || !route.seasonStartMonth) return null;
else {
return new Date(
new Date().getFullYear(),
route.seasonStartMonth - 1,
route.seasonStartDay
);
}
};
export const getMaxDateValue = (route: RouteInfo | null) => {
if (!route || !route.isSeasonTrip) return null;
else if (!route.seasonFinishDay || !route.seasonFinishMonth) return null;
else {
return new Date(
new Date().getFullYear(),
route.seasonFinishMonth - 1,
route.seasonFinishDay
);
}
};
|