diff --git a/src/stores/Reservation.js b/src/stores/Reservation.js index 6f4a851..2fb6999 100644 --- a/src/stores/Reservation.js +++ b/src/stores/Reservation.js @@ -80,21 +80,6 @@ class Reservation { }); } - // get confirmationList() { - // return computed(() => { - // return json.PlanChange.map((data, index) => { - // return { - // key: data.PCI_SN, - // PCI_Changetext: data.PCI_Changetext, - // PCI_SendDate: data.PCI_SendDate, - // ConfirmPerson: data.ConfirmPerson, - // PCI_ConfirmText: data.PCI_ConfirmText, - // PCI_ConfirmDate: data.PCI_ConfirmDate - // } - // }); - // }).get(); - // } - fetchCityList(reservationId) { const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetCityGuide') .append('VEI_SN', this.root.authStore.login.travelAgencyId) @@ -106,7 +91,7 @@ class Reservation { .then(json => { runInAction(() => { if (json.errcode == 0) { - this.cityList = json.Result.map((data, index) => { + this.cityList = (json?.Result ?? []).map((data, index) => { return { key: data.CII_SN, cityId: data.CII_SN, @@ -124,14 +109,15 @@ class Reservation { fetchGuideList() { const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetGuideList') - .append('VEI_SN', 628)//this.root.authStore.login.travelAgencyId) + .append('VEI_SN', this.root.authStore.login.travelAgencyId) .build(); return fetchJSON(fetchUrl) .then(json => { runInAction(() => { if (json.errcode == 0) { - this.guideList = json.Result.map((data, index) => { + console.info(json.Result); + this.guideList = (json?.Result ?? []).map((data, index) => { return { guideId: data.TGI_SN, guideName: data.TGI2_Name, diff --git a/src/views/reservation/Detail.jsx b/src/views/reservation/Detail.jsx index 67bf8dd..74d2e51 100644 --- a/src/views/reservation/Detail.jsx +++ b/src/views/reservation/Detail.jsx @@ -121,7 +121,7 @@ function Detail() { Reference Number: {reservationDetail.referenceNumber}; Arrival date: {reservationDetail.arrivalDate}; - + diff --git a/src/views/reservation/Newest.jsx b/src/views/reservation/Newest.jsx index 81dd2f6..926568d 100644 --- a/src/views/reservation/Newest.jsx +++ b/src/views/reservation/Newest.jsx @@ -1,5 +1,5 @@ -import { NavLink } from "react-router-dom"; -import { useState, useRef, useEffect } from 'react'; +import { NavLink, useLocation } from "react-router-dom"; +import { useState, useEffect } from 'react'; import { observer } from "mobx-react"; import { toJS } from "mobx"; import { Row, Col, Space, Button, Table, Input, Typography, DatePicker, Radio, Modal, App, Select } from 'antd'; @@ -73,7 +73,7 @@ function Newest() { allowClear placeholder="Select a guide" optionFilterProp="children" - defaultValue={city.tourGuideId} + defaultValue={guideSelectOptions.length == 0 ? null : city.tourGuideId} onChange={(guideId) => { reservationStore.setupCityGuide(city.cityId, guideId); }} @@ -88,8 +88,7 @@ function Newest() { ); } - // const href = useHref(); - // const isMountedRef = useRef(false); + const location = useLocation(); const { reservationStore } = useStore(); const { reservationList, reservationPage, referenceNo, arrivalDateRange, cityList, guideList } = reservationStore; const [isModalOpen, setIsModalOpen] = useState(false); @@ -106,10 +105,14 @@ function Newest() { } }); - useEffect(() => { - onSearchClick(); - console.info('Newest...'); - }, [123]); + useEffect (() => { + if (location.search !== '?back') { + onSearchClick(); + } + return () => { + console.info('unmount...'); + }; + }, []); const showCityGuideModal = (reservation) => { setDataLoading(true);