Skip to content
Snippets Groups Projects
Commit afd60a78 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

order projects by date

parent 2163cb99
No related branches found
No related tags found
3 merge requests!3add export-geojson & fix slug vs title in feature_list route,!2add extra_form to feature_edit,!1format date for derniers signalements, detect click outside menu dropdown and...
......@@ -8,7 +8,7 @@ import store from './store'
Vue.config.productionTip = false
axios.all([store.dispatch("GET_PROJECTS"), store.dispatch("GET_STATIC_PAGES")]).then(axios.spread(function () {
axios.all([store.dispatch("GET_ALL_PROJECTS"), store.dispatch("GET_STATIC_PAGES")]).then(axios.spread(function () {
new Vue({
router,
store,
......
......@@ -7,11 +7,11 @@ import router from '../router'
Vue.use(Vuex);
const GET_PROJECT_USER = GET_PROJECT_USER;
const GET_PROJECTS = GET_PROJECTS;
/* const GET_PROJECT_USER = GET_PROJECT_USER;
const GET_ALL_PROJECTS = GET_ALL_PROJECTS;
const CHECK_LOGIN = CHECK_LOGIN;
const SET_COOKIE = SET_COOKIE;
const SET_STATIC_PAGES = SET_STATIC_PAGES;
const SET_STATIC_PAGES = SET_STATIC_PAGES; */
export default new Vuex.Store({
......@@ -47,10 +47,13 @@ export default new Vuex.Store({
},
actions: {
async GET_PROJECTS({ commit }) {
async GET_ALL_PROJECTS({ commit }) {
await axios
.get("http://localhost:8000/api/projects/")
.then((response) => (commit("SET_PROJECTS", response.data)))
.then((response) => {
const orderedProjects = response.data.sort((a, b) => new Date(b.created_on) - new Date(a.created_on));
commit("SET_PROJECTS", orderedProjects)
})
.catch((error) => {
throw error;
});
......@@ -66,7 +69,7 @@ export default new Vuex.Store({
GET_PROJECT({ commit }, project_slug) {
axios
.get(`http://localhost:8000/api/projet/${project_slug}/project`)
.then((response) => (commit("SET_PROJECT", response.data)))
.then((response) => commit("SET_PROJECT", response.data))
.catch((error) => {
throw error;
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment