123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- /* eslint-disable guard-for-in */
- /* eslint-disable no-restricted-syntax */
- import axios from 'axios';
- import MyData from '../../../assets/myData';
- import MaritalStatus from '../../../assets/staticData/maritalStatus';
-
- export default {
- namespaced: true,
- state: {
- resorts: [],
- regions: [],
- detailedRegion: [],
- seasons: [],
- resortBedrooms: [],
- maxSleep: [],
- bankedEntities: [],
- agencies: [],
- agents: [],
- maritalStatus: MaritalStatus,
- sellItem: {
- referedByAgent: false,
- agent: undefined,
- agency: undefined,
- otherResort: false,
- otherResortName: undefined,
- resort: undefined,
- region: undefined,
- season: undefined,
- module: undefined,
- unitNumber: undefined,
- bedrooms: undefined,
- maxSleep: undefined,
- weekNumber: undefined,
- levyAmount: undefined,
- currentYearBanked: false,
- bankedWith: undefined,
- leviesPaidInFull: false,
- weekPlacedForRental: false,
- originalPurchasePrice: undefined,
- originalPurchaseDate: undefined,
- arrivalDate: undefined,
- departureDate: undefined,
- sellingPrice: undefined,
- agentCommission: undefined,
- mandate: undefined,
- status: undefined,
- owner: {
- name: undefined,
- surname: undefined,
- idNumber: undefined,
- companyRegNumber: undefined,
- maritalStatus: undefined,
- emailAddress: undefined,
- cellNumber: undefined,
- landlineNumber: undefined,
- address: {
- streetNumber: undefined,
- streetName: undefined,
- suburb: undefined,
- city: undefined,
- province: undefined,
- postalCode: undefined,
- },
- bankingDetails: {
- bank: undefined,
- accountNumber: undefined,
- accountHolder: undefined,
- },
- },
- },
- },
- mutations: {
- setUnitConfigurationList(state, list) {
- state.unitConfigurationList = list;
- },
- setAgency(state, agencies) {
- state.agencies = agencies;
- },
- setAgent(state, agents) {
- state.agents = agents;
- },
- setSeason(state, seasons) {
- state.seasons = seasons;
- },
- setResortBedrooms(state, resortBedrooms) {
- state.resortBedrooms = resortBedrooms;
- },
- setMaxSleep(state, maxSleep) {
- state.maxSleep = maxSleep;
- },
- setBankedEntities(state, bankedEntities) {
- state.bankedEntities = bankedEntities;
- },
- addResort(state, resorts) {
- state.resorts = resorts;
- },
- addRegion(state, regions) {
- state.regions = regions;
- },
- addDetailedRegion(state, detailedRegion) {
- state.detailedRegion.push(detailedRegion);
- },
- },
- getters: {
-
- },
- actions: {
- initTimeshare({
- commit,
- dispatch,
- }) {
- commit('setResortBedrooms', MyData.resortBedrooms);
- commit('setMaxSleep', MyData.maxBedrooms);
- commit('setBankedEntities', MyData.bankedEntities);
- dispatch('getSeasons');
- dispatch('getAgents');
- dispatch('getAgencies');
- dispatch('getResorts');
- dispatch('getRegions');
- },
- getSeasons({
- commit,
- }) {
- axios
- .get('/api/season')
- .then(result => commit('setSeason', result.data))
- .catch(console.error);
- },
- getAgencies({
- commit,
- }) {
- console.log(123);
- axios
- .get('/api/agency')
- .then(result => commit('setAgency', result.data))
- .catch(console.error);
- },
- getAgents({
- commit,
- }) {
- axios
- .get('/api/agent')
- .then(result => commit('setAgent', result.data))
- .catch(console.error);
- },
- getResorts({
- commit,
- }) {
- axios
- .get('https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/')
- .then(result => commit('addResort', result.data))
- .catch(console.error);
- },
- getRegions({
- dispatch,
- commit,
- }) {
- axios
- .get('https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/regions/list/ZA')
- .then((result) => {
- commit('addRegion', result.data);
- dispatch('getDetailedRegion', result.data);
- })
- .catch(console.error);
- },
- getDetailedRegion({
- commit,
- }, data) {
- if (data) {
- for (const r in Object.keys(data)) {
- const region = data[r];
- if (region !== undefined) {
- axios
- .get(
- `https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/${
- region.regionCode
- }/`,
- )
- .then(result => commit('addDetailedRegion', {
- region,
- children: result.data,
- }))
- .catch(console.error);
- }
- }
- }
- },
- },
- };
|