You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GHHub/src/stores/Reservation.js

113 lines
3.7 KiB
JavaScript

import { makeAutoObservable, runInAction } from "mobx";
import { fetchJSON } from '@/utils/request';
import { HT_HOST } from "@/config";
import { prepareUrl } from '@/utils/commons';
class Reservation {
constructor(root) {
makeAutoObservable(this, { rootStore: false });
this.root = root;
}
fetchReservationList(referenceNo, fromDate, thruDate) {
const fetchUrl = prepareUrl(HT_HOST + '/service-tourdesign/GetPlanSearchList')
.append('VEI_SN', this.root.authStore.login.travelAgencyId)
.append('GroupNo', referenceNo)
.append('DateStart', fromDate)
.append('DateEnd', thruDate)
.append('ReTotal', 0)
.append('PageSize', 0)
.append('PageNum', 0)
.append('PageIndex', 1)
.build();
return fetchJSON(fetchUrl)
.then(json => {
runInAction(() => {
if (json.errcode == 0) {
this.reservationList = json.Result.map((data, index) => {
return {
key: data.vas_gri_sn,
id: data.vas_gri_sn,
referenceNumber: data.GriName,
arrivalDate: data.GetGDate,
pax: data.PersonNum,
status: data.GState,
reservationDate: data.GetGDate,
guide: data.Guide,
}
});
} else {
throw new Error(json.errmsg + ': ' + json.errcode);
}
});
});
}
fetchReservation(reservationId) {
const fetchUrl = prepareUrl(HT_HOST + '/service-tourdesign/GetPlanInfo')
.append('VEI_SN', this.root.authStore.login.travelAgencyId)
.append('GRI_SN', reservationId)
.build();
return fetchJSON(fetchUrl)
.then(json => {
runInAction(() => {
if (json.errcode == 0) {
this.itineraryList = json.VendorTour.map((data, index) => {
return {
key: data.GRD_GRI_SN,
day: data.GRD_OrderDate,
placeTransport: data.GRD_Traffic,
todayActivities: data.GRD_LandscapeWL,
accommodation: data.GRD_Hotel,
meals: data.GRD_Meal_L + data.GRD_Meal_S,
}
});
this.reservationDetail = {
referenceNumber: json.PlanDetail[0].GRI_Name, tourGuide: json.Guide[0].TGI2_Name, arrivalDate: json.PlanDetail[0].eoi_getdate
};
this.customerNames = json.CusAndRequest[0].GCI_CustomerList;
} else {
throw new Error(json.errmsg + ': ' + json.errcode);
}
});
});
}
reservationList = [];
reservationDetail = {
referenceNumber: '', arrivalDate: '', tourGuide: ''
};
itineraryList = [
];
customerList = [
{
title: 'Crane / Gemma Chelse',
description: 'Gender: Male Nationality: United States Passport: 655844449 Expiration Date: 2030-09-07 Birth Date: 1979-12-23',
},
{
title: 'McCracken / Ryan Lee',
description: 'Gender: Female Nationality: United States Passport: 655844450 Expiration Date: 2030-09-07 Birth Date: 1983-05-17',
},
{
title: 'Ramlakhan / Darryl',
description: 'Gender: Female Nationality: United States Passport: 661810034 Expiration Date: 2026-03-16 Birth Date: 2006-07-12',
},
{
title: 'Ramlakhan / Reanne',
description: 'Gender: Male Nationality: United States Passport: 593422145 Expiration Date: 2023-04-25 Birth Date: 2012-03-26',
},
{
title: 'Alexander Daich',
description: 'Gender: Male Nationality: United States Passport: 593422145 Expiration Date: 2023-04-25 Birth Date: 2012-03-26s',
},
];
customerNames = '';
}
export default Reservation;