first commit
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
<template>
|
||||
<AuthShell>
|
||||
<form class="auth-form" @submit.prevent="onSubmit">
|
||||
<div class="auth-form__body">
|
||||
<AuthHeading title="تغییر رمز عبور" subtitle="در این قسمت رمز عبور جدید خود را وارد کنید" />
|
||||
|
||||
<TextField
|
||||
v-model="form.phoneNumber"
|
||||
name="phoneNumber"
|
||||
label="شماره موبایل"
|
||||
:disabled="!!user?.phoneNumber"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="phone" :size="22" color="var(--color-thd-gray)" />
|
||||
</template>
|
||||
</TextField>
|
||||
|
||||
<PasswordField
|
||||
v-model="form.password"
|
||||
name="password"
|
||||
label="رمز عبور"
|
||||
:error="errors.password"
|
||||
@blur="validateAt('password', form.password)"
|
||||
/>
|
||||
|
||||
<PasswordField
|
||||
v-model="form.passwordConfirmation"
|
||||
name="passwordConfirmation"
|
||||
label="تکرار رمز عبور"
|
||||
:error="errors.passwordConfirmation"
|
||||
@blur="validateAt('passwordConfirmation', form.passwordConfirmation)"
|
||||
/>
|
||||
|
||||
<BaseButton
|
||||
type="submit"
|
||||
text="تایید رمز عبور"
|
||||
:loading="resetMutation.isPending.value"
|
||||
custom-class="reset__submit"
|
||||
>
|
||||
<template #appendIcon>
|
||||
<SvgIcon name="arrow-left" :size="22" color="#fff" />
|
||||
</template>
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<div class="auth-form__footer">
|
||||
<AuthCopyright />
|
||||
</div>
|
||||
</form>
|
||||
</AuthShell>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import AuthShell from '@/features/auth/components/AuthShell.vue'
|
||||
import AuthHeading from '@/features/auth/components/AuthHeading.vue'
|
||||
import AuthCopyright from '@/features/auth/components/AuthCopyright.vue'
|
||||
import BaseButton from '@/components/BaseButton.vue'
|
||||
import TextField from '@/components/form/TextField.vue'
|
||||
import PasswordField from '@/components/form/PasswordField.vue'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import useYup from '@/composables/useYup'
|
||||
import useAuth from '@/composables/useAuth'
|
||||
import { useResetPasswordMutation } from '@/services/query/auth'
|
||||
import { useRedirectAfterLogin } from '@/features/auth/composables/useRedirectAfterLogin'
|
||||
import { resetPasswordSchema } from '@/features/auth/schema'
|
||||
|
||||
const { user, applySession } = useAuth()
|
||||
const redirectAfterLogin = useRedirectAfterLogin()
|
||||
|
||||
const schema = resetPasswordSchema
|
||||
|
||||
const form = ref({
|
||||
phoneNumber: user.value?.phoneNumber || '',
|
||||
password: '',
|
||||
passwordConfirmation: '',
|
||||
})
|
||||
const { validate, validateAt, errors } = useYup(schema)
|
||||
|
||||
const resetMutation = useResetPasswordMutation()
|
||||
|
||||
const onSubmit = async () => {
|
||||
const { isValid, payload } = await validate(form.value)
|
||||
if (!isValid) return
|
||||
const response = await resetMutation.mutateAsync(payload)
|
||||
applySession(response?.data ?? response)
|
||||
redirectAfterLogin()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.auth-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-grow: 1;
|
||||
|
||||
&__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
padding: 1rem 0;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
&__footer {
|
||||
margin-bottom: 1rem;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.reset__submit {
|
||||
margin-top: 1.5rem;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user