Cleanup structure
This commit is contained in:
parent
68893d503d
commit
a47eadd68f
@ -1,9 +1,24 @@
|
|||||||
import {SubjectComparisonCard} from "@/app/cards/subjectComparisonCard";
|
import {SubjectComparisonCard} from "@/app/cards/subjectComparisonCard";
|
||||||
import {CalendarOverviewCard} from "@/app/cards/calendarOverviewCard";
|
import {CalendarOverviewCard} from "@/app/cards/calendarOverviewCard";
|
||||||
import {OverviewConfig} from "@/app/overviewConfig";
|
|
||||||
import {SubjectOverviewCard} from "@/app/cards/subjectOverviewCard";
|
import {SubjectOverviewCard} from "@/app/cards/subjectOverviewCard";
|
||||||
import {getData} from "@/app/fetchData";
|
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}: {
|
export default async function OverviewPage({config}: {
|
||||||
config: OverviewConfig
|
config: OverviewConfig
|
||||||
}) {
|
}) {
|
||||||
@ -25,6 +40,7 @@ export default async function OverviewPage({config}: {
|
|||||||
|
|
||||||
<CalendarOverviewCard
|
<CalendarOverviewCard
|
||||||
data={data}
|
data={data}
|
||||||
|
goal={config.goalHours}
|
||||||
startTime={config.timePeriod.start}
|
startTime={config.timePeriod.start}
|
||||||
endTime={config.timePeriod.end}
|
endTime={config.timePeriod.end}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -8,12 +8,15 @@ import '../calendar-styles.css'
|
|||||||
import {Tooltip} from 'react-tooltip';
|
import {Tooltip} from 'react-tooltip';
|
||||||
import {Data} from "@/app/fetchData";
|
import {Data} from "@/app/fetchData";
|
||||||
|
|
||||||
const dailyGoal = 4;
|
|
||||||
const granularity = 4;
|
const granularity = 4;
|
||||||
|
|
||||||
function computeCompletionShade(value: number) {
|
function computeCompletionShade(value: number, dailyGoal: number) {
|
||||||
const linearValue = Math.round((value / dailyGoal) * granularity);
|
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;
|
if (linearValue == 0 && value > 0) return 1;
|
||||||
|
|
||||||
|
// Clamp to the granularity
|
||||||
if (linearValue > granularity) return granularity;
|
if (linearValue > granularity) return granularity;
|
||||||
return linearValue;
|
return linearValue;
|
||||||
}
|
}
|
||||||
@ -50,10 +53,12 @@ function useCalendarData(data: Data, initialDate: Date, endDate: Date) {
|
|||||||
|
|
||||||
export function CalendarOverviewCard({
|
export function CalendarOverviewCard({
|
||||||
data,
|
data,
|
||||||
|
goal,
|
||||||
startTime,
|
startTime,
|
||||||
endTime
|
endTime,
|
||||||
}: {
|
}: {
|
||||||
data: Data,
|
data: Data,
|
||||||
|
goal: number,
|
||||||
startTime: string,
|
startTime: string,
|
||||||
endTime: string,
|
endTime: string,
|
||||||
}) {
|
}) {
|
||||||
@ -69,7 +74,7 @@ export function CalendarOverviewCard({
|
|||||||
startDate={initialDate}
|
startDate={initialDate}
|
||||||
endDate={endDate}
|
endDate={endDate}
|
||||||
values={calendarData}
|
values={calendarData}
|
||||||
classForValue={value => `color-github-${computeCompletionShade(value?.count ?? 0)}`}
|
classForValue={value => `color-github-${computeCompletionShade(value?.count ?? 0, goal)}`}
|
||||||
tooltipDataAttrs={(value: any) => {
|
tooltipDataAttrs={(value: any) => {
|
||||||
return value.date ? {
|
return value.date ? {
|
||||||
'data-tooltip-id': `calendar-tooltip`,
|
'data-tooltip-id': `calendar-tooltip`,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import {OverviewConfig} from "@/app/overviewConfig";
|
|
||||||
|
import {OverviewConfig} from "@/app/OverviewPage";
|
||||||
|
|
||||||
export interface Data {
|
export interface Data {
|
||||||
projects: {
|
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 Link from "next/link";
|
||||||
import {semester1Revision} from "@/app/overviewConfig";
|
|
||||||
|
|
||||||
export default function Home() {
|
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 OverviewPage, {OverviewConfig} from "@/app/OverviewPage";
|
||||||
import {OverviewConfig} from "@/app/overviewConfig";
|
|
||||||
|
|
||||||
const semester2: OverviewConfig = {
|
const semester2: OverviewConfig = {
|
||||||
title: 'Semester 2',
|
title: 'Semester 2',
|
||||||
goalHours: 4,
|
goalHours: 7.5,
|
||||||
subjects: [
|
subjects: [
|
||||||
{
|
{
|
||||||
projectId: 195754611,
|
projectId: 195754611,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user