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