Skip to content

Commit

Permalink
refactor: rename the state to be more meaningful
Browse files Browse the repository at this point in the history
  • Loading branch information
devgustavosantos committed Aug 2, 2024
1 parent d0a421c commit 42b1326
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/contexts/Tasks/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { TasksContext } from './';
import { TasksProviderProps } from './types';

export function TasksProvider({ children }: TasksProviderProps) {
const [task, setTask] = useState<TaskType | null>(null);
const [currentTask, setCurrentTask] = useState<TaskType | null>(null);

return (
<TasksContext.Provider value={{ task, setTask }}>
<TasksContext.Provider value={{ currentTask, setCurrentTask }}>
{children}
</TasksContext.Provider>
);
Expand Down
4 changes: 2 additions & 2 deletions src/contexts/Tasks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ interface TasksProviderProps {
}

interface TasksContextType {
task: TaskType | null;
setTask: Dispatch<SetStateAction<TaskType | null>>;
currentTask: TaskType | null;
setCurrentTask: Dispatch<SetStateAction<TaskType | null>>;
}

export type { TasksProviderProps, TasksContextType };
4 changes: 2 additions & 2 deletions src/pages/Home/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function useHome() {
},
});

const { setTask } = useTasksContext();
const { setCurrentTask } = useTasksContext();

const taskNameRegister = register('name');
const desiredTimeRegister = register('desiredTime', {
Expand Down Expand Up @@ -83,7 +83,7 @@ export function useHome() {
function onSubmit(data: FormType) {
if (schemaValidation.error) return;

setTask({
setCurrentTask({
name: data.name,
desiredTime: data.desiredTime,
createdAt: new Date(),
Expand Down

0 comments on commit 42b1326

Please sign in to comment.