diff --git a/src/app/[locale]/page.tsx b/src/app/[locale]/page.tsx index 9799e342..1b277020 100644 --- a/src/app/[locale]/page.tsx +++ b/src/app/[locale]/page.tsx @@ -13,7 +13,6 @@ import { getOwnActivityData, } from "../../api/usersApi"; import { redirect } from "next/navigation"; -import { getPreferences } from "../../utils/cookieUtils"; export default async function MainPage({ params: { locale }, @@ -51,8 +50,6 @@ export default async function MainPage({ throw new Error(JSON.stringify(currentActivity)); } - const { dayRange, smoothCharts, maxTimeUnit } = getPreferences(); - return (
); diff --git a/src/app/[locale]/users/[username]/page.tsx b/src/app/[locale]/users/[username]/page.tsx index 54b4754c..ce1a9be5 100644 --- a/src/app/[locale]/users/[username]/page.tsx +++ b/src/app/[locale]/users/[username]/page.tsx @@ -8,7 +8,6 @@ import { CurrentActivity } from "../../../../components/CurrentActivity/CurrentA import { GetUserActivityDataError } from "../../../../types"; import initTranslations from "../../../i18n"; import { Stack, Title } from "@mantine/core"; -import { getPreferences } from "../../../../utils/cookieUtils"; export default async function UserPage({ params: { locale, username }, @@ -45,8 +44,6 @@ export default async function UserPage({ currentActivity = currentActivityResponse ?? undefined; } - const { dayRange, smoothCharts, maxTimeUnit } = getPreferences(); - return ( ); } diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index 06d0bd19..74e744f3 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -39,32 +39,30 @@ import { DataCard } from "./DataCard/DataCard"; import MonthlyCodingTimeChart, { transformData as transformMonthlyData, } from "./MonthlyCodingTimeChart"; +import { useSettings } from "../hooks/useSettings"; interface DashboardProps { username: string; isFrontPage: boolean; allEntries: ActivityDataEntry[]; - defaultDayRange: DayRange; - smoothCharts: boolean; locale: string; initialActivity: CurrentActivity | undefined | null; - maxTimeUnit: TimeUnit; } export const Dashboard = ({ username, isFrontPage, allEntries, - defaultDayRange, - smoothCharts, locale, initialActivity, - maxTimeUnit, }: DashboardProps) => { const { t } = useTranslation(); + const { smoothCharts, defaultDayRange, timeInHours } = useSettings(); + const maxTimeUnit: TimeUnit = timeInHours ? "h" : "y"; - const [statisticsRange, setStatisticsRange] = - useState(defaultDayRange); + const [statisticsRange, setStatisticsRange] = useState( + defaultDayRange ?? "week", + ); const [selectedProjects, setSelectedProjects] = useState([]); const isSmallScreen = useMediaQuery("(max-width: 700px)");