Cleanup structure
This commit is contained in:
parent
68893d503d
commit
a47eadd68f
@ -1,9 +1,24 @@
|
||||
import {SubjectComparisonCard} from "@/app/cards/subjectComparisonCard";
|
||||
import {CalendarOverviewCard} from "@/app/cards/calendarOverviewCard";
|
||||
import {OverviewConfig} from "@/app/overviewConfig";
|
||||
import {SubjectOverviewCard} from "@/app/cards/subjectOverviewCard";
|
||||
import {getData} from "@/app/fetchData";
|
||||
|
||||
export interface OverviewConfig {
|
||||
title: string,
|
||||
|
||||
subjects: {
|
||||
title?: string,
|
||||
projectId: number,
|
||||
}[],
|
||||
|
||||
goalHours: number,
|
||||
|
||||
timePeriod: {
|
||||
start: string,
|
||||
end: string
|
||||
},
|
||||
}
|
||||
|
||||
export default async function OverviewPage({config}: {
|
||||
config: OverviewConfig
|
||||
}) {
|
||||
@ -25,6 +40,7 @@ export default async function OverviewPage({config}: {
|
||||
|
||||
<CalendarOverviewCard
|
||||
data={data}
|
||||
goal={config.goalHours}
|
||||
startTime={config.timePeriod.start}
|
||||
endTime={config.timePeriod.end}
|
||||
/>
|
||||
|
||||
@ -8,12 +8,15 @@ import '../calendar-styles.css'
|
||||
import {Tooltip} from 'react-tooltip';
|
||||
import {Data} from "@/app/fetchData";
|
||||
|
||||
const dailyGoal = 4;
|
||||
const granularity = 4;
|
||||
|
||||
function computeCompletionShade(value: number) {
|
||||
function computeCompletionShade(value: number, dailyGoal: number) {
|
||||
const linearValue = Math.round((value / dailyGoal) * granularity);
|
||||
|
||||
// If we did something, but not enough to reach the first level, return 1
|
||||
if (linearValue == 0 && value > 0) return 1;
|
||||
|
||||
// Clamp to the granularity
|
||||
if (linearValue > granularity) return granularity;
|
||||
return linearValue;
|
||||
}
|
||||
@ -50,10 +53,12 @@ function useCalendarData(data: Data, initialDate: Date, endDate: Date) {
|
||||
|
||||
export function CalendarOverviewCard({
|
||||
data,
|
||||
goal,
|
||||
startTime,
|
||||
endTime
|
||||
endTime,
|
||||
}: {
|
||||
data: Data,
|
||||
goal: number,
|
||||
startTime: string,
|
||||
endTime: string,
|
||||
}) {
|
||||
@ -69,7 +74,7 @@ export function CalendarOverviewCard({
|
||||
startDate={initialDate}
|
||||
endDate={endDate}
|
||||
values={calendarData}
|
||||
classForValue={value => `color-github-${computeCompletionShade(value?.count ?? 0)}`}
|
||||
classForValue={value => `color-github-${computeCompletionShade(value?.count ?? 0, goal)}`}
|
||||
tooltipDataAttrs={(value: any) => {
|
||||
return value.date ? {
|
||||
'data-tooltip-id': `calendar-tooltip`,
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import {OverviewConfig} from "@/app/overviewConfig";
|
||||
|
||||
import {OverviewConfig} from "@/app/OverviewPage";
|
||||
|
||||
export interface Data {
|
||||
projects: {
|
||||
|
||||
@ -1,40 +1 @@
|
||||
export interface OverviewConfig {
|
||||
title: string,
|
||||
|
||||
subjects: {
|
||||
title?: string,
|
||||
projectId: number,
|
||||
}[],
|
||||
|
||||
goalHours: number,
|
||||
|
||||
timePeriod: {
|
||||
start: string,
|
||||
end: string
|
||||
},
|
||||
}
|
||||
|
||||
export const semester1Revision: OverviewConfig = {
|
||||
title: 'Semester 1 Revision',
|
||||
goalHours: 4,
|
||||
subjects: [
|
||||
{
|
||||
projectId: 195482340,
|
||||
},
|
||||
{
|
||||
title: 'Measure Theory',
|
||||
projectId: 195519024,
|
||||
},
|
||||
{
|
||||
title: 'Quantum Mechanics',
|
||||
projectId: 195518593,
|
||||
},
|
||||
{
|
||||
projectId: 195754611,
|
||||
}
|
||||
],
|
||||
timePeriod: {
|
||||
start: "2023-12-15T00:00:00.000Z",
|
||||
end: "2024-01-25T00:00:00.000Z"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,18 @@
|
||||
import OverviewPage from "@/app/OverviewPage";
|
||||
import {semester1Revision} from "@/app/overviewConfig";
|
||||
import Link from "next/link";
|
||||
|
||||
export default function Home() {
|
||||
return <OverviewPage config={semester1Revision}/>
|
||||
return <main className="m-6 text-slate-900 dark:text-white">
|
||||
<h1 className="text-3xl font-semibold my-2">Work Tracker</h1>
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
<Link href="/sem1-revision" className={"text-blue-500 underline underline-offset-2"}>
|
||||
Semester 1 Revision
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/sem2" className={"text-blue-500 underline underline-offset-2"}>Semester 2</Link>
|
||||
</li>
|
||||
</ol>
|
||||
</main>
|
||||
}
|
||||
|
||||
30
src/app/sem1-revision/page.tsx
Normal file
30
src/app/sem1-revision/page.tsx
Normal file
@ -0,0 +1,30 @@
|
||||
import OverviewPage, {OverviewConfig} from "@/app/OverviewPage";
|
||||
|
||||
const semester1Revision: OverviewConfig = {
|
||||
title: 'Semester 1 Revision',
|
||||
goalHours: 4,
|
||||
subjects: [
|
||||
{
|
||||
projectId: 195482340,
|
||||
},
|
||||
{
|
||||
title: 'Measure Theory',
|
||||
projectId: 195519024,
|
||||
},
|
||||
{
|
||||
title: 'Quantum Mechanics',
|
||||
projectId: 195518593,
|
||||
},
|
||||
{
|
||||
projectId: 195754611,
|
||||
}
|
||||
],
|
||||
timePeriod: {
|
||||
start: "2023-12-15T00:00:00.000Z",
|
||||
end: "2024-01-25T00:00:00.000Z"
|
||||
}
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
return <OverviewPage config={semester1Revision}/>
|
||||
}
|
||||
@ -1,9 +1,8 @@
|
||||
import OverviewPage from "@/app/OverviewPage";
|
||||
import {OverviewConfig} from "@/app/overviewConfig";
|
||||
import OverviewPage, {OverviewConfig} from "@/app/OverviewPage";
|
||||
|
||||
const semester2: OverviewConfig = {
|
||||
title: 'Semester 2',
|
||||
goalHours: 4,
|
||||
goalHours: 7.5,
|
||||
subjects: [
|
||||
{
|
||||
projectId: 195754611,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user