TaskContext as subset of ApiHookState

This commit is contained in:
AbdBarho
2023-01-29 11:38:16 +01:00
parent d7f2a6d0d9
commit 77cc96d401
8 changed files with 45 additions and 29 deletions
+8 -2
View File
@@ -1,7 +1,13 @@
import { createContext, useContext } from "react";
import { TaskApiHook } from "src/types/Hooks";
import { BaseTask } from "src/types/Task";
import { BaseTask, TaskInfo } from "src/types/Task";
export const TaskContext = createContext<TaskApiHook<BaseTask, unknown>>(null);
export interface TaskContextType<Task extends BaseTask, ResponseContent>
extends Omit<TaskApiHook<Task, ResponseContent>, "response"> {
task: Task;
taskInfo: TaskInfo;
}
export const TaskContext = createContext<TaskContextType<BaseTask, unknown>>(null);
export const useTaskContext = () => useContext(TaskContext);