feat(client): update userinfo

Signed-off-by: Noa Virellia <noa@requiem.garden>
This commit is contained in:
2026-01-20 21:08:19 +08:00
parent 27ac4d9b4a
commit 4e45a9b6d0
6 changed files with 138 additions and 173 deletions

View File

@@ -0,0 +1,22 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { axiosClient } from '@/lib/axios';
interface UpdateUserPayload {
avatar?: string;
bio?: string;
nickname?: string;
subtitle?: string;
username?: string;
}
export function useUpdateUser() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (payload: UpdateUserPayload) => {
return axiosClient.patch<{ status: string }>('/user/update', payload);
},
onSuccess: async () => {
await queryClient.invalidateQueries({ queryKey: ['userInfo'] });
},
});
}

View File

@@ -6,6 +6,7 @@ export function useUserInfo() {
queryKey: ['userInfo'],
queryFn: async () => {
const response = await axiosClient.get<{
username: string;
user_id: string;
email: string;
type: string;