Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dtemkin1 committed Jan 7, 2025
1 parent c8ba07b commit 0883f0b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/components/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ const Auth: Component<{
conflict: (conflictInfo: Conflict) => void;
resolveConflict: () => void;
}> = (props) => {
const finalProps = mergeProps({ conflictInfo: {} }, props);
const [
store,
{
Expand Down
9 changes: 4 additions & 5 deletions src/components/Road.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Semester from "~/components/Semester";
import { Accordion } from "~/components/ui/accordion";
import { IconButton } from "~/components/ui/icon-button";

import { useCourseDataContext } from "~/context/create";
import type { SimplifiedSelectedSubjects } from "~/context/types";

const Road: Component<{
Expand Down Expand Up @@ -50,13 +49,13 @@ const Road: Component<{
return (
<Accordion.RootProvider lazyMount unmountOnExit value={accordion}>
<Index each={[...Array(numSems()).keys()]}>
{(item) => (
{(index) => (
<Semester
index={item()}
index={index()}
selectedSubjects={props.selectedSubjects}
semesterSubjects={props.selectedSubjects[item()]}
semesterSubjects={props.selectedSubjects[index()]}
roadID={props.roadID}
isOpen={visibleList().includes(`${item()}`)}
isOpen={visibleList().includes(index().toString())}
/>
)}
</Index>
Expand Down
39 changes: 22 additions & 17 deletions src/components/Semester.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Semester: Component<{
const [store, { getUserYear }] = useCourseDataContext();

const baseYear = createMemo(() => {
const today = new Date(Date.now());
const today = new Date();
const currentYear = today.getFullYear();
const baseYear = today.getMonth() >= 5 ? currentYear + 1 : currentYear;
return baseYear - getUserYear();
Expand All @@ -31,7 +31,7 @@ const Semester: Component<{
"Junior",
"Senior",
"Fifth Year",
];
] as const;
if (props.index === 0) {
return "";
}
Expand All @@ -46,24 +46,29 @@ const Semester: Component<{
const semesterType = createMemo(() => {
return props.index === 0
? "Prior Credit"
: ["Fall", "IAP", "Spring"][(props.index - 1) % 3];
: (["Fall", "IAP", "Spring"] as const)[(props.index - 1) % 3];
});
const semesterYearRendered = createMemo(() => {
return props.index > 0 && semesterYear()
? `'${semesterYear().toString().substring(2)}`
: "";
});

return (
<Show when={!store.hideIAP || semesterType() !== "IAP"}>
<Accordion.Item value={props.index.toString()}>
<Accordion.ItemTrigger>
{semesterYearName()} {semesterType()}{" "}
{props.index > 0 ? `'${semesterYear().toString().substring(2)}` : ""}
<Accordion.ItemIndicator>
<ChevronDownIcon />
</Accordion.ItemIndicator>
</Accordion.ItemTrigger>
<Accordion.ItemContent>
Showing semester {props.index} for {props.roadID}
</Accordion.ItemContent>
</Accordion.Item>
</Show>
<Accordion.Item
value={props.index.toString()}
hidden={store.hideIAP && semesterType() === "IAP"}
>
<Accordion.ItemTrigger>
{semesterYearName()} {semesterType()} {semesterYearRendered()}
<Accordion.ItemIndicator>
<ChevronDownIcon />
</Accordion.ItemIndicator>
</Accordion.ItemTrigger>
<Accordion.ItemContent>
Showing semester {props.index} for {props.roadID}
</Accordion.ItemContent>
</Accordion.Item>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/SidebarDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const SidebarDialog: ParentComponent<Drawer.RootProps> = (props) => {
<Drawer.Positioner>
<Drawer.Content>
<Drawer.Header>
<Drawer.Title>Courseroad</Drawer.Title>
<Drawer.Title>CourseRoad</Drawer.Title>
<Drawer.Description>
<SidebarWarningText />
</Drawer.Description>
Expand Down

0 comments on commit 0883f0b

Please sign in to comment.