diff --git a/Makefile b/Makefile
index 5c6f4ac..1772f11 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ frontend:
frontend-watch:
cd frontend && yarn build --watch
-run: build
+run: *.go
./happy -develop
.PHONY: run frontend frontend-watch
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index aa48c34..8c0a779 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -3,8 +3,8 @@
Happy
-
{{err}}
+
How are you?
@@ -13,18 +13,15 @@
diff --git a/frontend/src/components/ChoiceButton.vue b/frontend/src/components/ChoiceButton.vue
index b48fc88..c74f015 100644
--- a/frontend/src/components/ChoiceButton.vue
+++ b/frontend/src/components/ChoiceButton.vue
@@ -10,7 +10,10 @@
},
methods: {
click: function(e) {
- this.$emit('selected', e, this.mood)
+ this.$emit('selected', e, this.$store.dispatch("setMood", this.mood)
+ .catch(resp => {
+ this.$store.commit('addError', resp.message);
+ }));
}
}
}
diff --git a/frontend/src/components/Chooser.vue b/frontend/src/components/Chooser.vue
index 5adff76..745c4d9 100644
--- a/frontend/src/components/Chooser.vue
+++ b/frontend/src/components/Chooser.vue
@@ -4,7 +4,6 @@
v-bind:key="mood.key"
v-bind:index="index"
:mood="mood"
- v-on:selected="doIt"
/>
@@ -20,15 +19,7 @@
},
computed: mapState({
moods: state => state.moods
- }),
- methods: {
- doIt: function(e, mood) {
- this.$store.dispatch("setMood", mood)
- .catch(resp => {
- this.$store.commit('setError', resp.message);
- })
- }
- }
+ })
}
diff --git a/frontend/src/components/Error.vue b/frontend/src/components/Error.vue
new file mode 100644
index 0000000..d41b414
--- /dev/null
+++ b/frontend/src/components/Error.vue
@@ -0,0 +1,26 @@
+
+
+ {{e}}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/store.js b/frontend/src/store.js
index aedb119..2d361be 100644
--- a/frontend/src/store.js
+++ b/frontend/src/store.js
@@ -7,7 +7,7 @@ Vue.use(Vuex);
const store = new Vuex.Store({
state: {
- err: null,
+ errs: [],
userInfo: null,
moods: [],
},
@@ -36,10 +36,10 @@ const store = new Vuex.Store({
state.moods = moods;
},
clearError(state) {
- state.err = null
+ state.errs = []
},
- setError(state, err) {
- state.err = err
+ addError(state, err) {
+ state.errs.push(err)
}
}
});