Updated Home to using store.

This commit is contained in:
neviyn 2018-09-17 13:00:51 +01:00
parent 15c5e6d39c
commit eb0c5abc7b

View File

@ -44,9 +44,9 @@
</template> </template>
<script> <script>
import Vue from 'vue' import Vue from "vue";
import 'vue-awesome/icons/spinner'; import "vue-awesome/icons/spinner";
import { mapState, mapMutations } from 'vuex' import { mapState, mapMutations } from "vuex";
export default { export default {
name: "home", name: "home",
data() { data() {
@ -54,12 +54,12 @@ export default {
siteOptions: [], siteOptions: [],
tutorOptions: [], tutorOptions: [],
loadingTutors: false loadingTutors: false
} };
}, },
mounted() { mounted() {
Vue.axios.get("/api/site/all").then((response) => { Vue.axios.get("/api/site/all").then(response => {
this.siteOptions = response.data; this.siteOptions = response.data;
}) });
}, },
computed: { computed: {
...mapState(["site", "description", "type", "tutors"]) ...mapState(["site", "description", "type", "tutors"])
@ -76,10 +76,10 @@ export default {
...mapMutations(["setSite", "setDescription", "setType", "setTutors"]), ...mapMutations(["setSite", "setDescription", "setType", "setTutors"]),
getTutors: function() { getTutors: function() {
if (this.site != null) { if (this.site != null) {
Vue.axios.get("/api/tutor/site/" + this.site).then((response) => { Vue.axios.get("/api/tutor/site/" + this.site).then(response => {
this.tutorOptions = response.data; this.tutorOptions = response.data;
this.loadingTutors = false; this.loadingTutors = false;
}) });
} }
} }
} }