Skip to content

Commit

Permalink
feat: update user api
Browse files Browse the repository at this point in the history
  • Loading branch information
TinsFox committed Sep 20, 2024
1 parent 7911c33 commit c06ff83
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/hooks/query/use-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@ export const queryUser = () => queryOptions({
queryFn: async () => apiFetch<IUserProfile>("/api/user"),
})

export const queryUserInfo = () =>
queryOptions({
queryKey: ["user-info"],
queryFn: async () => apiFetch<IUserProfile>(`/api/user/info`),
})

export function useUser() {
return useSuspenseQuery(queryUser())
return useSuspenseQuery(queryUserInfo())
}

export function useUserLoginMutation() {
return useMutation({
mutationFn: async (loginForm: ILoginForm) =>
await apiFetch("/api/login", {
await apiFetch("/api/auth/login", {
method: "POST",
body: loginForm,
}),
mutationKey: ["user-login"],
})
}

Expand All @@ -44,7 +51,7 @@ export function useUsers(pagination: PaginationState) {
total: number
page: number
pageSize: number
}>("/api/users", {
}>("/api/team-users", {
params: {
page: pagination.pageIndex,
pageSize: pagination.pageSize,
Expand Down

0 comments on commit c06ff83

Please sign in to comment.