| | |
| | | import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators' |
| | | |
| | | import { ClientInfo, getMyAppointmentList, getMyReviewLog } from '~/assets/ts/api/appointment'; |
| | | import { getMyReviewLog } from '~/assets/ts/api/appointment'; |
| | | import { recommend, AgentOfStrictQuery, addFavoriteConsultant, deleteConsultant, strictQuery } from '~/assets/ts/api/consultant'; |
| | | import { getFavoriteFromStorage, setFavoriteToStorage } from '~/assets/ts/storageConsultant'; |
| | | |
| | | import myConsultantService from '~/assets/ts/services/my-consultant.service'; |
| | | import myConsultantService from '~/assets/ts/services/my-consultant.service'; |
| | | import appointmentService from '~/assets/ts/services/appointment.service'; |
| | | |
| | | import { Consultant } from '~/assets/ts/models/consultant.model'; |
| | | import { AppointmentLog } from '~/assets/ts/models/appointment.model'; |
| | | import { ClientInfo } from '~/assets/ts/models/client.model'; |
| | | @Module |
| | | export default class Store extends VuexModule { |
| | | recommendList: Consultant[] = []; |
| | |
| | | myConsultantList: Consultant[] = []; |
| | | |
| | | myAppointmentList: ClientInfo[] = []; |
| | | myNewAppointmentSum: number = 0; |
| | | |
| | | myAppointmentReviewLogList: AppointmentLog[] = []; |
| | | |
| | |
| | | return this.context.getters['localStorage/isUserLogin']; |
| | | } |
| | | |
| | | @Mutation updateRecommend(data: Consultant[]) { |
| | | @Mutation |
| | | updateRecommend(data: Consultant[]) { |
| | | this.recommendList = data; |
| | | } |
| | | |
| | | @Mutation updateConsultantList(data: Consultant[]) { |
| | | @Mutation |
| | | updateConsultantList(data: Consultant[]) { |
| | | this.myConsultantList = data; |
| | | } |
| | | |
| | | @Mutation updateStrictQueryList(data: AgentOfStrictQuery[]) { |
| | | @Mutation |
| | | updateStrictQueryList(data: AgentOfStrictQuery[]) { |
| | | this.strictQueryList = data; |
| | | } |
| | | |
| | | @Mutation updateMyAppointmentList(data: ClientInfo[]) { |
| | | @Mutation |
| | | updateMyAppointmentList(data: ClientInfo[]) { |
| | | this.myAppointmentList = data; |
| | | } |
| | | |
| | | @Mutation updateMyAppointmentReviewLog(data: AppointmentLog[]) { |
| | | @Mutation |
| | | updateMyNewAppointmentSum(newAppointmentSum: number) { |
| | | this.myNewAppointmentSum = newAppointmentSum; |
| | | } |
| | | |
| | | @Mutation |
| | | updateMyAppointmentReviewLog(data: AppointmentLog[]) { |
| | | this.myAppointmentReviewLogList = data; |
| | | } |
| | | |
| | | @Action storeRecommendList() { |
| | | @Action |
| | | storeRecommendList() { |
| | | recommend().then(data => { |
| | | this.context.commit('updateRecommend', data) |
| | | }) |
| | |
| | | } |
| | | |
| | | @Action |
| | | async storeMyAppointmentList() { |
| | | return await getMyAppointmentList().then((data) => { |
| | | storeMyAppointmentList(): void { |
| | | appointmentService.getMyAppointmentList().then((data) => { |
| | | const newAppointmentSum = data.filter(item => !item.consultantViewTime || item.consultantViewTime === null).length; |
| | | this.context.commit('updateMyAppointmentList', data); |
| | | return data.filter(item => !item.consultantViewTime || item.consultantViewTime === null).length |
| | | this.context.commit('updateMyNewAppointmentSum', newAppointmentSum); |
| | | }); |
| | | } |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | @Action updateMyAppointment(myAppointment: ClientInfo) { |
| | | @Action |
| | | updateMyAppointment(myAppointment: ClientInfo) { |
| | | const data = this.myAppointmentList.filter(item => item.id !== myAppointment.id); |
| | | data.unshift(myAppointment); |
| | | this.context.commit('updateMyAppointmentList', data) |