-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
affa7db
commit 83de90b
Showing
6 changed files
with
56 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import TaskContext, { | ||
TaskContextInterface, | ||
} from "../providers/task.context.provider"; | ||
import { useContext } from "react"; | ||
|
||
const useTaskContext = () => useContext(TaskContext) as TaskContextInterface; | ||
|
||
export default useTaskContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useDisclosure } from "@mantine/hooks"; | ||
import { createContext, Dispatch, SetStateAction, useState } from "react"; | ||
import { Task } from "../api/dto"; | ||
|
||
export interface TaskContextInterface { | ||
currentTask: Partial<Task> | null; | ||
setCurrentTask: Dispatch<SetStateAction<Partial<Task> | null>>; | ||
opened: boolean; | ||
setOpened: Dispatch<SetStateAction<boolean>>; | ||
} | ||
// Context of current viewed task for Dialog | ||
const TaskContext = createContext<TaskContextInterface | null>(null); | ||
|
||
interface TaskProviderProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const TaskProvider: React.FC<TaskProviderProps> = ({ children }) => { | ||
const [opened, setOpened] = useState(false); | ||
const [currentTask, setCurrentTask] = useState<Partial<Task> | null>(null); | ||
|
||
const value = { | ||
currentTask, | ||
setCurrentTask, | ||
opened, | ||
setOpened, | ||
}; | ||
return <TaskContext.Provider value={value}>{children}</TaskContext.Provider>; | ||
}; | ||
|
||
export default TaskContext; |