| | |
| | | import { StrictQueryParams } from '~/shared/models/strict-query.model'; |
| | | import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators' |
| | | |
| | | import { getMyReviewLog } from '~/shared/api/appointment'; |
| | | import { recommend, AgentOfStrictQuery, addFavoriteConsultant, deleteConsultant, strictQuery } from '~/shared/api/consultant'; |
| | | 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 { Consultant } from '~/shared/models/consultant.model'; |
| | | import { AppointmentLog } from '~/shared/models/appointment.model'; |
| | | import { ClientInfo } from '~/shared/models/client.model'; |
| | | import { AgentOfStrictQuery } from '~/shared/models/strict-query.model'; |
| | | @Module |
| | | export default class Store extends VuexModule { |
| | | recommendList: Consultant[] = []; |
| | |
| | | |
| | | @Action |
| | | storeRecommendList() { |
| | | recommend().then(data => { |
| | | queryConsultantService.getRecommendConsultantList().then(data => { |
| | | this.context.commit('updateRecommend', data) |
| | | }) |
| | | } |
| | |
| | | |
| | | if (localData?.length) { |
| | | const agentNoList = localData.map(i => i.agentNo) |
| | | await addFavoriteConsultant(agentNoList).then(res => { |
| | | await queryConsultantService.addFavoriteConsultant(agentNoList).then(res => { |
| | | localStorage.removeItem('favoriteConsultant') |
| | | }) |
| | | } |
| | |
| | | if (!this.isUserLogin) { |
| | | setFavoriteToStorage(left); |
| | | } else { |
| | | await deleteConsultant(agentNo) |
| | | await myConsultantService.deleteConsultant(agentNo) |
| | | } |
| | | |
| | | this.context.commit('updateConsultantList', left) |
| | |
| | | if (!found) { |
| | | const newData = [consultantToAdd].concat(this.myConsultantList); |
| | | if (this.isUserLogin) { |
| | | await addFavoriteConsultant([consultantToAdd.agentNo]) |
| | | await queryConsultantService.addFavoriteConsultant([consultantToAdd.agentNo]) |
| | | } else { |
| | | setFavoriteToStorage(newData); |
| | | } |
| | |
| | | } |
| | | |
| | | @Action |
| | | async storeStrictQueryList(strictQueryDto) { |
| | | return await strictQuery(strictQueryDto).then(res=>{ |
| | | async storeStrictQueryList(strictQueryDto: StrictQueryParams) { |
| | | return await queryConsultantService.strictQuery(strictQueryDto).then(res=>{ |
| | | this.context.commit('localStorage/storageRecommendConsultant', JSON.stringify(strictQueryDto)); |
| | | this.context.commit('updateStrictQueryList', res.data) |
| | | return res.data.length; |
| | | this.context.commit('updateStrictQueryList', res) |
| | | return res.length; |
| | | }); |
| | | } |
| | | |