import axios from "axios"; export const state = () => ({ ads: [] }); export const mutations = { SET_ADS(state, ads) { state.ads = ads; } }; export const actions = { async getAds({ commit }) { await axios.get("https://api.amic.ru/api/v1/advertising/active").then(res => { commit("SET_ADS", res.data.data) return true }) } }; export const getters = { headerAds: s => s.ads.filter(obj => { return obj.advertising_section_code == 'header_banner'})[0], mainAds: s => s.ads.filter(obj => { return obj.advertising_section_code == 'main_banner'})[0], sideAds: s => s.ads.filter(obj => { return obj.advertising_section_code == 'side_banner'})[0], partners1: s => s.ads.filter(obj => { return obj.advertising_section_code == 'partners1'})[0], partners2: s => s.ads.filter(obj => { return obj.advertising_section_code == 'partners2'})[0], partners3: s => s.ads.filter(obj => { return obj.advertising_section_code == 'partners3'})[0], partners4: s => s.ads.filter(obj => { return obj.advertising_section_code == 'partners4'})[0], partners5: s => s.ads.filter(obj => { return obj.advertising_section_code == 'partners5'})[0] }; export default { namespaced: true, state, getters, actions, mutations }