diff --git a/packages/frontend/components/Sidebar/Sidebar.tsx b/packages/frontend/components/Sidebar/Sidebar.tsx index 4058dbdd..af5d7459 100644 --- a/packages/frontend/components/Sidebar/Sidebar.tsx +++ b/packages/frontend/components/Sidebar/Sidebar.tsx @@ -220,6 +220,7 @@ const Sidebar: React.FC = memo( creditsToTake={major.totalCreditsRequired} renderCoopBlock renderBetaMajorBlock={major.metadata?.verified !== true} + planId={selectedPlan.id} > {courseData && ( <> @@ -284,6 +285,7 @@ export const NoMajorSidebar: React.FC = ({ creditsTaken={creditsTaken} renderCoopBlock renderDropdownWarning={false} + planId={selectedPlan.id} > @@ -336,6 +338,7 @@ interface SidebarContainerProps { renderCoopBlock?: boolean; renderBetaMajorBlock?: boolean; renderDropdownWarning?: boolean; + planId: string | number; } export const NoPlanSidebar: React.FC = () => { @@ -350,13 +353,26 @@ const SidebarContainer: React.FC> = ({ renderCoopBlock, renderBetaMajorBlock, renderDropdownWarning = true, + planId, children, }) => { const [notes, setNotes] = useState(""); const handleNewNotes = (e: React.ChangeEvent) => { setNotes(e.target.value); + // have a notes object plan_id (number | string) -> note (string) + localStorage.setItem(planId.toString(), e.target.value); console.log("New notes: ", e.target.value); }; + + useEffect(() => { + if (!planId) return; + + const storedNotes = localStorage.getItem(planId.toString()); + if (storedNotes) { + setNotes(storedNotes); + } + }, [planId]); + return ( @@ -415,6 +431,7 @@ const SidebarContainer: React.FC> = ({ /> )} + {children} @@ -426,13 +443,12 @@ const SidebarContainer: React.FC> = ({ fontSize="sm" fontWeight="bold" > - Sandbox Area + Sandbox Area {planId} Notes - {/*