Add src/client/journey_helper.ts
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
93d40d8d29
commit
9fc2dc6a6a
41
src/client/journey_helper.ts
Normal file
41
src/client/journey_helper.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import journey_wrapper from './types/wrapper';
|
||||
|
||||
/* LIST HELPERS */
|
||||
export const filter_selected = function (journey: journey_wrapper, list: geoloc[], step: boolean) {
|
||||
return list.filter((e) =>
|
||||
step ? e.step == journey.sel_day : e.step >= 0,
|
||||
);
|
||||
}
|
||||
|
||||
export const filter_unselected = function (list: geoloc[]) {
|
||||
return list.filter((e) => e.step == undefined || e.step < 0);
|
||||
}
|
||||
|
||||
export const remove_item = function (list: geoloc[], idx: number) {
|
||||
list[idx].step = -1;
|
||||
list.splice(idx, 1);
|
||||
}
|
||||
|
||||
|
||||
/* JOURNEY ADD/RM ITEM HELPER */
|
||||
export const journey_add_place = function (journey: journey_wrapper, tpe: String, item: geoloc) {
|
||||
switch (tpe) {
|
||||
case 'hotel': return journey.leg_get().hotel = item;
|
||||
case 'restaurant': return journey.leg_get().places.restaurants.push(item);
|
||||
case 'place': return journey.leg_get().places.activities.push(item);
|
||||
case 'other': return;
|
||||
case 'flight': return journey.leg_get().travel.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
export const journey_del_place = function (journey: journey_wrapper, tpe: String, idx: number) {
|
||||
console.log(tpe)
|
||||
switch (tpe) {
|
||||
case "hotel": return journey.leg_get().hotel = null;
|
||||
case "restaurants": return journey.leg_get().places.restaurants.splice(idx, 1);
|
||||
case "activities": return journey.leg_get().places.activities.splice(idx, 1);
|
||||
case "other": return;
|
||||
case "flight": return journey.leg_get().travel.splice(idx, 1);
|
||||
default: return true;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user