Skip to content

Commit

Permalink
👷 Update item edit form data after successful save
Browse files Browse the repository at this point in the history
  • Loading branch information
flipkick committed Dec 12, 2024
1 parent 88c83cc commit db1249d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion frontend/src/components/Items/EditItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
type ApiError,
type ItemPublic,
type ItemUpdate,
type ItemsUpdateItemResponse,
ItemsService,
} from "../../client"
import useCustomToast from "../../hooks/useCustomToast"
Expand Down Expand Up @@ -47,8 +48,9 @@ const EditItem = ({ item, isOpen, onClose }: EditItemProps) => {
const mutation = useMutation({
mutationFn: (data: ItemUpdate) =>
ItemsService.updateItem({ id: item.id, requestBody: data }),
onSuccess: () => {
onSuccess: (data: ItemsUpdateItemResponse) => {
showToast("Success!", "Item updated successfully.", "success")
reset(data)
onClose()
},
onError: (err: ApiError) => {
Expand Down

0 comments on commit db1249d

Please sign in to comment.