Client - empty form and error messages on path change
This commit is contained in:
parent
6c770ed76b
commit
0235a93c5b
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="login-form">
|
<div id="login-or-register-form">
|
||||||
<div id="user-form">
|
<div id="user-form">
|
||||||
<div class="form-box">
|
<div class="form-box">
|
||||||
<form @submit.prevent="onSubmit(action)">
|
<form @submit.prevent="onSubmit(action)">
|
||||||
@ -43,8 +43,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ComputedRef, computed, defineComponent, reactive } from 'vue'
|
import { ComputedRef, computed, defineComponent, reactive, watch } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
import { IFormData } from '@/interfaces'
|
import { IFormData } from '@/interfaces'
|
||||||
import { ROOT_STORE, USER_STORE } from '@/store/constants'
|
import { ROOT_STORE, USER_STORE } from '@/store/constants'
|
||||||
@ -52,7 +53,7 @@
|
|||||||
import ErrorMessage from '@/components/Common/ErrorMessage.vue'
|
import ErrorMessage from '@/components/Common/ErrorMessage.vue'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'LoginForm',
|
name: 'LoginOrRegisterForm',
|
||||||
components: {
|
components: {
|
||||||
ErrorMessage,
|
ErrorMessage,
|
||||||
},
|
},
|
||||||
@ -70,6 +71,7 @@
|
|||||||
password_conf: '',
|
password_conf: '',
|
||||||
})
|
})
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
const route = useRoute()
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
|
||||||
const buttonText: ComputedRef<string> = computed(() =>
|
const buttonText: ComputedRef<string> = computed(() =>
|
||||||
@ -85,7 +87,19 @@
|
|||||||
formData,
|
formData,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
function resetFormData() {
|
||||||
|
formData.username = ''
|
||||||
|
formData.email = ''
|
||||||
|
formData.password = ''
|
||||||
|
formData.password_conf = ''
|
||||||
|
}
|
||||||
|
watch(
|
||||||
|
() => route.path,
|
||||||
|
async () => {
|
||||||
|
store.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||||
|
resetFormData()
|
||||||
|
}
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
t,
|
t,
|
||||||
buttonText,
|
buttonText,
|
||||||
@ -100,7 +114,7 @@
|
|||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import '~@/scss/base';
|
@import '~@/scss/base';
|
||||||
|
|
||||||
#login-form {
|
#login-or-register-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user