diff --git a/app/history/page.tsx b/app/history/page.tsx index f8c5d0b..0f22bad 100644 --- a/app/history/page.tsx +++ b/app/history/page.tsx @@ -13,7 +13,6 @@ import { } from "@mui/icons-material"; import { Alert, - Container, Stack, Table, TableBody, @@ -76,7 +75,7 @@ const RecentPage = () => { }; return ( - +
{events.length !== 0 ? ( @@ -115,7 +114,7 @@ const RecentPage = () => { ) : ( No events )} - + ); }; diff --git a/app/layout.tsx b/app/layout.tsx index c721cab..626d610 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -4,6 +4,7 @@ import { RecentTasksProvider } from "@/components/RecentTasksProvider"; import { TaskEventsProvider } from "@/components/TaskEventsProvider"; import { TaskProvider } from "@/components/TasksProvider"; import ThemeRegistry from "@/components/ThemeRegistry"; +import { Container } from "@mui/material"; import { Inter } from "next/font/google"; import "./globals.css"; @@ -22,7 +23,9 @@ const RootLayout: React.FC<{ children: React.ReactNode }> = ({ children }) => ( - {children} + + {children} + diff --git a/app/page.tsx b/app/page.tsx index e374657..940a28c 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -7,7 +7,6 @@ import { Add } from "@mui/icons-material"; import { Box, Button, - Container, Dialog, DialogActions, DialogContent, @@ -104,12 +103,12 @@ const Home: React.FC = () => { const tasks = [...new Set([...order, ...names.keys()])]; return ( - +
- +
); }; diff --git a/app/recent/page.tsx b/app/recent/page.tsx index 393cd06..bd00642 100644 --- a/app/recent/page.tsx +++ b/app/recent/page.tsx @@ -2,7 +2,6 @@ import { TaskCards } from "@/components/TaskCards"; import { useRecentTasks } from "@/lib/hooks/use-recent-tasks"; -import { Container } from "@mui/material"; import { useState } from "react"; const RecentPage = () => { @@ -10,9 +9,9 @@ const RecentPage = () => { const [initialRecentTasks] = useState(recentTasks); return ( - +
- +
); }; diff --git a/app/top/page.tsx b/app/top/page.tsx new file mode 100644 index 0000000..3eafd61 --- /dev/null +++ b/app/top/page.tsx @@ -0,0 +1,32 @@ +"use client"; + +import { TaskCards } from "@/components/TaskCards"; +import { useTaskEvents } from "@/lib/hooks/use-task-events"; +import { useState } from "react"; + +const RecentPage = () => { + const { elapsedTimes, ongoingTasks, lastEventTime } = useTaskEvents(); + + const [tasks] = useState( + [...elapsedTimes.entries()] + .map( + ([task, time]) => + [ + task, + ongoingTasks.has(task) && lastEventTime !== undefined + ? time + (Date.now() - lastEventTime) / ongoingTasks.size + : time, + ] as const + ) + .sort(([, a], [, b]) => b - a) + .map(([task]) => task) + ); + + return ( +
+ +
+ ); +}; + +export default RecentPage; diff --git a/components/MyTabs.tsx b/components/MyTabs.tsx index ccb97fa..f5f1739 100644 --- a/components/MyTabs.tsx +++ b/components/MyTabs.tsx @@ -2,23 +2,29 @@ import { useRecentTasks } from "@/lib/hooks/use-recent-tasks"; import { useTaskEvents } from "@/lib/hooks/use-task-events"; -import { History, Home, Timeline } from "@mui/icons-material"; +import { History, Home, Sort, Timeline } from "@mui/icons-material"; import { LinkTab } from "./LinkTab"; import { LinkTabs } from "./LinkTabs"; export const MyTabs: React.FC = () => { const { tasks } = useRecentTasks(); - const { events } = useTaskEvents(); + const { events, elapsedTimes } = useTaskEvents(); return ( - } label="Home" /> + } label="All" /> } label="Recent" disabled={tasks.length === 0} /> + } + label="Top" + disabled={elapsedTimes.size === 0} + /> }