Commit 37c6fb2c authored by Rémy Marronnier's avatar Rémy Marronnier

adress ban + zrr + autocomplete wip

parent b409554a
export const CLARA_API_URL = "https://***/api/";
export default CLARA_API_URL;
\ No newline at end of file
import { BAN_API_URL } from "./config";
export default function BANService(postcode) {
return fetch(BAN_API_URL.concat(postcode), {
credentials: 'include',
method: "GET",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
})
}
\ No newline at end of file
export const CLARA_API_URL = "https://***/api/";
export const BAN_API_URL = "https://api-adresse.data.gouv.fr/search/?limit=5&q=";
export const ZRR_API_URL = "https://public.opendatasoft.com/api/records/1.0/search/?dataset=communes-zrr-2017&q=";
export default CLARA_API_URL;
\ No newline at end of file
import { ZRR_API_URL } from "./config";
export default function ZRRService(postcode) {
return fetch(ZRR_API_URL.concat(postcode), {
credentials: 'include',
method: "GET",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
})
}
\ No newline at end of file
import ClaraService from "@/api/clara";
// import ClaraService from "@/services/clara";
export default {
state: {
// export default {
// state: {
},
mutations: {
// },
// mutations: {
},
actions: {
}
}
\ No newline at end of file
// },
// actions: {
// }
// }
\ No newline at end of file
//import ClaraService from "@/api/clara";
import ZRRService from "@/services/zrr";
export default {
state: {
......@@ -10,7 +10,9 @@ export default {
allocation_type: "",
monthly_allocation_value: 0,
age: 0,
address: "",
location_citycode: "",
zrr: "non renseigné",
category: "",
},
mutations: {
......@@ -38,24 +40,49 @@ export default {
updateAge(state, age) {
state.age = age
},
updateAddress(state, address) {
state.address = address
},
updateLocationCitycode(state, location_citycode) {
state.location_citycode = location_citycode
},
updateZRR(state, zrr) {
state.zrr = zrr
},
updateCategory(state, category) {
state.category = category
},
},
actions: {
// submitInscription({ commit }, inscription_period) {
// },
submitAddress({ commit, state }, location_citycode) {
submitInscription({ commit, state }, inscription_period) {
if (inscription_period != state.inscription_period) {
commit('updateInscriptionPeriod', inscription_period)
commit('updateChanged', true)
}
},
submitAddress({ commit, state }, address) {
if (address != state.address) {
commit('updateAddress', address)
commit('updateChanged', true)
}
},
submitCitycode({ commit, dispatch, state }, location_citycode) {
if (location_citycode != state.location_citycode) {
commit('updateLocationCitycode', location_citycode)
commit('updateChanged', true)
ZRRService(location_citycode)
.then(res => res.json())
.then(res => {
dispatch('submitZRR', res.records.first.fields.zrr_2017);
})
}
},
submitZRR({ commit, state }, zrr) {
if (zrr != state.zrr) {
commit('updateZRR', zrr)
commit('updateChanged', true)
}
// this.$router.push('other')
},
submitAge({ commit, state }, age) {
if (age != state.age) {
......@@ -130,6 +157,7 @@ export default {
allocation_type: state => state.allocation_type,