1+ // --- НАЧАЛО ИСПРАВЛЕННОГО КОДА ---
12import { Container , Heading , Input , Text } from "@chakra-ui/react"
23import { useMutation } from "@tanstack/react-query"
34import { createFileRoute , redirect } from "@tanstack/react-router"
45import { type SubmitHandler , useForm } from "react-hook-form"
56import { FiMail } from "react-icons/fi"
67
7- import { type ApiError , LoginService } from "@/client"
8+ import { type ApiError , loginLoginRouterRecoverPassword } from "@/client"
89import { Button } from "@/components/ui/button"
910import { Field } from "@/components/ui/field"
1011import { InputGroup } from "@/components/ui/input-group"
1112import { isLoggedIn } from "@/hooks/useAuth"
1213import useCustomToast from "@/hooks/useCustomToast"
13- import { emailPattern , handleError } from "@/utils"
14+ // --- ИЗМЕНЕНИЕ ---: Импорт handleError удален
15+ import { emailPattern } from "@/utils"
1416
1517interface FormData {
1618 email : string
@@ -34,10 +36,11 @@ function RecoverPassword() {
3436 reset,
3537 formState : { errors, isSubmitting } ,
3638 } = useForm < FormData > ( )
37- const { showSuccessToast } = useCustomToast ( )
39+ // --- ИЗМЕНЕНИЕ ---: Получаем showApiErrorToast из хука
40+ const { showSuccessToast, showApiErrorToast } = useCustomToast ( )
3841
3942 const recoverPassword = async ( data : FormData ) => {
40- await LoginService . recoverPassword ( {
43+ await loginLoginRouterRecoverPassword ( {
4144 email : data . email ,
4245 } )
4346 }
@@ -49,12 +52,13 @@ function RecoverPassword() {
4952 reset ( )
5053 } ,
5154 onError : ( err : ApiError ) => {
52- handleError ( err )
55+ // --- ИЗМЕНЕНИЕ ---: Используем новый, правильный метод
56+ showApiErrorToast ( err )
5357 } ,
5458 } )
5559
56- const onSubmit : SubmitHandler < FormData > = async ( data ) => {
57- mutation . mutate ( data )
60+ const onSubmit : SubmitHandler < FormData > = ( data ) => {
61+ void mutation . mutate ( data )
5862 }
5963
6064 return (
@@ -71,9 +75,7 @@ function RecoverPassword() {
7175 < Heading size = "xl" color = "ui.main" textAlign = "center" mb = { 2 } >
7276 Password Recovery
7377 </ Heading >
74- < Text textAlign = "center" >
75- A password recovery email will be sent to the registered account.
76- </ Text >
78+ < Text textAlign = "center" > A password recovery email will be sent to the registered account.</ Text >
7779 < Field invalid = { ! ! errors . email } errorText = { errors . email ?. message } >
7880 < InputGroup w = "100%" startElement = { < FiMail /> } >
7981 < Input
@@ -93,3 +95,4 @@ function RecoverPassword() {
9395 </ Container >
9496 )
9597}
98+ // --- КОНЕЦ ИСПРАВЛЕННОГО КОДА ---
0 commit comments