@@ -34,13 +34,12 @@ import { FC, useEffect, useState } from 'react'
3434import { useForm } from 'react-hook-form'
3535import { useTranslation } from 'react-i18next'
3636import { z } from 'zod'
37- import { useUpdatePasswordMutation } from '~/apis/mutation'
3837import { useUserQuery } from '~/apis/query'
3938import { LogoText } from '~/components/LogoText'
4039import { ModalConfirmFormFooter } from '~/components/Modal'
4140import { updatePasswordFormDefault , useUpdatePasswordSchemaWithRefine } from '~/schemas/account'
4241
43- const Header : FC = ( ) => {
42+ export const Header : FC = ( ) => {
4443 const { t } = useTranslation ( )
4544 const { theme : curTheme , setTheme } = useTheme ( )
4645
@@ -53,8 +52,6 @@ const Header: FC = () => {
5352 onOpenChange : onUpdatePasswordOpenChange
5453 } = useDisclosure ( )
5554
56- const updatePasswordMutation = useUpdatePasswordMutation ( )
57-
5855 const updatePasswordSchemaWithRefine = useUpdatePasswordSchemaWithRefine ( ) ( )
5956
6057 const updatePasswordForm = useForm < z . infer < typeof updatePasswordSchemaWithRefine > > ( {
@@ -204,9 +201,8 @@ const Header: FC = () => {
204201 < form
205202 onSubmit = { updatePasswordForm . handleSubmit ( async ( values ) => {
206203 try {
207- await updatePasswordMutation . mutateAsync ( {
208- currentPassword : values . oldPassword ,
209- newPassword : values . newPassword
204+ await ky . post ( '/api/update-password' , {
205+ json : { currentPassword : values . currentPassword , newPassword : values . newPassword }
210206 } )
211207
212208 onUpdatePasswordClose ( )
@@ -220,10 +216,10 @@ const Header: FC = () => {
220216 < div className = "flex flex-col gap-4" >
221217 < Input
222218 type = "password"
223- label = { t ( 'primitives.oldPassword ' ) }
224- placeholder = { t ( 'primitives.oldPassword ' ) }
225- errorMessage = { updatePasswordForm . formState . errors . oldPassword ?. message }
226- { ...updatePasswordForm . register ( 'oldPassword ' ) }
219+ label = { t ( 'primitives.currentPassword ' ) }
220+ placeholder = { t ( 'primitives.currentPassword ' ) }
221+ errorMessage = { updatePasswordForm . formState . errors . currentPassword ?. message }
222+ { ...updatePasswordForm . register ( 'currentPassword ' ) }
227223 />
228224
229225 < Input
@@ -255,5 +251,3 @@ const Header: FC = () => {
255251 )
256252}
257253Header . displayName = 'Header'
258-
259- export { Header }
0 commit comments