Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): Add action toasts on save
Browse files Browse the repository at this point in the history
daryllimyt committed Mar 10, 2024
1 parent 981efd4 commit 9bd13e0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions frontend/src/components/forms/action.tsx
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ import {
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip"
import { toast } from "@/components/ui/use-toast"
import {
ActionFieldOption,
getActionSchema,
@@ -64,19 +65,14 @@ export function ActionForm({
const response = await axios.get<ActionResponse>(
`http://localhost:8000/actions/${actionId}?workflow_id=${workflowId}`
)
// TODO: Validate response data with zod
return actionResponseSchema.parse(response.data)
} catch (error) {
console.error("Error fetching action:", error)
throw error // Rethrow the error to ensure it's caught by useQuery's isError state
}
}

const {
data: actionResponseData,
isLoading,
isError,
} = useQuery<ActionResponse, Error>({
const { data: actionResponseData } = useQuery<ActionResponse, Error>({
queryKey: ["selected_action", actionId, workflowId],
queryFn: getActionById,
})
@@ -243,7 +239,10 @@ export function ActionForm({
const { mutate } = useUpdateAction(actionId)
function onSubmit(values: actionFormSchemaType) {
mutate(values)
// TODO: Update the workflow switcher with the new action data
toast({
title: "Saved action",
description: "Your action has been updated successfully.",
})
}

// Loading state to defend in a user friendly way

0 comments on commit 9bd13e0

Please sign in to comment.