♻️ Refactor and tweaks, rename UserCreateOpen to UserRegister and others (#1143)

This commit is contained in:
Alejandra
2024-04-01 22:53:33 -05:00
committed by GitHub
parent aed4db7521
commit 4239d93ea6
45 changed files with 537 additions and 518 deletions

View File

@@ -40,24 +40,23 @@ const AddItem = ({ isOpen, onClose }: AddItemProps) => {
},
})
const addItem = async (data: ItemCreate) => {
await ItemsService.createItem({ requestBody: data })
}
const mutation = useMutation(addItem, {
onSuccess: () => {
showToast("Success!", "Item created successfully.", "success")
reset()
onClose()
const mutation = useMutation(
(data: ItemCreate) => ItemsService.createItem({ requestBody: data }),
{
onSuccess: () => {
showToast("Success!", "Item created successfully.", "success")
reset()
onClose()
},
onError: (err: ApiError) => {
const errDetail = err.body?.detail
showToast("Something went wrong.", `${errDetail}`, "error")
},
onSettled: () => {
queryClient.invalidateQueries("items")
},
},
onError: (err: ApiError) => {
const errDetail = err.body?.detail
showToast("Something went wrong.", `${errDetail}`, "error")
},
onSettled: () => {
queryClient.invalidateQueries("items")
},
})
)
const onSubmit: SubmitHandler<ItemCreate> = (data) => {
mutation.mutate(data)