Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -51,8 +50,6 @@ export default async function MainPage({
throw new Error(JSON.stringify(currentActivity));
}

const { dayRange, smoothCharts, maxTimeUnit } = getPreferences();

return (
<div className={styles.dashboardContainer}>
<Dashboard
Expand All @@ -63,11 +60,8 @@ export default async function MainPage({
start_time: new Date(e.start_time),
dayStart: startOfDay(new Date(e.start_time)),
}))}
defaultDayRange={dayRange}
smoothCharts={smoothCharts}
locale={locale}
initialActivity={currentActivity}
maxTimeUnit={maxTimeUnit}
/>
</div>
);
Expand Down
6 changes: 0 additions & 6 deletions src/app/[locale]/users/[username]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -45,18 +44,13 @@ export default async function UserPage({
currentActivity = currentActivityResponse ?? undefined;
}

const { dayRange, smoothCharts, maxTimeUnit } = getPreferences();

return (
<Dashboard
allEntries={data}
username={decodedUsername}
isFrontPage={false}
locale={locale}
initialActivity={currentActivity}
defaultDayRange={dayRange}
maxTimeUnit={maxTimeUnit}
smoothCharts={smoothCharts}
/>
);
}
14 changes: 6 additions & 8 deletions src/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<DayRange>(defaultDayRange);
const [statisticsRange, setStatisticsRange] = useState<DayRange>(
defaultDayRange ?? "week",
);
const [selectedProjects, setSelectedProjects] = useState<string[]>([]);
const isSmallScreen = useMediaQuery("(max-width: 700px)");

Expand Down