orderiom-api-package
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "orderiom-api-package", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "this package will install all neccessary api calls for every orderiom restaurant", | ||
@@ -64,2 +64,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
@@ -90,5 +90,5 @@ import axios from "axios"; | ||
.then(res => { | ||
window.localStorage.setItem("privateToken", res.data.data.access_token); | ||
window.localStorage.setItem("expires_at", res.data.data.expires_at); | ||
if (authData.manager) { | ||
window.localStorage.setItem("managerToken", res.data.data.access_token); | ||
window.localStorage.setItem("expires_at", res.data.data.expires_at); | ||
return { | ||
@@ -99,2 +99,4 @@ type: 'success', | ||
} | ||
window.localStorage.setItem("privateToken", res.data.data.access_token); | ||
window.localStorage.setItem("expires_at", res.data.data.expires_at); | ||
commit("authUser", { | ||
@@ -101,0 +103,0 @@ privateToken: res.data.data.access_token, |
@@ -7,3 +7,5 @@ import axios from "axios"; | ||
restaurants: [], | ||
tables: [] | ||
tables: [], | ||
blogs: [], | ||
blog: null | ||
}); | ||
@@ -23,2 +25,8 @@ | ||
state.tables = tables | ||
}, | ||
setBlogs(state, blogs) { | ||
state.blogs = blogs | ||
}, | ||
setBlog(state, blog) { | ||
state.blog = blog | ||
} | ||
@@ -191,5 +199,62 @@ }; | ||
}); | ||
} | ||
}, | ||
getBlogs({ commit }, restaurantId) { | ||
return axios.get('api/blogs', { | ||
params: restaurantId | ||
}).then(res => { | ||
commit('setBlogs', res.data.data) | ||
return { | ||
type: 'success', | ||
msg: 'ok' | ||
} | ||
}).catch(error => { | ||
commit('setBlogs', []) | ||
if (error.response) { | ||
if (error.response.status == 422) { | ||
return { | ||
type: 'error', | ||
msg: Object.values(error.response.data.error.validation).map(m => { return m[0] }).toString() | ||
} | ||
} | ||
if (error.response.status == 401 || error.response.status == 403 || error.response.status == 404 || error.response.status == 400) { | ||
return { | ||
type: 'error', | ||
msg: error.response.data.message.body | ||
} | ||
} | ||
} | ||
}) | ||
}, | ||
getBlog({ commit }, blogId) { | ||
return axios.get('api/blogs/show', { | ||
params: blogId | ||
}).then(res => { | ||
commit('setBlog', res.data.data) | ||
return { | ||
type: 'success', | ||
msg: 'ok' | ||
} | ||
}).catch(error => { | ||
commit('setBlog', []) | ||
if (error.response) { | ||
if (error.response.status == 422) { | ||
return { | ||
type: 'error', | ||
msg: Object.values(error.response.data.error.validation).map(m => { return m[0] }).toString() | ||
} | ||
} | ||
if (error.response.status == 401 || error.response.status == 403 || error.response.status == 404 || error.response.status == 400) { | ||
return { | ||
type: 'error', | ||
msg: error.response.data.message.body | ||
} | ||
} | ||
} | ||
}) | ||
}, | ||
} | ||
@@ -196,0 +261,0 @@ export default { |
88797
2172