Skip to content
Snippets Groups Projects
Commit 713edeef authored by Endrizzi, Marco (UG - Comp Sci & Elec Eng)'s avatar Endrizzi, Marco (UG - Comp Sci & Elec Eng)
Browse files

Added firebase vuex methods to components

parent 08680af4
No related branches found
No related tags found
No related merge requests found
<template> <template>
<router-view /> <router-view />
</template> </template>
<script> <script>
import { defineComponent } from 'vue' import { defineComponent } from 'vue'
import { mapActions } from 'vuex'
export default defineComponent({ export default defineComponent({
name: 'App' name: 'App',
methods: {
...mapActions('firebase', ['handleAuthStateChanged'])
},
mounted() {
this.handleAuthStateChanged()
}
}) })
</script> </script>
<template lang="pug"> <template lang="pug">
q-form.q-pa-lg(@submit='submitForm') q-form.q-pa-lg(@submit='submitForm')
q-input.q-mb-md(v-model='email', type='email', label='Email') q-input.q-mb-md(v-model='formData.email', type='email', label='Email')
template(v-slot:prepend) template(v-slot:prepend)
q-icon(name='email') q-icon(name='email')
q-input.q-mb-md(v-model='username', v-if='tab == "register"', type='username', label='Username') q-input.q-mb-md(v-model='formData.username', v-if='tab == "register"', type='username', label='Username')
template(v-slot:prepend) template(v-slot:prepend)
q-icon(name='person') q-icon(name='person')
q-input.q-mb-md(type='password', v-model='password', label='Password') q-input.q-mb-md(type='password', v-model='formData.password', label='Password')
template(v-slot:prepend) template(v-slot:prepend)
q-icon(name='lock') q-icon(name='lock')
//- Register only //- Register only
...@@ -37,23 +37,28 @@ q-form.q-pa-lg(@submit='submitForm') ...@@ -37,23 +37,28 @@ q-form.q-pa-lg(@submit='submitForm')
</template> </template>
<script> <script>
import { mapActions } from 'vuex'
export default { export default {
props: ['tab'], props: ['tab'],
data() { data() {
return { return {
email: '', formData: {
username: '', email: '',
password: '' username: '',
password: ''
}
} }
}, },
methods: { methods: {
submitForm() { submitForm() {
if (this.tab == 'login') { if (this.tab == 'login') {
console.log('login the user') this.loginUser(this.formData)
} else { } else {
console.log('register the user') this.registerUser(this.formData)
} }
} },
...mapActions('firebase', ['loginUser', 'registerUser'])
} }
} }
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment