mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-11-03 20:36:27 +00:00
Migrate Admin user components to new client API
This commit is contained in:
@@ -72,8 +72,7 @@ const AddUser = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: (data: UserCreate) =>
|
mutationFn: (data: UserCreate) => UsersService.createUser({ body: data }),
|
||||||
UsersService.createUser({ requestBody: data }),
|
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
showSuccessToast("User created successfully")
|
showSuccessToast("User created successfully")
|
||||||
form.reset()
|
form.reset()
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const DeleteUser = ({ id, onSuccess }: DeleteUserProps) => {
|
|||||||
const { handleSubmit } = useForm()
|
const { handleSubmit } = useForm()
|
||||||
|
|
||||||
const deleteUser = async (id: string) => {
|
const deleteUser = async (id: string) => {
|
||||||
await UsersService.deleteUser({ userId: id })
|
await UsersService.deleteUser({ path: { user_id: id } })
|
||||||
}
|
}
|
||||||
|
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ const EditUser = ({ user, onSuccess }: EditUserProps) => {
|
|||||||
|
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: (data: FormData) =>
|
mutationFn: (data: FormData) =>
|
||||||
UsersService.updateUser({ userId: user.id, requestBody: data }),
|
UsersService.updateUser({ path: { user_id: user.id }, body: data }),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
showSuccessToast("User updated successfully")
|
showSuccessToast("User updated successfully")
|
||||||
setIsOpen(false)
|
setIsOpen(false)
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ const AddItem = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: (data: ItemCreate) =>
|
mutationFn: (data: ItemCreate) => ItemsService.createItem({ body: data }),
|
||||||
ItemsService.createItem({ requestBody: data }),
|
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
showSuccessToast("Item created successfully")
|
showSuccessToast("Item created successfully")
|
||||||
form.reset()
|
form.reset()
|
||||||
|
|||||||
Reference in New Issue
Block a user