Skip to content

Commit

Permalink
feat: remove update atom
Browse files Browse the repository at this point in the history
  • Loading branch information
fandujar committed Oct 13, 2024
1 parent 51d2d2d commit 9f9630a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions choregate-ui/src/components/Task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { Steps } from "./Steps"
import { StepAdd } from "./StepAdd"
import { TaskRuns } from "./TaskRuns"
import { TaskRunCreate } from "./TaskRunCreate"
import { TaskUpdateAtom } from "@/atoms/Update";
import { TaskAtom } from "@/atoms/Tasks";
import { useRecoilState } from "recoil";
import { toast } from "sonner";

import { TaskSettings } from "./TaskSettings";
import { useQuery } from "react-query";

type TaskProps = {
taskID: string
Expand All @@ -20,17 +20,17 @@ type TaskProps = {
export const Task = (props: TaskProps) => {
const { taskID } = props
const [task, setTask] = useRecoilState(TaskAtom)
const [update, setUpdate] = useRecoilState(TaskUpdateAtom)
const { data, isLoading } = useQuery('task', () => getTask(taskID))

useEffect(() => {
const task = getTask(taskID)
task.then((task) => {
setTask(task)
}).catch((error) => {
toast.error(`${error.message}: ${error.response.data}`)
})
setUpdate(false)
}, [update])
if (data) {
setTask(data)
}
}, [data])

if (isLoading) {
return <div>Loading...</div>
}

return (
<section className="flex-auto m-5">
Expand Down

0 comments on commit 9f9630a

Please sign in to comment.