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 { // export default {
state: { // state: {
}, // },
mutations: { // mutations: {
}, // },
actions: { // actions: {
} // }
} // }
\ No newline at end of file \ No newline at end of file
//import ClaraService from "@/api/clara"; import ZRRService from "@/services/zrr";
export default { export default {
state: { state: {
...@@ -10,7 +10,9 @@ export default { ...@@ -10,7 +10,9 @@ export default {
allocation_type: "", allocation_type: "",
monthly_allocation_value: 0, monthly_allocation_value: 0,
age: 0, age: 0,
address: "",
location_citycode: "", location_citycode: "",
zrr: "non renseigné",
category: "", category: "",
}, },
mutations: { mutations: {
...@@ -38,24 +40,49 @@ export default { ...@@ -38,24 +40,49 @@ export default {
updateAge(state, age) { updateAge(state, age) {
state.age = age state.age = age
}, },
updateAddress(state, address) {
state.address = address
},
updateLocationCitycode(state, location_citycode) { updateLocationCitycode(state, location_citycode) {
state.location_citycode = location_citycode state.location_citycode = location_citycode
}, },
updateZRR(state, zrr) {
state.zrr = zrr
},
updateCategory(state, category) { updateCategory(state, category) {
state.category = category state.category = category
}, },
}, },
actions: { actions: {
// submitInscription({ commit }, inscription_period) { submitInscription({ commit, state }, inscription_period) {
if (inscription_period != state.inscription_period) {
// }, commit('updateInscriptionPeriod', inscription_period)
submitAddress({ commit, state }, location_citycode) { 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) { if (location_citycode != state.location_citycode) {
commit('updateLocationCitycode', location_citycode) commit('updateLocationCitycode', location_citycode)
commit('updateChanged', true) commit('updateChanged', true)
ZRRService(location_citycode)
.then(res => res.json())
.then(res => {
dispatch('submitZRR', res.records.first.fields.zrr_2017);
})
}
},
submitZRR({