Line data Source code
1 1 : <template>
2 : <form
3 : data-testid="update-password-dialog"
4 : class="flex w-96 flex-col gap-6"
5 : @submit.prevent="onSubmit"
6 : >
7 : <PasswordFields />
8 :
9 : <Button type="submit" class="mt-4 h-10" :loading="loading">
10 : {{ $t('userSettings.updatePassword') }}
11 : </Button>
12 : </form>
13 : </template>
14 :
15 : <script setup lang="ts">
16 : import { useForm } from 'vee-validate'
17 : import { ref } from 'vue'
18 :
19 : import PasswordFields from '@/components/dialog/content/signin/PasswordFields.vue'
20 : import Button from '@comfyorg/design-system/button/Button'
21 : import { useUpdatePassword } from '@/composables/auth/useUpdatePassword'
22 : import { updatePasswordSchema } from '@/schemas/signInSchema'
23 :
24 : const { requestSignIn, onSuccess } = defineProps<{
25 : requestSignIn: () => Promise<boolean>
26 : onSuccess: () => void
27 : }>()
28 :
29 1 : const updatePassword = useUpdatePassword(requestSignIn)
30 1 : const loading = ref(false)
31 :
32 1 : const { handleSubmit } = useForm({
33 : validationSchema: updatePasswordSchema,
34 : initialValues: { password: '', confirmPassword: '' }
35 : })
36 :
37 1 : const onSubmit = handleSubmit(async ({ password }) => {
38 1 : loading.value = true
39 1 : try {
40 1 : await updatePassword(password)
41 1 : onSuccess()
42 : } finally {
43 1 : loading.value = false
44 : }
45 : })
46 : </script>
|