From 5cf166ca12c42123aa56c4dfd952c24d48d8c63a Mon Sep 17 00:00:00 2001 From: HenriT Date: Tue, 16 Feb 2021 22:09:59 +0200 Subject: [PATCH] Fix persisting client changes. Fix persisting team changes. Fix validating vat of 0. --- src/App.vue | 1 - src/store/clients.js | 8 +++----- src/store/teams.js | 7 ++----- src/utils/helpers.js | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/App.vue b/src/App.vue index b2501af..f2cdc9c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -40,7 +40,6 @@ export default { } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) { // OS theme setting detected as dark this.$store.commit('themes/theme', 'dark'); - console.log('hello there'); return document.documentElement.setAttribute('data-theme', 'dark'); } document.documentElement.setAttribute('data-theme', this.theme || 'light'); diff --git a/src/store/clients.js b/src/store/clients.js index b0dc7d5..efda1b8 100644 --- a/src/store/clients.js +++ b/src/store/clients.js @@ -50,11 +50,9 @@ export default { await dispatch('clientProps', props); return ClientService.updateClient(getters.client); }, - async updateClientById(payload) { - const client = await Client.update({ - where: payload.clientId, - data: payload.props, - }); + async updateClientById(store, payload) { + const client = Client.find(payload.clientId); + client.$update(payload.props); return ClientService.updateClient(client); }, async openNewClientModal({ commit }) { diff --git a/src/store/teams.js b/src/store/teams.js index 0b65fce..33978b3 100644 --- a/src/store/teams.js +++ b/src/store/teams.js @@ -27,11 +27,8 @@ export default { await Team.create({ data: team }); return team; }, - async teamProps({ state }, props) { - return Team.update({ - where: state.teamId, - data: props, - }); + async teamProps({ getters }, props) { + return getters.team.$update(props); }, async updateTeam({ getters, dispatch }, props) { if (props) { diff --git a/src/utils/helpers.js b/src/utils/helpers.js index 813078d..503ba45 100644 --- a/src/utils/helpers.js +++ b/src/utils/helpers.js @@ -59,7 +59,7 @@ export function validate(requiredFields, input) { } export function validateField(input, field, label) { - if (!input.hasOwnProperty(field) || !input[field] || input[field].length === 0) { + if (!input.hasOwnProperty(field) || input[field] === null || input[field].length === 0) { return [`${label} is required`]; } return null;