-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60a5f03
commit 7582461
Showing
5 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useMutation } from "@tanstack/react-query" | ||
import UserService, { EditUsersBody } from "./UserService" | ||
|
||
export function useEditUserMutation(users: EditUsersBody) { | ||
return useMutation({ | ||
mutationFn: () => UserService.editUsers(users) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { useQuery } from "@tanstack/react-query" | ||
import UserService from "./UserService" | ||
|
||
export function useUsersQuery() { | ||
return useQuery({ | ||
queryKey: ["allUsers"], | ||
queryFn: () => UserService.getUsers() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { components } from "models/__generated__/schema" | ||
import fetchClient from "../OpenApiFetchClient" | ||
|
||
type UserAdditionalInfo = components["schemas"]["UserAdditionalInfo"] | ||
export type EditUsersBody = { | ||
uid: string | ||
updatedInformation: UserAdditionalInfo | ||
}[] | ||
|
||
const UserService = { | ||
getUsers: async function () { | ||
const { data } = await fetchClient.GET("/users", {}) | ||
return data | ||
}, | ||
editUsers: async function (users: EditUsersBody) { | ||
await fetchClient.PATCH("/users/bulk-edit", { | ||
body: { | ||
users | ||
} | ||
}) | ||
} | ||
} as const | ||
|
||
export default UserService |
This file was deleted.
Oops, something went wrong.