Untitled

mail@pastecode.io avatar
unknown
php
a year ago
1.5 kB
3
Indexable
import Vuex from 'vuex'; import httpService from '../services/HttpService'; export default new Vuex.Store({ modules: { }, state: { states:[] }, orderData : { orders:[] }, getters: { }, mutations: { setStates(state, states) { state.states = states; }, setOrderData(orderData, orders) { orderData.orders = orders; } }, actions: { //for fedex one rate async getStates( { commit, state }, countryCode) { //let countryCode = try { let { data: request } = await httpService.getStatesOfACountry('UNITED_STATES_OF_AMERICA'); if (request.success) { let states = request.data && request.data.states; // filter not allowed states for( var i = 0; i < states.length; i++){ if ( states[i].code === 'APO' || states[i].code === 'FPO' || states[i].code === 'DPO' || states[i].code === 'GU' || states[i].code === 'MH' || states[i].code === 'MP' || states[i].code === 'PW' || states[i].code === 'AS' || states[i].code === 'FM' ) { states.splice(i, 1); i--; } } commit('setStates', states); } } catch (err) { console.log(err); } }, async getStates( { commit }) { //let countryCode = try { let response = await httpService.getAllShipment(); if (response.success) { commit('setOrderData', response); } } catch (err) { console.log(err); } }, // async getCountries( { commit, state }) { // try { // let { data: request } = await httpService.getCountries(); // if (request.success) { // let countries = request.data; // commit('setCountries', countries); // console.log(countries); // } // } catch (err) { // console.log(err); // } // } } })