diff --git a/app/Components/ConfigMenu/ConfigMenu.tsx b/app/Components/ConfigMenu/ConfigMenu.tsx index 6adf6ad..53b3b8e 100644 --- a/app/Components/ConfigMenu/ConfigMenu.tsx +++ b/app/Components/ConfigMenu/ConfigMenu.tsx @@ -1,3 +1,4 @@ +import { DisableTabsOption } from "./DisableTabs"; import ThemeMenu from "./ThemeMenu"; export default function ConfigMenu() { @@ -26,8 +27,8 @@ export default function ConfigMenu() { > diff --git a/app/Components/ConfigMenu/DisableTabs.tsx b/app/Components/ConfigMenu/DisableTabs.tsx new file mode 100644 index 0000000..41fbba0 --- /dev/null +++ b/app/Components/ConfigMenu/DisableTabs.tsx @@ -0,0 +1,28 @@ +"use client"; + +import { useConfig } from "@/app/_lib/contexts/ConfigContext"; +import { useState } from "react"; + +export function DisableTabsOption() { + const { config, updateConfig } = useConfig(); + + const disableTabs = config.disableTabs + + function toogleTabsFunctionality() { + updateConfig({ disableTabs: !disableTabs }); + } + + return ( +
+ +
+ ); +} diff --git a/app/Components/TasksApp/_TaskApp.tsx b/app/Components/TasksApp/_TaskApp.tsx index 404f56e..8dc0a25 100644 --- a/app/Components/TasksApp/_TaskApp.tsx +++ b/app/Components/TasksApp/_TaskApp.tsx @@ -7,12 +7,15 @@ import { useAtom } from "jotai"; import { atomWithStorage } from "jotai/utils"; import { useEffect, useState } from "react"; import TaskPage from "./TaskPage"; +import { config } from "process"; +import { useConfig } from "@/app/_lib/contexts/ConfigContext"; +import clsx from "clsx"; const initialTasks: Task[] = [ - { id: '2', text: "Drink matcha", done: false, date: new Date() }, - { id: '1', text: "Call grandma", done: false, date: new Date() }, + { id: "2", text: "Drink matcha", done: false, date: new Date() }, + { id: "1", text: "Call grandma", done: false, date: new Date() }, { - id: '0', + id: "0", text: "Contemplate the inevitable increase of entropy in the universe", done: true, date: new Date(), @@ -24,6 +27,8 @@ const initialTabs: Array = [{ id: 0, name: "To-Do", tasks: initialTasks }]; const tabAtom = atomWithStorage("tabs", initialTabs); export default function TaskApp() { + const { config } = useConfig(); + const [tabs, setTabs] = useAtom(tabAtom); const [activeTab, setActiveTab] = useState(tabs[0].name); @@ -54,14 +59,21 @@ export default function TaskApp() { return ( <>
- -
+ {!config.disableTabs && ( + + )} +
updateTasks(activeTab, tasks)} diff --git a/app/_lib/contexts/ConfigContext.tsx b/app/_lib/contexts/ConfigContext.tsx index d6457d4..46ea94b 100644 --- a/app/_lib/contexts/ConfigContext.tsx +++ b/app/_lib/contexts/ConfigContext.tsx @@ -10,6 +10,7 @@ export interface TasksConfig { uncheckAudio: string; deleteAudio: string; showCompletedTasks: boolean; + disableTabs: boolean; } const initialConfig: TasksConfig = { @@ -17,6 +18,7 @@ const initialConfig: TasksConfig = { uncheckAudio: "./sounds/defaultCheck.mp3", deleteAudio: "./sounds/defaultDelete.mpeg", showCompletedTasks: true, + disableTabs: false, }; export const ConfigContextProvider = ({