From 0cf56b6a398db8aa3e77029553dc64e6309c0ea2 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Mon, 25 May 2026 15:30:45 -0400 Subject: [PATCH 01/24] run formatter --- src/components/profile/contract/Contract.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/profile/contract/Contract.tsx b/src/components/profile/contract/Contract.tsx index f994073f..b14fecb9 100644 --- a/src/components/profile/contract/Contract.tsx +++ b/src/components/profile/contract/Contract.tsx @@ -8,7 +8,7 @@ import { useOutletContext } from "react-router-dom"; interface ContractProps { categoriesData: CategoryData[]; - profileData?: StudentRecord + profileData?: StudentRecord; } export default function Contract({ categoriesData, profileData }: ContractProps) { @@ -25,7 +25,7 @@ export default function Contract({ categoriesData, profileData }: ContractProps) const profileId = profileData?.profile_id ?? session?.user.id; if (!profileData) { - throw Error("Error: No session or profile_id has been defined"); + throw Error("Error: No session or profile_id has been defined"); } // if the categoriesData changes, update the problem count From 71fea1cf935d81f2dc5872c4357eefd0132c72cc Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Mon, 25 May 2026 16:13:25 -0400 Subject: [PATCH 02/24] set edit button to be read only based off db value --- src/components/profile/contract/Contract.tsx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components/profile/contract/Contract.tsx b/src/components/profile/contract/Contract.tsx index bf7d9ade..b9c7ae21 100644 --- a/src/components/profile/contract/Contract.tsx +++ b/src/components/profile/contract/Contract.tsx @@ -149,6 +149,24 @@ function ContractModal({ problemCountByCategory, }: ContractModalProps) { const [isUpdating, setIsUpdating] = useState(false); + const [isReadOnly, setIsReadOnly] = useState(false); + + useEffect(() => { + const checkIfReadOnly = async () => { + const { data: readOnlySetting, error } = await supabase + .from("settings") + .select("value") + .eq("key", "contract-read-only"); + + if(error){ + throw Error("Contract Read-Only Setting cannot be Defined", error) + } else { + const readOnlyValue = readOnlySetting?.[0]?.value as string; + setIsReadOnly(JSON.parse(readOnlyValue)); + } + }; + checkIfReadOnly(); + }, [isReadOnly]); /** * This function enforces a max and min of submitted values @@ -234,7 +252,7 @@ function ContractModal({ ) : ( - )} From f13a30e978c183eed4b8399b645c273e7284b13c Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Tue, 26 May 2026 13:22:27 -0400 Subject: [PATCH 03/24] set readonly on contract through admin dashboard --- src/components/admin/AdminPageModal.tsx | 31 +++++++++++++++++++++++-- src/routes/AdminPage.tsx | 12 +++++++--- src/types.ts | 3 ++- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/components/admin/AdminPageModal.tsx b/src/components/admin/AdminPageModal.tsx index f68f81bc..13229bf9 100644 --- a/src/components/admin/AdminPageModal.tsx +++ b/src/components/admin/AdminPageModal.tsx @@ -1,5 +1,5 @@ import { Modal, Box, Typography, Switch } from "@mui/joy"; -import { ReactNode } from "react"; +import { ReactNode, useEffect, useState } from "react"; // Interface for Modal Props interface AdminPageModalProps { @@ -9,6 +9,7 @@ interface AdminPageModalProps { modalDesc: string; switchLabel?: string; switchAction?: () => void; + switchCondition?: () => Promise; extraNodes?: ReactNode[]; } @@ -40,8 +41,34 @@ export default function AdminPageModal({ modalDesc, switchLabel, switchAction, + switchCondition, extraNodes: extraNode, }: AdminPageModalProps) { + const [isChecked, setIsChecked] = useState(false); + + // If a switchCondition is set, handle it as a checked condition for the toggle itself + useEffect(() => { + const handleSwitchCondition = async () => { + if (!switchCondition) return; + const fetchedCheckState = await switchCondition(); + setIsChecked(fetchedCheckState); + }; + handleSwitchCondition(); + }, [switchCondition]); + + const handleSwitchChange = async () => { + const nextChecked = !isChecked; + + setIsChecked(nextChecked); + + try { + await switchAction?.(); + } catch (error) { + setIsChecked(!nextChecked); + throw error; + } + }; + return ( } + endDecorator={} > {switchLabel} diff --git a/src/routes/AdminPage.tsx b/src/routes/AdminPage.tsx index 78faddf2..000a85cc 100644 --- a/src/routes/AdminPage.tsx +++ b/src/routes/AdminPage.tsx @@ -6,6 +6,7 @@ import CategoryPasswordForm from "../components/admin/CategoryPasswordForm"; import { ListProtectedCategories } from "../components/admin/ListProtectedCategories"; import { useLoaderData } from "react-router-dom"; import { SearchBar } from "../components/admin/SearchBar"; +import { fetchContractPerms, updateContractPerms } from "../utils/contractPerms"; // Defines the data in the modal interface ModalMetaData { @@ -34,7 +35,7 @@ export default function AdminPage() { { title: "View Student Information", desc: "Enter the email/student id of the student you want to a detailed view of", - extraNodes: [] + extraNodes: [], }, { title: "Toggle Public/Test Questions", @@ -44,7 +45,11 @@ export default function AdminPage() { { title: "Modify Global Contract Permissions", desc: "Below is a switch that toggles the contract to be read-only globally. This does not apply for student who have contract overrides enabled.", - switch: { switchLabel: "Toggle Read-Only Mode", switchAction: () => ({}) }, + switch: { + switchLabel: "Toggle Read-Only Mode", + switchCondition: () => fetchContractPerms(), + switchAction: () => updateContractPerms(), + }, }, ]; @@ -67,7 +72,7 @@ export default function AdminPage() { gap: 1.5, border: "10px, solid ,#d4ff99", padding: "100px", - marginTop: "5%" + marginTop: "5%", }} > @@ -90,6 +95,7 @@ export default function AdminPage() { modalDesc={activeModal.desc} switchLabel={activeModal.switch?.switchLabel} switchAction={activeModal.switch?.switchAction} + switchCondition={activeModal.switch?.switchCondition} extraNodes={activeModal.extraNodes} /> )} diff --git a/src/types.ts b/src/types.ts index 4bc8a3b4..9b0dcb0d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -19,7 +19,8 @@ export interface CategoryData { } export interface AdminSwitch { - switchLabel: string + switchLabel: string; + switchCondition: () => Promise; switchAction: () => void; } From 1335f6743334b285a6353e18bdc10794ba24e694 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Tue, 26 May 2026 13:22:50 -0400 Subject: [PATCH 04/24] create helper functions to get setting for contract --- src/utils/contractPerms.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/utils/contractPerms.ts diff --git a/src/utils/contractPerms.ts b/src/utils/contractPerms.ts new file mode 100644 index 00000000..cb51d801 --- /dev/null +++ b/src/utils/contractPerms.ts @@ -0,0 +1,33 @@ +import { supabase } from "../supabaseClient"; + +/** + * Toggles the contract read-only setting and updates the db + */ +export async function updateContractPerms() { + const contractStatusBool = await fetchContractPerms(); + const { error } = await supabase + .from("settings") + .update({ value: !contractStatusBool }) + .eq("key", "contract-read-only"); + + if (error) { + throw Error(error.message); + } +} + +/** + * Function the value of the read-only values of the contract + */ +export async function fetchContractPerms() { + const { data, error } = await supabase + .from("settings") + .select("value") + .eq("key", "contract-read-only"); + + if (error) { + throw Error(error.message); + } + const contractStatusBool = data?.[0].value === "true"; + + return contractStatusBool; +} From 08741a3f955308825eb60ab3b622b86b4f891d4d Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Tue, 26 May 2026 13:26:57 -0400 Subject: [PATCH 05/24] add user tooltip when contract is readonly --- src/components/profile/contract/Contract.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/profile/contract/Contract.tsx b/src/components/profile/contract/Contract.tsx index b9c7ae21..dbf272ec 100644 --- a/src/components/profile/contract/Contract.tsx +++ b/src/components/profile/contract/Contract.tsx @@ -252,9 +252,16 @@ function ContractModal({ ) : ( - + <> + {isReadOnly && ( + + CONTRACT IS SET TO READ-ONLY + + )} + + )} From c3a41e32327a0ac4ed7abf0999e7b4bfe35e9f05 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Tue, 26 May 2026 13:27:25 -0400 Subject: [PATCH 06/24] run formatter --- src/components/profile/contract/Contract.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/profile/contract/Contract.tsx b/src/components/profile/contract/Contract.tsx index dbf272ec..4da862de 100644 --- a/src/components/profile/contract/Contract.tsx +++ b/src/components/profile/contract/Contract.tsx @@ -25,7 +25,7 @@ export default function Contract({ categoriesData, profileData }: ContractProps) const profileId = profileData?.profile_id ?? session?.user.id; if (!profileId) { - throw Error("Error: No session or profile_id has been defined"); + throw Error("Error: No session or profile_id has been defined"); } // if the categoriesData changes, update the problem count @@ -158,8 +158,8 @@ function ContractModal({ .select("value") .eq("key", "contract-read-only"); - if(error){ - throw Error("Contract Read-Only Setting cannot be Defined", error) + if (error) { + throw Error("Contract Read-Only Setting cannot be Defined", error); } else { const readOnlyValue = readOnlySetting?.[0]?.value as string; setIsReadOnly(JSON.parse(readOnlyValue)); @@ -255,10 +255,14 @@ function ContractModal({ <> {isReadOnly && ( - CONTRACT IS SET TO READ-ONLY + CONTRACT IS SET TO READ-ONLY )} - From d80e616058af3818f9291ea2ba71ef162df73e8d Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Tue, 26 May 2026 14:41:11 -0400 Subject: [PATCH 07/24] remove unessisary null type check --- src/utils/getProfiles.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/getProfiles.ts b/src/utils/getProfiles.ts index 457859ed..2ca99211 100644 --- a/src/utils/getProfiles.ts +++ b/src/utils/getProfiles.ts @@ -33,5 +33,5 @@ export async function getProfiles( throw error; } - return data as StudentRecord[] | null; + return data as StudentRecord[]; } From 38a864285e3177e5f9f3ae749e567e5db05361a5 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Tue, 26 May 2026 15:41:31 -0400 Subject: [PATCH 08/24] create override list w/ working disable logic --- src/components/admin/ContractOverrideList.tsx | 61 ++++++++++++++++++- src/routes/AdminPage.tsx | 2 + 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/components/admin/ContractOverrideList.tsx b/src/components/admin/ContractOverrideList.tsx index 08ef46f9..b43921d4 100644 --- a/src/components/admin/ContractOverrideList.tsx +++ b/src/components/admin/ContractOverrideList.tsx @@ -1,5 +1,60 @@ -export {} +import { Box, Button, List, ListItem, Typography } from "@mui/joy"; +import { useEffect, useState } from "react"; +import { getProfiles } from "../../utils/getProfiles"; +import { StudentRecord } from "../../types"; +import { supabase } from "../../supabaseClient"; -// export default function ContractOverrideList { +const boxStyles = { + bgcolor: "#b2f2bb", + border: "2px solid", + borderColor: "#006400", + borderRadius: 2, + p: 2, +}; -// } \ No newline at end of file +export default function ContractOverrideList() { + const [profilesWithOverrides, setProfilesWithOverrides] = useState(); + + useEffect(() => { + const fetchProfileWithOverrides = async () => { + const profiles = await getProfiles("contract_override", "true", "eq"); + setProfilesWithOverrides(profiles); + }; + fetchProfileWithOverrides(); + }); + + const disableOverride = async (profile_id: string) => { + const { error } = await supabase + .from("profiles") + .update({ contract_override: false }) + .eq("profile_id", `${profile_id}`); + + if (error) { + throw Error(error.message); + } + + // remove the profile from the local list + setProfilesWithOverrides((prev) => prev?.filter((p) => p.profile_id !== profile_id)); + }; + + return ( + + Students with Write Access Overrides + + {profilesWithOverrides?.map((profile, idx) => ( + + + {profile.username}({profile.student_id}) + + + + ))} + + + ); +} + +function disableOverride(profile_id: string) {} diff --git a/src/routes/AdminPage.tsx b/src/routes/AdminPage.tsx index 000a85cc..8039015a 100644 --- a/src/routes/AdminPage.tsx +++ b/src/routes/AdminPage.tsx @@ -7,6 +7,7 @@ import { ListProtectedCategories } from "../components/admin/ListProtectedCatego import { useLoaderData } from "react-router-dom"; import { SearchBar } from "../components/admin/SearchBar"; import { fetchContractPerms, updateContractPerms } from "../utils/contractPerms"; +import ContractOverrideList from "../components/admin/ContractOverrideList"; // Defines the data in the modal interface ModalMetaData { @@ -50,6 +51,7 @@ export default function AdminPage() { switchCondition: () => fetchContractPerms(), switchAction: () => updateContractPerms(), }, + extraNodes: [] }, ]; From daadd2efcbdc5e9150ca0222f63445cab2efd5e2 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Tue, 26 May 2026 15:42:08 -0400 Subject: [PATCH 09/24] remove unused function header --- src/components/admin/ContractOverrideList.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/admin/ContractOverrideList.tsx b/src/components/admin/ContractOverrideList.tsx index b43921d4..f2a0a228 100644 --- a/src/components/admin/ContractOverrideList.tsx +++ b/src/components/admin/ContractOverrideList.tsx @@ -55,6 +55,4 @@ export default function ContractOverrideList() { ); -} - -function disableOverride(profile_id: string) {} +} \ No newline at end of file From 5a4b29de1bfb7f183da9faef67e4c2e971d85185 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Tue, 26 May 2026 16:02:16 -0400 Subject: [PATCH 10/24] add msg if no overrides are active --- src/components/admin/ContractOverrideList.tsx | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/components/admin/ContractOverrideList.tsx b/src/components/admin/ContractOverrideList.tsx index f2a0a228..d58d7f80 100644 --- a/src/components/admin/ContractOverrideList.tsx +++ b/src/components/admin/ContractOverrideList.tsx @@ -41,18 +41,22 @@ export default function ContractOverrideList() { Students with Write Access Overrides - {profilesWithOverrides?.map((profile, idx) => ( - - - {profile.username}({profile.student_id}) - - - - ))} + {profilesWithOverrides && profilesWithOverrides.length > 0 ? ( + profilesWithOverrides.map((profile, idx) => ( + + + {profile.username}({profile.student_id}) + + + + )) + ) : ( + No Students Found with Overrides + )} ); -} \ No newline at end of file +} From 1175708595a499ea599b6d4790c399bad4e77da7 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Wed, 27 May 2026 01:15:58 -0400 Subject: [PATCH 11/24] add contract override to boolean --- src/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types.ts b/src/types.ts index 9b0dcb0d..3ba52fb8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,6 +8,7 @@ export interface StudentRecord { student_id: number; is_admin: boolean; pfp_id: number; + contract_override: boolean; } export interface CategoryData { From 709eb6efa706d81e920eca027d314fb8a5e59c19 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Wed, 27 May 2026 01:16:32 -0400 Subject: [PATCH 12/24] create toggle for contract override --- src/routes/StudentAnalytics.tsx | 45 +++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/src/routes/StudentAnalytics.tsx b/src/routes/StudentAnalytics.tsx index f7d012ec..b7535028 100644 --- a/src/routes/StudentAnalytics.tsx +++ b/src/routes/StudentAnalytics.tsx @@ -1,4 +1,4 @@ -import { Box, Stack, Typography } from "@mui/joy"; +import { Box, Stack, Switch, Typography } from "@mui/joy"; import CategoriesBarGraph from "../components/profile/progress/CategoriesBarGraph"; import HeatMap from "../components/profile/progress/heatmap/HeatMap"; import ActivityGraph from "../components/profile/progress/ActivityGraph"; @@ -8,6 +8,8 @@ import { getProfiles } from "../utils/getProfiles"; import { useLoaderData } from "react-router-dom"; import useActivityTracker from "../hooks/useActivityTracker"; import Contract from "../components/profile/contract/Contract"; +import { useState } from "react"; +import { supabase } from "../supabaseClient"; const containerStyles = { minHeight: "100vh", @@ -84,16 +86,17 @@ export function StudentAnalytics() { - - - Student ID: {profileData.student_id ?? "No Student ID Found"} - - - Student Name: {profileData.username ?? "No Username Found"} - - - + + + Student ID: {profileData.student_id ?? "No Student ID Found"} + + + Student Name: {profileData.username ?? "No Username Found"} + + + + ); } + +function ContractOverrideSwitch({ profileData }: { profileData: StudentRecord }) { + const [isChecked, setIsChecked] = useState(!!profileData.contract_override); + + const handleToggle = async () => { + setIsChecked(!isChecked); + const { error } = await supabase + .from("profiles") + .update({ contract_override: !isChecked }) + .eq("profile_id", profileData.profile_id); + + if (error) { + throw Error(error.message); + } + }; + + return ( + }> + Toggle Contract Readonly Override + + ); +} From bdf807ed191049a3e979683c0d9f935eed7daa46 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Wed, 27 May 2026 12:21:18 -0400 Subject: [PATCH 13/24] update styles --- src/routes/StudentAnalytics.tsx | 180 ++++++++++++++++++++++---------- 1 file changed, 126 insertions(+), 54 deletions(-) diff --git a/src/routes/StudentAnalytics.tsx b/src/routes/StudentAnalytics.tsx index b7535028..bc77ef4f 100644 --- a/src/routes/StudentAnalytics.tsx +++ b/src/routes/StudentAnalytics.tsx @@ -1,4 +1,4 @@ -import { Box, Stack, Switch, Typography } from "@mui/joy"; +import { Box, Button, Card, Divider, Stack, Switch, Typography } from "@mui/joy"; import CategoriesBarGraph from "../components/profile/progress/CategoriesBarGraph"; import HeatMap from "../components/profile/progress/heatmap/HeatMap"; import ActivityGraph from "../components/profile/progress/ActivityGraph"; @@ -13,56 +13,81 @@ import { supabase } from "../supabaseClient"; const containerStyles = { minHeight: "100vh", + px: { xs: 2, md: 4 }, + py: { xs: 2, md: 3 }, + background: "linear-gradient(180deg, #feffed 0%, #fff7d9 100%)", +}; + +const pageStyles = { + width: "100%", + maxWidth: 1500, + mx: "auto", display: "flex", flexDirection: "column", - pt: 3, - pb: 4, - px: 2, - gap: 4, + gap: 3, +}; + +const heroStyles = { + display: "flex", + alignItems: { xs: "flex-start", md: "center" }, + justifyContent: "space-between", + gap: 2, + flexWrap: "wrap", + p: { xs: 2, md: 3 }, + borderRadius: "xl", + backgroundColor: "rgba(255, 255, 255, 0.72)", + border: "1px solid rgba(0, 0, 0, 0.08)", + boxShadow: "0 20px 60px rgba(31, 41, 55, 0.08)", }; const titleStyles = { - fontSize: "2rem", - textAlign: "center", + fontSize: { xs: "1.7rem", md: "2.2rem" }, + textAlign: { xs: "left", md: "center" }, + lineHeight: 1.05, + fontWeight: 800, }; const contentStyles = { - flex: 1, - display: "flex", - gap: 4, - alignItems: "flex-start", - justifyContent: "space-between", + display: "grid", + gridTemplateColumns: { xs: "1fr", lg: "300px minmax(0, 1fr)" }, + gap: { xs: 2, lg: 3 }, + alignItems: "start", }; const leftPanelStyles = { - flex: "0 0 220px", display: "flex", flexDirection: "column", - justifyContent: "space-between", - alignItems: "center", - p: 3, - pb: 2, - minHeight: 160, - backgroundColor: "#f7f0dc", - borderRadius: "lg", - border: "1px solid", - borderColor: "rgba(0, 0, 0, 0.08)", + gap: 2, + p: 2.5, + borderRadius: "xl", + backgroundColor: "rgba(255, 255, 255, 0.8)", + border: "1px solid rgba(0, 0, 0, 0.08)", + boxShadow: "0 18px 40px rgba(31, 41, 55, 0.08)", }; const studentInfoStyles = { width: "100%", - textAlign: "center", + display: "flex", + flexDirection: "column", + gap: 0.75, }; const rightPanelStyles = { - flex: 1, display: "flex", - justifyContent: "flex-end", + minWidth: 0, }; const graphStackStyles = { width: "100%", - maxWidth: 960, + gap: 2.25, +}; + +const graphCardStyles = { + p: { xs: 1.5, md: 2 }, + borderRadius: "xl", + backgroundColor: "rgba(255, 255, 255, 0.82)", + border: "1px solid rgba(0, 0, 0, 0.08)", + boxShadow: "0 18px 40px rgba(31, 41, 55, 0.06)", }; export async function profileLoader({ params }: any): Promise { @@ -81,33 +106,63 @@ export function StudentAnalytics() { return ( - - Student Analytics: ({profileData.username}) - - - - - - Student ID: {profileData.student_id ?? "No Student ID Found"} + + + + + Student Analytics - - Student Name: {profileData.username ?? "No Username Found"} + + Performance, progress, and contract controls for {profileData.username} - - + - - - - - - - + + + + + {profileData.username ?? "No Username Found"} + + + Student ID: {profileData.student_id ?? "No Student ID Found"} + + + Last updated: {new Date(profileData.updated_at).toLocaleDateString()} + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -118,20 +173,37 @@ function ContractOverrideSwitch({ profileData }: { profileData: StudentRecord }) const [isChecked, setIsChecked] = useState(!!profileData.contract_override); const handleToggle = async () => { - setIsChecked(!isChecked); + const nextChecked = !isChecked; + + setIsChecked(nextChecked); const { error } = await supabase .from("profiles") - .update({ contract_override: !isChecked }) + .update({ contract_override: nextChecked }) .eq("profile_id", profileData.profile_id); if (error) { + setIsChecked(!nextChecked); throw Error(error.message); } }; return ( - }> - Toggle Contract Readonly Override - + + + + Contract Override + + + Temporarily bypass the read-only contract lock for this student. + + + } + > + Readonly override + + ); } From c5a0c4a5fc088658d9da0323d511d72cc009953a Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Wed, 27 May 2026 12:26:49 -0400 Subject: [PATCH 14/24] remove unused button --- src/routes/StudentAnalytics.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/routes/StudentAnalytics.tsx b/src/routes/StudentAnalytics.tsx index bc77ef4f..c1e8df2f 100644 --- a/src/routes/StudentAnalytics.tsx +++ b/src/routes/StudentAnalytics.tsx @@ -116,9 +116,6 @@ export function StudentAnalytics() { Performance, progress, and contract controls for {profileData.username} - From bdc748b5a645d2ee31774340cc6b24fa20001e38 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Wed, 27 May 2026 12:50:02 -0400 Subject: [PATCH 15/24] update styles to look even better --- src/routes/StudentAnalytics.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/routes/StudentAnalytics.tsx b/src/routes/StudentAnalytics.tsx index c1e8df2f..9d1adf50 100644 --- a/src/routes/StudentAnalytics.tsx +++ b/src/routes/StudentAnalytics.tsx @@ -108,14 +108,12 @@ export function StudentAnalytics() { - - - Student Analytics - - - Performance, progress, and contract controls for {profileData.username} - - + + Student Analytics + + + Control Panel for User: {profileData.username} + From 002aa457d550cc019561027d53369953ddeb963f Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Fri, 29 May 2026 12:32:05 -0400 Subject: [PATCH 16/24] stop infinite request loop for overrides --- src/components/admin/ContractOverrideList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/admin/ContractOverrideList.tsx b/src/components/admin/ContractOverrideList.tsx index d58d7f80..cc5ea203 100644 --- a/src/components/admin/ContractOverrideList.tsx +++ b/src/components/admin/ContractOverrideList.tsx @@ -21,7 +21,7 @@ export default function ContractOverrideList() { setProfilesWithOverrides(profiles); }; fetchProfileWithOverrides(); - }); + }, []); const disableOverride = async (profile_id: string) => { const { error } = await supabase From 818b243d653613dabbe95f58e84e703f8d3854a8 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Fri, 29 May 2026 16:40:18 -0400 Subject: [PATCH 17/24] change userData to use StudentRecord --- src/components/layout/UpperNavBar.tsx | 5 +++-- src/components/profile/UserInfo.tsx | 6 +++--- src/hooks/useAuth.ts | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/layout/UpperNavBar.tsx b/src/components/layout/UpperNavBar.tsx index 45645719..b00b124d 100644 --- a/src/components/layout/UpperNavBar.tsx +++ b/src/components/layout/UpperNavBar.tsx @@ -5,6 +5,7 @@ import { List as ListIcon } from '@phosphor-icons/react'; import ProfileAvatar from '../profile/ProfileAvatar'; import { ALL_PFPS } from '../profile/UserInfo'; import { Session } from '@supabase/supabase-js'; +import { StudentRecord } from '../../types'; interface Props { openDrawer: () => void; @@ -16,7 +17,7 @@ interface Props { sessionRemainingSeconds: number; endSession: () => void; sessionId: string | null; - userData: { name: string; pfp_id: number } | null; + userData: StudentRecord | null; isAdmin: boolean; signOut: () => void; setActiveSession: (param: boolean) => void; @@ -86,7 +87,7 @@ export default function UpperNavBar({ ) : ( <> )} - {userData?.name ?? 'Profile'} + {userData?.username ?? 'Profile'} diff --git a/src/components/profile/UserInfo.tsx b/src/components/profile/UserInfo.tsx index 1e00d832..2d39a41b 100644 --- a/src/components/profile/UserInfo.tsx +++ b/src/components/profile/UserInfo.tsx @@ -4,7 +4,7 @@ import { supabase } from "../../supabaseClient"; import { Button, Stack, Typography } from "@mui/joy"; import { useOutletContext } from "react-router-dom"; import ProfileAvatar from "./ProfileAvatar"; -import { UserData } from "../../types"; +import { StudentRecord, UserData } from "../../types"; // TODO: maybe get these dynamically? export const ALL_PFPS = [ @@ -15,7 +15,7 @@ export const ALL_PFPS = [ "thumbs-up-pfp.png" ] -export default function UserInfo({ userData, refetchProfile }: { userData: UserData | null, refetchProfile: Function }) { +export default function UserInfo({ userData, refetchProfile }: { userData: StudentRecord | null, refetchProfile: Function }) { const [isUpdating, setIsUpdating] = useState(false); const [loading, setLoading] = useState(false); const [error, setError] = useState(""); @@ -146,7 +146,7 @@ export default function UserInfo({ userData, refetchProfile }: { userData: UserD height={pfpHeight} width={pfpWidth} /> - { userData?.name && {userData.name} } + { userData?.username && {userData.username} } diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts index 67b34908..8d38cc2a 100644 --- a/src/hooks/useAuth.ts +++ b/src/hooks/useAuth.ts @@ -1,11 +1,11 @@ import { useState, useEffect, useCallback } from 'react'; import { supabase } from '../supabaseClient'; import { type Session } from '@supabase/supabase-js'; -import { UserData } from '../types'; +import { StudentRecord } from '../types'; interface UseAuthReturn { session: Session | null; - userData: UserData | null; + userData: StudentRecord | null; isAdmin: boolean; isRecoverySession: boolean; fetchProfile: () => Promise; @@ -13,7 +13,7 @@ interface UseAuthReturn { export default function useAuth(): UseAuthReturn { const [session, setSession] = useState(null); - const [userData, setUserData] = useState(null); + const [userData, setUserData] = useState(null); const [isAdmin, setIsAdmin] = useState(false); const [isRecoverySession, setIsRecoverySession] = useState(false); @@ -71,11 +71,11 @@ export default function useAuth(): UseAuthReturn { if (!session) return; const { data } = await supabase .from('profiles') - .select('username, pfp_id') + .select() .eq('profile_id', session.user.id) .single(); if (data) { - setUserData({ name: data.username, pfp_id: data.pfp_id }); + setUserData({...data}); } }, [session]); From 7afdc573d3ba3689bfabde1b1285948b971c13fa Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Fri, 29 May 2026 16:41:47 -0400 Subject: [PATCH 18/24] make override allow editing the contract even if global readonly is enabled --- src/components/profile/contract/Contract.tsx | 24 +++++++++++--------- src/routes/Account.tsx | 6 ++--- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/components/profile/contract/Contract.tsx b/src/components/profile/contract/Contract.tsx index 4da862de..3047563a 100644 --- a/src/components/profile/contract/Contract.tsx +++ b/src/components/profile/contract/Contract.tsx @@ -5,6 +5,7 @@ import ContractEdit from "./ContractEdit"; import { supabase } from "../../../supabaseClient"; import { Session } from "@supabase/supabase-js"; import { useOutletContext } from "react-router-dom"; +import { fetchContractPerms } from "../../../utils/contractPerms"; interface ContractProps { categoriesData: CategoryData[]; @@ -122,6 +123,7 @@ export default function Contract({ categoriesData, profileData }: ContractProps) setContract={setContract} featureMap={featureMap} problemCountByCategory={problemCountByCategory} + profileData={profileData} /> ); @@ -136,6 +138,7 @@ interface ContractModalProps { onSave: () => Promise; featureMap: Record; problemCountByCategory: Record; + profileData?: StudentRecord; } function ContractModal({ @@ -147,26 +150,25 @@ function ContractModal({ onSave, featureMap, problemCountByCategory, + profileData }: ContractModalProps) { const [isUpdating, setIsUpdating] = useState(false); const [isReadOnly, setIsReadOnly] = useState(false); useEffect(() => { const checkIfReadOnly = async () => { - const { data: readOnlySetting, error } = await supabase - .from("settings") - .select("value") - .eq("key", "contract-read-only"); - - if (error) { - throw Error("Contract Read-Only Setting cannot be Defined", error); - } else { - const readOnlyValue = readOnlySetting?.[0]?.value as string; - setIsReadOnly(JSON.parse(readOnlyValue)); + try { + if(profileData && profileData.contract_override === true){ + setIsReadOnly(false) + } else { + setIsReadOnly(await fetchContractPerms()); + } + } catch (error) { + console.error("Contract read-only setting could not be loaded", error); } }; checkIfReadOnly(); - }, [isReadOnly]); + }, []); /** * This function enforces a max and min of submitted values diff --git a/src/routes/Account.tsx b/src/routes/Account.tsx index f6d00ce8..d14055cd 100644 --- a/src/routes/Account.tsx +++ b/src/routes/Account.tsx @@ -11,7 +11,7 @@ import OtherStats from "../components/profile/progress/other-stats/OtherStats"; import { useOutletContext } from "react-router-dom"; import SessionReflections from "../components/profile/sessions/SessionReflections"; import useActivityTracker from "../hooks/useActivityTracker"; -import { UserData } from "../types"; +import { StudentRecord, UserData } from "../types"; /** * The `Account` component handles everything related to the profile page. @@ -19,7 +19,7 @@ import { UserData } from "../types"; */ export default function Account({ session }: { session: Session }) { const { refetchProfile } = useOutletContext<{ refetchProfile: () => Promise }>(); - const { userData } = useOutletContext<{ userData: UserData | null }>(); + const { userData } = useOutletContext<{ userData: StudentRecord }>(); // Change "reflections" into something else const [view, setView] = useState<"reflections" | "activity" | "sessions">("reflections"); @@ -58,7 +58,7 @@ export default function Account({ session }: { session: Session }) { Contract - + From 19c863db481626f704b1313fc0d81ae71575885e Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Fri, 29 May 2026 16:54:20 -0400 Subject: [PATCH 19/24] add missing dependancy --- src/components/profile/contract/Contract.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/profile/contract/Contract.tsx b/src/components/profile/contract/Contract.tsx index 3047563a..2dc15135 100644 --- a/src/components/profile/contract/Contract.tsx +++ b/src/components/profile/contract/Contract.tsx @@ -168,7 +168,7 @@ function ContractModal({ } }; checkIfReadOnly(); - }, []); + }, [profileData]); /** * This function enforces a max and min of submitted values From 8169c7b46c589d27bd174d4184bd6eb17738b952 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Fri, 29 May 2026 16:55:15 -0400 Subject: [PATCH 20/24] remove mentions of student id --- src/routes/AdminPage.tsx | 2 +- src/routes/StudentAnalytics.tsx | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/routes/AdminPage.tsx b/src/routes/AdminPage.tsx index 8039015a..6ac70dd5 100644 --- a/src/routes/AdminPage.tsx +++ b/src/routes/AdminPage.tsx @@ -35,7 +35,7 @@ export default function AdminPage() { const links: ModalMetaData[] = [ { title: "View Student Information", - desc: "Enter the email/student id of the student you want to a detailed view of", + desc: "Enter the username of the student you want to a detailed view of", extraNodes: [], }, { diff --git a/src/routes/StudentAnalytics.tsx b/src/routes/StudentAnalytics.tsx index 9d1adf50..7b9ff6fd 100644 --- a/src/routes/StudentAnalytics.tsx +++ b/src/routes/StudentAnalytics.tsx @@ -1,4 +1,4 @@ -import { Box, Button, Card, Divider, Stack, Switch, Typography } from "@mui/joy"; +import { Box, Card, Divider, Stack, Switch, Typography } from "@mui/joy"; import CategoriesBarGraph from "../components/profile/progress/CategoriesBarGraph"; import HeatMap from "../components/profile/progress/heatmap/HeatMap"; import ActivityGraph from "../components/profile/progress/ActivityGraph"; @@ -121,9 +121,6 @@ export function StudentAnalytics() { {profileData.username ?? "No Username Found"} - - Student ID: {profileData.student_id ?? "No Student ID Found"} - Last updated: {new Date(profileData.updated_at).toLocaleDateString()} From 0a3938ebd9cb9d786fe9eb1dba0f6161c177dfd3 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Fri, 29 May 2026 17:30:41 -0400 Subject: [PATCH 21/24] fix password compare logic not working --- src/routes/PasswordProtected.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/routes/PasswordProtected.tsx b/src/routes/PasswordProtected.tsx index 8830fdda..81d2a03e 100644 --- a/src/routes/PasswordProtected.tsx +++ b/src/routes/PasswordProtected.tsx @@ -43,7 +43,7 @@ export default function PasswordProtected({ order, setOrder, orderBy, - setOrderBy + setOrderBy, }: ProblemListProps) { const [passwordValue, setPasswordValue] = useState(""); const [error, setError] = useState(""); @@ -51,16 +51,20 @@ export default function PasswordProtected({ const handleClick = async () => { //Generate a hash and compare it w/ the user entered password - const hashedUserPassword = await hashPassword(passwordValue) + const hashedUserPassword = await hashPassword(passwordValue); - const { data, error } = await supabase.from("settings").select(); + const { data: actualPassword, error } = await supabase + .from("settings") + .select("value") + .eq("key", "test-password") + .single(); if (error) { setError("Failed to fetch password. Please try again."); return; } - if (hashedUserPassword === data?.[0]?.value) { + if (hashedUserPassword === actualPassword.value) { handleUnlock(); } else { setError("Incorrect password. Please try again."); From 4f95adb067643a4a5f58df4315ff2ae4d6e4f88a Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Fri, 29 May 2026 17:34:26 -0400 Subject: [PATCH 22/24] remove mentions of student id --- src/components/admin/ContractOverrideList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/admin/ContractOverrideList.tsx b/src/components/admin/ContractOverrideList.tsx index cc5ea203..a2d6586a 100644 --- a/src/components/admin/ContractOverrideList.tsx +++ b/src/components/admin/ContractOverrideList.tsx @@ -48,7 +48,7 @@ export default function ContractOverrideList() { sx={{ display: "flex", justifyContent: "space-between", width: "100%" }} > - {profile.username}({profile.student_id}) + {profile.username} From b92f17040c3dedfdb7c145cd74b5df1c96418957 Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Fri, 29 May 2026 17:36:13 -0400 Subject: [PATCH 23/24] set private problems pointer most recent commit --- src/private-problems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/private-problems b/src/private-problems index c13d814d..2f120490 160000 --- a/src/private-problems +++ b/src/private-problems @@ -1 +1 @@ -Subproject commit c13d814d60ea7d14c2c84b5a44b95e421c3405c0 +Subproject commit 2f12049087e1f5470f60aca905108ef1bf7ed5ce From b5a8ef9d79d7b01d5d47a29731fb81add011ebbe Mon Sep 17 00:00:00 2001 From: AltrosMado Date: Sat, 30 May 2026 01:42:11 -0400 Subject: [PATCH 24/24] remove unused imports --- src/components/profile/UserInfo.tsx | 2 +- src/routes/Account.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/profile/UserInfo.tsx b/src/components/profile/UserInfo.tsx index 2d39a41b..888d5c0f 100644 --- a/src/components/profile/UserInfo.tsx +++ b/src/components/profile/UserInfo.tsx @@ -4,7 +4,7 @@ import { supabase } from "../../supabaseClient"; import { Button, Stack, Typography } from "@mui/joy"; import { useOutletContext } from "react-router-dom"; import ProfileAvatar from "./ProfileAvatar"; -import { StudentRecord, UserData } from "../../types"; +import { StudentRecord } from "../../types"; // TODO: maybe get these dynamically? export const ALL_PFPS = [ diff --git a/src/routes/Account.tsx b/src/routes/Account.tsx index d14055cd..3501d900 100644 --- a/src/routes/Account.tsx +++ b/src/routes/Account.tsx @@ -11,7 +11,7 @@ import OtherStats from "../components/profile/progress/other-stats/OtherStats"; import { useOutletContext } from "react-router-dom"; import SessionReflections from "../components/profile/sessions/SessionReflections"; import useActivityTracker from "../hooks/useActivityTracker"; -import { StudentRecord, UserData } from "../types"; +import { StudentRecord } from "../types"; /** * The `Account` component handles everything related to the profile page.