Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added link to all draggable courses #754

Merged
merged 9 commits into from
Oct 18, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Text,
VStack,
} from "@chakra-ui/react";
import { NUPathEnum, ScheduleCourse2 } from "@graduate/common";
import { NUPathEnum, ScheduleCourse2, SeasonEnum } from "@graduate/common";
import { useState } from "react";
import { useSearchCourses } from "../../hooks";
import {
Expand All @@ -33,6 +33,7 @@ import { SecondaryButton } from "../Button";
interface AddCourseModalProps {
isOpen: boolean;
catalogYear?: number;
season: SeasonEnum;
addTo: string;
/** Function to close the modal UX, returned from the useDisclosure chakra hook */
closeModalDisplay: () => void;
Expand All @@ -50,6 +51,7 @@ interface AddCourseModalProps {
export const AddCourseModal: React.FC<AddCourseModalProps> = ({
isOpen,
catalogYear,
season,
addTo,
closeModalDisplay,
isCourseAlreadyAdded,
Expand Down Expand Up @@ -227,6 +229,8 @@ export const AddCourseModal: React.FC<AddCourseModalProps> = ({
(course) => (
<SearchResult
key={getCourseDisplayString(course)}
year={catalogYear}
season={season}
course={course}
addSelectedCourse={addSelectedCourse}
isResultAlreadyAdded={isCourseAlreadyAdded(course)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const NUPathLabel: React.FC<NuPathLabelProps> = ({
}

return (
<Flex justifyContent="end" gap="2xs" flex="1" ml="xs">
<Flex justifyContent="end" gap="2xs" ml="xs">
{nuPaths.map((nuPath) => (
<Flex
key={nuPaths.indexOf(nuPath)}
Expand Down
29 changes: 27 additions & 2 deletions packages/frontend/components/AddCourseModal/SearchResult.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { AddIcon } from "@chakra-ui/icons";
import { AddIcon, QuestionOutlineIcon } from "@chakra-ui/icons";
import { Box, Flex, IconButton, Text } from "@chakra-ui/react";
import { NUPathEnum, ScheduleCourse2 } from "@graduate/common";
import { NUPathEnum, ScheduleCourse2, SeasonEnum } from "@graduate/common";
import { getCourseDisplayString } from "../../utils/";
import { GraduateToolTip } from "../GraduateTooltip";
import { NUPathLabel } from "./NUPathLabel";
import { getSearchLink } from "../ScheduleCourse";

interface SearchResultProps {
course: ScheduleCourse2<null>;
year: number | undefined;
season: SeasonEnum;
addSelectedCourse: (course: ScheduleCourse2<null>) => Promise<void>;
isResultAlreadySelected: boolean;
isResultAlreadyAdded: boolean;
Expand All @@ -17,6 +20,8 @@ interface SearchResultProps {

export const SearchResult: React.FC<SearchResultProps> = ({
course,
year,
season,
addSelectedCourse,
isResultAlreadySelected,
isResultAlreadyAdded,
Expand Down Expand Up @@ -48,6 +53,26 @@ export const SearchResult: React.FC<SearchResultProps> = ({
{course.name}
</Text>
</Box>
<Box ml="auto" mr="sm"></Box>
<a
href={getSearchLink(year ?? 2022, season, course)}
target="_blank"
rel="noreferrer"
>
<IconButton
aria-label="Add class"
icon={<QuestionOutlineIcon />}
color="primary.blue.light.main"
border={0}
colorScheme="primary.blue.light.main"
isRound
size="sm"
pr={1}
isLoading={isSelectingAnotherCourse}
isDisabled={isResultAlreadyAdded || isResultAlreadySelected}
alignSelf="center"
/>
</a>
<NUPathLabel
nuPaths={course.nupaths ? course.nupaths : []}
filteredPaths={filteredPaths}
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/components/Plan/ScheduleTerm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const ScheduleTerm: React.FC<ScheduleTermProps> = ({
))}
<AddCourseButton onOpen={onOpen} />
<AddCourseModal
season={scheduleTerm.season}
isOpen={isOpen}
catalogYear={catalogYear}
addTo={getSeasonDisplayWord(scheduleTerm.season)}
Expand Down
11 changes: 10 additions & 1 deletion packages/frontend/components/Plan/TransferCourses.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChevronDownIcon, ChevronUpIcon } from "@chakra-ui/icons";
import { Flex, Grid, Stack, Text, useDisclosure } from "@chakra-ui/react";
import { API } from "@graduate/api-client";
import { ScheduleCourse2, StudentModel } from "@graduate/common";
import { ScheduleCourse2, SeasonEnum, StudentModel } from "@graduate/common";
import { useRouter } from "next/router";
import { fetchStudentAndPrepareForDnd, useStudentWithPlans } from "../../hooks";
import {
Expand All @@ -19,11 +19,13 @@ import { IsGuestContext } from "../../pages/_app";
interface TransferCoursesToggleProps {
isExpanded: boolean;
toggleExpanded: () => void;
year: number;
}

export const TransferCourses: React.FC<TransferCoursesToggleProps> = ({
isExpanded,
toggleExpanded,
year,
}) => {
const { student, isLoading, mutateStudent } = useStudentWithPlans();
const router = useRouter();
Expand Down Expand Up @@ -86,11 +88,13 @@ export const TransferCourses: React.FC<TransferCoursesToggleProps> = ({
isExpanded={isExpanded}
toggleExpanded={toggleExpanded}
totalTransferCredits={totalTransferCredits}
year={year}
/>
{isExpanded && (
<TransferCoursesBody
transferCourses={transferCourses}
updateTransferCourses={updateTransferCourses}
year={year}
/>
)}
</Flex>
Expand All @@ -102,11 +106,13 @@ interface TransferCoursesBodyProps {
updateTransferCourses: (
updateTransferCourses: ScheduleCourse2<null>[]
) => void;
year: number;
}

const TransferCoursesBody: React.FC<TransferCoursesBodyProps> = ({
transferCourses,
updateTransferCourses,
year,
}) => {
const { isOpen, onOpen, onClose } = useDisclosure();

Expand Down Expand Up @@ -145,6 +151,9 @@ const TransferCoursesBody: React.FC<TransferCoursesBodyProps> = ({
))}
<AddCourseButton onOpen={onOpen} />
<AddCourseModal
//is season really necessary? i have placeholder here
season={SeasonEnum.FL}
catalogYear={year}
isOpen={isOpen}
addTo="Transfer Courses"
closeModalDisplay={onClose}
Expand Down
31 changes: 31 additions & 0 deletions packages/frontend/components/ScheduleCourse/ScheduleCourse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
INEUReqError,
IRequiredCourse,
ScheduleCourse2,
SeasonEnum,
} from "@graduate/common";
import { forwardRef, PropsWithChildren, useEffect, useState } from "react";
import {
Expand Down Expand Up @@ -383,3 +384,33 @@ const ScheduleCourseDraggedContents: React.FC<
const ScheduleCourseSpacer: React.FC = () => {
return <div style={{ width: "32px", height: "32px", flexShrink: 0 }}></div>;
};

export function getSearchLink(
catalogYear: number,
szn: SeasonEnum,
course: ScheduleCourse2<unknown>
): string {
let sznInt = -1;
switch (szn) {
case SeasonEnum.FL:
sznInt = 1;
break;
case SeasonEnum.SP:
sznInt = 3;
break;
case SeasonEnum.S1:
sznInt = 4;
break;
case SeasonEnum.SM:
sznInt = 5;
break;
case SeasonEnum.S2:
sznInt = 6;
break;
default:
sznInt = 1;
}
return `https://searchneu.com/NEU/${catalogYear}${sznInt}${0}/search/${
course.name
}`;
}
1 change: 1 addition & 0 deletions packages/frontend/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ const HomePage: NextPage = () => {
/>
<Divider borderColor="neutral.200" borderWidth={1} />
<TransferCourses
year={selectedPlan.catalogYear}
isExpanded={isTransferCoursesExpanded}
toggleExpanded={() =>
setIsTransferCoursesExpanded(!isTransferCoursesExpanded)
Expand Down
Loading