| | |
| | | import { StrictQueryParams } from '~/shared/models/strict-query.model'; |
| | | import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators' |
| | | |
| | | import { getFavoriteFromStorage, setFavoriteToStorage } from '~/shared/storageConsultant'; |
| | | |
| | | import myConsultantService from '~/shared/services/my-consultant.service'; |
| | | import queryConsultantService from '~/shared/services/query-consultant.service'; |
| | | import appointmentService from '~/shared/services/appointment.service'; |
| | | import reviewsService from '~/shared/services/reviews.service'; |
| | | |
| | | import { Consultant } from '~/shared/models/consultant.model'; |
| | | import { getFavoriteFromStorage, setFavoriteToStorage } from '~/shared/storageConsultant'; |
| | | import { AppointmentLog } from '~/shared/models/appointment.model'; |
| | | import { ClientInfo } from '~/shared/models/client.model'; |
| | | import { AgentOfStrictQuery } from '~/shared/models/strict-query.model'; |
| | | import { AgentOfStrictQuery, StrictQueryParams } from '~/shared/models/strict-query.model'; |
| | | import { NotificationList } from '~/shared/models/reviews.model'; |
| | | |
| | | @Module |
| | | export default class Store extends VuexModule { |
| | | recommendList: Consultant[] = []; |
| | | strictQueryList: AgentOfStrictQuery[] = []; |
| | | myConsultantList: Consultant[] = []; |
| | | |
| | | myAppointmentList: ClientInfo[] = []; |
| | | myNewAppointmentSum: number = 0; |
| | | |
| | | myAppointmentReviewLogList: AppointmentLog[] = []; |
| | | reviewLogList: AppointmentLog[] = []; |
| | | unReviewLogList: AppointmentLog[] = []; |
| | | notificationList: NotificationList[] = []; |
| | | |
| | | get isUserLogin() { |
| | | return this.context.getters['localStorage/isUserLogin']; |
| | |
| | | |
| | | @Mutation |
| | | updateRecommend(data: Consultant[]) { |
| | | this.recommendList = data; |
| | | this.recommendList = data; |
| | | } |
| | | |
| | | @Mutation |
| | |
| | | } |
| | | |
| | | @Mutation |
| | | updateMyAppointmentList(data: ClientInfo[]) { |
| | | this.myAppointmentList = data; |
| | | updateReviewLog(data: AppointmentLog[]) { |
| | | this.reviewLogList = data; |
| | | } |
| | | |
| | | @Mutation |
| | | updateMyNewAppointmentSum(newAppointmentSum: number) { |
| | | this.myNewAppointmentSum = newAppointmentSum; |
| | | updateUnReviewLog(data: AppointmentLog[]) { |
| | | this.unReviewLogList = data; |
| | | } |
| | | |
| | | @Mutation |
| | | updateMyAppointmentReviewLog(data: AppointmentLog[]) { |
| | | this.myAppointmentReviewLogList = data; |
| | | updateNotification(data: NotificationList[]) { |
| | | this.notificationList = data; |
| | | } |
| | | |
| | | @Action |
| | |
| | | } |
| | | |
| | | @Action |
| | | storeMyAppointmentList(): void { |
| | | appointmentService.getMyAppointmentList().then((data) => { |
| | | const newAppointmentSum = data.filter(item => !item.consultantViewTime || item.consultantViewTime === null).length; |
| | | this.context.commit('updateMyAppointmentList', data); |
| | | this.context.commit('updateMyNewAppointmentSum', newAppointmentSum); |
| | | }); |
| | | } |
| | | |
| | | @Action |
| | | storeMyAppointmentReviewLog() { |
| | | reviewsService.getMyReviewLog().then((data) => { |
| | | const dataWithLatestDate = data.map((item) => { |
| | |
| | | } |
| | | }); |
| | | const sortedData = dataWithLatestDate.sort((a, b) => +b.compareDate - +a.compareDate); |
| | | this.context.commit('updateMyAppointmentReviewLog', sortedData); |
| | | const reviewLog = sortedData.filter(item => item.score); |
| | | const unReviewLog = sortedData.filter(item => !item.score); |
| | | this.context.commit('updateReviewLog', reviewLog); |
| | | this.context.commit('updateUnReviewLog', unReviewLog); |
| | | }); |
| | | } |
| | | |
| | | @Action |
| | | updateMyAppointment(myAppointment: ClientInfo) { |
| | | const data = this.myAppointmentList.filter(item => item.id !== myAppointment.id); |
| | | data.unshift(myAppointment); |
| | | this.context.commit('updateMyAppointmentList', data) |
| | | } |
| | | |
| | | @Action |
| | |
| | | }); |
| | | } |
| | | |
| | | @Action |
| | | storeMyPersonalNotification() { |
| | | reviewsService.getMyPersonalNotification().then(data => { |
| | | const sortData = data |
| | | .sort((preItem, nextItem) => +new Date(nextItem.createdDate) - +new Date(preItem.createdDate)) |
| | | this.context.commit('updateNotification', sortData); |
| | | }) |
| | | } |
| | | |
| | | } |