This commit is contained in:
2026-05-22 23:11:09 +03:00
parent aa25c6dec5
commit 96ea3788d5
9 changed files with 229 additions and 161 deletions

View File

@@ -90,6 +90,25 @@ export async function passwordResetStart(payload: PasswordResetStartPayload): Pr
}
}
export async function updatePhone(phone: string): Promise<void> {
const headers = await authedHeaders()
const res = await fetch(`${USERS_API_URL}/me/settings/phone`, {
method: 'PATCH',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
...headers,
},
body: JSON.stringify({ phone }),
})
if (!res.ok) {
const data = await res.json().catch(() => ({}))
throw data
}
}
export interface PasswordResetCompletePayload {
email: string
code: string

View File

@@ -0,0 +1,12 @@
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { updatePhone } from '../api/profileApi'
export function useUpdatePhone() {
const queryClient = useQueryClient()
return useMutation<void, unknown, string>({
mutationFn: updatePhone,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['me'] })
},
})
}

View File

@@ -1,8 +1,9 @@
export { registrationStart, registrationComplete, loginStart, loginComplete } from './api/registrationApi'
export { getMe, uploadAvatar } from './api/profileApi'
export { getMe, uploadAvatar, updatePhone } from './api/profileApi'
export type { MeResponse, UploadAvatarPayload } from './api/profileApi'
export { useMe } from './hooks/useMe'
export { useUploadAvatar } from './hooks/useUploadAvatar'
export { useUpdatePhone } from './hooks/useUpdatePhone'
export type { RegistrationStartPayload, RegistrationCompletePayload, LoginStartPayload, LoginCompletePayload, AuthResponse } from './api/registrationApi'
export { useIsAuthenticated } from './hooks/useIsAuthenticated'
export { useAuth, AUTH_QUERY_KEY } from './hooks/useAuth'