diff --git a/lootalot_front/src/components/Wealth.vue b/lootalot_front/src/components/Wealth.vue index 41fdef9..9347a1e 100644 --- a/lootalot_front/src/components/Wealth.vue +++ b/lootalot_front/src/components/Wealth.vue @@ -1,5 +1,5 @@ @@ -58,20 +57,28 @@ data () { return { edit_values: [0,0,0,0], + form_errors: [false,false,false,false], + inputs_key: 0, // Hack to re-render inputs }; }, methods: { updateWealth (op) { - const values = this.edit_values.map(Number); - console.log('updateWealth', op, values); - let success; - if (true) { - success = true; - } + const values = this.edit_values; + this.form_errors.fill(false); // Reset error status + values.forEach((v,i) => { + if (isNaN(v)) { + console.log("error with value", v); + this.form_errors[i] = true; + }; + }); + const success = !this.form_errors.includes(true); if (success) { + console.log('updated', op, values); this.$emit('updated'); - this.edit_values.fill(0) - + this.edit_values.fill(0) } + else { + console.log(this.form_errors); + this.inputs_key += 1; } } }