mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
household address: post address to household (WIP)
This commit is contained in:
parent
aff140230c
commit
d513be2fce
@ -11,7 +11,7 @@
|
||||
<!-- <add-address-to-household
|
||||
@addAddressToHousehold="addAddressToHousehold">
|
||||
</add-address-to-household> -->
|
||||
<button class="sc-button bt-create centered mt-4" @click="addAddressToHousehold">
|
||||
<button class="sc-button bt-create centered mt-4" @click="addToHousehold">
|
||||
{{ $t('add_an_address_to_household') }}
|
||||
</button>
|
||||
</template>
|
||||
@ -19,7 +19,7 @@
|
||||
<script>
|
||||
|
||||
import AddAddress from 'ChillMainAssets/vuejs/_components/AddAddress.vue';
|
||||
//import AddAddressToHousehold from './components/AddAddressToHousehold.vue';
|
||||
//import AddAddressToHousehold from './components/AddAddressToHousehold.vue'; //TODO keep this?
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
@ -27,12 +27,14 @@ export default {
|
||||
AddAddress,
|
||||
//AddAddressToHousehold
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
householdId: window.householdId
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
address() {
|
||||
return this.$store.state.address;
|
||||
},
|
||||
householdId() {
|
||||
return window.householdId;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -60,12 +62,13 @@ export default {
|
||||
this.$store.dispatch('addAddress', newAddress);
|
||||
modal.showModal = false;
|
||||
},
|
||||
addAddressToHousehold() {
|
||||
const household = householdId;
|
||||
const address = address;
|
||||
console.log(household);
|
||||
console.log(address)
|
||||
this.$store.dispatch('addAddressToHousehold', household, address);
|
||||
addToHousehold() {
|
||||
const householdId = this.householdId;
|
||||
const address = this.$store.state.address;
|
||||
console.log(householdId);
|
||||
console.log(address);
|
||||
|
||||
this.$store.dispatch('addAddressToHousehold', {householdId, address});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,11 +1,13 @@
|
||||
/*
|
||||
* Endpoint household
|
||||
* method POST, post Household instance //TODO should be PATCH?
|
||||
* method POST, post Household instance
|
||||
*
|
||||
* @id integer - id of household
|
||||
* @body Object - dictionary with changes to post
|
||||
*/
|
||||
export const postAddressToHousehold = (id, body) => {
|
||||
console.log(id);
|
||||
console.log(body);
|
||||
const url = `/api/1.0/person/household/${id}.json`
|
||||
return fetch(url, {
|
||||
method: 'POST',
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<button class="sc-button bt-create centered mt-4" @click="doSmthg">
|
||||
<button class="sc-button bt-create centered mt-4" @click="postToHousehold">
|
||||
{{ $t('add_an_address_to_household') }}
|
||||
</button>
|
||||
</template>
|
||||
@ -22,7 +22,7 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
doSmthg() {
|
||||
postToHousehold() {
|
||||
//TODO
|
||||
console.log('click btn add_an_address_to_household')
|
||||
},
|
||||
|
@ -44,7 +44,7 @@ const store = createStore({
|
||||
addAddressToHousehold({ commit }, payload) {
|
||||
console.log('@A addAddressToHousehold payload', payload);
|
||||
|
||||
postAddressToHousehold(payload)
|
||||
postAddressToHousehold(payload.householdId, payload.address)
|
||||
.then(household => new Promise((resolve, reject) => {
|
||||
commit('addAddressToHousehold', household);
|
||||
resolve();
|
||||
|
Loading…
x
Reference in New Issue
Block a user