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

790 allow plans with no concentration #803

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
932274f
v1
liamcarvajal Jan 28, 2025
f7abdce
undecided validation works and is a selectable major TODO: make red t…
23langloisj Jan 30, 2025
ca8f727
added massive ahh red warning signaling you have an undecided concent…
23langloisj Jan 31, 2025
f8508b0
editing plan also has undecided as an option now
23langloisj Jan 31, 2025
9b02be2
bcrypt version update
KobeZ123 Jan 31, 2025
08092ed
good colors for missing concentration dropdown warning
23langloisj Jan 31, 2025
e9f3394
removed console logs added comments
23langloisj Feb 2, 2025
febd2cd
missing concentration message appears conditionally and abstracted co…
23langloisj Feb 2, 2025
740892d
Merge pull request #802 from sandboxnu/bcrypt-update
KobeZ123 Feb 2, 2025
8cd6018
addressing comments
liamcarvajal Feb 2, 2025
388de8e
remove comment
liamcarvajal Feb 2, 2025
8ac9630
another constant
liamcarvajal Feb 2, 2025
499a68d
more constants
liamcarvajal Feb 2, 2025
f6e43d3
added constants for undecided strings
23langloisj Feb 4, 2025
99012a6
removed undecided string everywhere and replaced with cosntants
23langloisj Feb 4, 2025
e2fe2e3
i think constants are set properly now
23langloisj Feb 5, 2025
d8f0363
fix
23langloisj Feb 5, 2025
f56972f
coop in last year, not just year 4
liamcarvajal Feb 6, 2025
4eae90f
fix
liamcarvajal Feb 6, 2025
365cee7
Merge pull request #799 from sandboxnu/lc/791
liamcarvajal Feb 9, 2025
5b7febb
changed undecided to undecided_string for clarity
23langloisj Feb 17, 2025
25176b9
Range update (fixed infinite loading) (#805)
denniwang Feb 18, 2025
00df6a3
undecided validation works and is a selectable major TODO: make red t…
23langloisj Jan 30, 2025
381cc90
added massive ahh red warning signaling you have an undecided concent…
23langloisj Jan 31, 2025
7c51eb0
editing plan also has undecided as an option now
23langloisj Jan 31, 2025
aa76a95
good colors for missing concentration dropdown warning
23langloisj Jan 31, 2025
60ba70b
removed console logs added comments
23langloisj Feb 2, 2025
8c59fc0
missing concentration message appears conditionally and abstracted co…
23langloisj Feb 2, 2025
ac10bcc
resolving merge conflict
23langloisj Feb 18, 2025
8afd28e
removed undecided string everywhere and replaced with cosntants
23langloisj Feb 4, 2025
4152b28
i think constants are set properly now
23langloisj Feb 5, 2025
f335de4
fix
23langloisj Feb 5, 2025
d318858
changed undecided to undecided_string for clarity
23langloisj Feb 17, 2025
e195a16
resolve merge plz
23langloisj Feb 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/api/src/major/major.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ export class MajorService {
return false;
}

const isValidConcentrationName = concentrations.some(
(c) => c === concentrationName
);
const isValidConcentrationName =
concentrations.includes(concentrationName) ||
concentrationName.toLowerCase() === "undecided";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should standardize how we are comparing to "undecided" vs "Undecided" string


if (!isValidConcentrationName) {
this.logger.debug(
Expand All @@ -134,10 +134,8 @@ export class MajorService {
},
MajorService.formatMajorServiceCtx("isValidConcentrationForMajor")
);

return false;
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@
],
"concentrations": {
"minOptions": 1,

"concentrationOptions": [
{
"type": "SECTION",
Expand Down
4 changes: 4 additions & 0 deletions packages/common/src/major2-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ export function getConcentrationsRequirement(
if (concentrationsRequirement.concentrationOptions.length === 0) {
return [];
}
// Allow undecided concentrations
if (inputConcentrations === "Undecided") {
return [];
}
const concentrationRequirements = [];
for (const c of selectedConcentrations) {
const found = concentrationsRequirement.concentrationOptions.find(
Expand Down
15 changes: 15 additions & 0 deletions packages/common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ export const majorOptionObjectComparator = (
return majorNameComparator(a.value.toString(), b.value.toString());
};

/**
* Converts a list of strings or numbers into a list of option objects for the
* Select component, including an "Undecided" option.
*/
export const convertToOptionObjectsIncludingUndecided = (
options: (string | number)[]
): OptionObject[] => {
const optionObjects = convertToOptionObjects(options);
optionObjects.unshift({
label: "Undecided",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can create a UNDECIDED_OPTION constant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, updated in latest push

value: "Undecided",
});
return optionObjects;
};

/**
* Converts a list of strings or numbers into a list of option objects for the
* Select component.
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/components/Plan/AddPlanModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
CreatePlanDtoWithoutSchedule,
PlanModel,
convertToOptionObjects,
convertToOptionObjectsIncludingUndecided,
} from "@graduate/common";
import { useRouter } from "next/router";
import { Dispatch, SetStateAction, useContext, useState } from "react";
Expand Down Expand Up @@ -318,7 +319,7 @@ export const AddPlanModal: React.FC<AddPlanModalProps> = ({
label="Concentrations"
name="concentration"
placeholder="Select a Concentration"
options={convertToOptionObjects(
options={convertToOptionObjectsIncludingUndecided(
majorConcentrations.concentrations
)}
control={control}
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/components/Plan/EditPlanModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
PlanModel,
UpdatePlanDto,
convertToOptionObjects,
convertToOptionObjectsIncludingUndecided,
} from "@graduate/common";
import { useRouter } from "next/router";
import { useCallback, useContext, useEffect, useState } from "react";
Expand Down Expand Up @@ -310,7 +311,7 @@ export const EditPlanModal: React.FC<EditPlanModalProps> = ({ plan }) => {
label="Concentrations"
name="concentration"
placeholder="Select a Concentration"
options={convertToOptionObjects(
options={convertToOptionObjectsIncludingUndecided(
majorConcentrations.concentrations
)}
control={control}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from "react";
import { InfoIcon } from "@chakra-ui/icons";
import {
Accordion,
AccordionItem,
AccordionButton,
AccordionIcon,
AccordionPanel,
Text,
} from "@chakra-ui/react";

const ConcentrationDropdownWarning = () => {
return (
<Accordion pb="sm" allowToggle>
<AccordionItem
borderRadius="lg"
backgroundColor="red.100"
border="1px #e63433 solid"
>
<AccordionButton>
<InfoIcon mr="xs" color="red.400" />
<Text fontWeight="semibold" textAlign="left" fontSize="md" flex="1">
Missing Concentration!
</Text>
<AccordionIcon color="red.400" />
</AccordionButton>
<AccordionPanel>
<Text fontSize="sm">
A concentration is required for this major. Go to &apos;Edit
plan&apos; and select your desired concentration from the drop-down
menu.
</Text>
</AccordionPanel>
</AccordionItem>
</Accordion>
);
};

export default ConcentrationDropdownWarning;
6 changes: 5 additions & 1 deletion packages/frontend/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ const Sidebar: React.FC<SidebarProps> = memo(
return (
<SidebarContainer
title={major.name}
subtitle={selectedPlan.concentration}
subtitle={
selectedPlan.concentration === "Undecided"
? "Concentration Undecided"
: selectedPlan.concentration
}
creditsTaken={creditsTaken}
creditsToTake={major.totalCreditsRequired}
renderCoopBlock
Expand Down
14 changes: 13 additions & 1 deletion packages/frontend/components/Sidebar/SidebarContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BETA_MAJOR_TOOLTIP_MSG } from "../../utils";
import { HelperToolTip } from "../Help";
import { DraggableScheduleCourse } from "../ScheduleCourse";
import DropdownWarning from "./DropdownWarning";
import ConcentrationDropdownWarning from "./ConcentrationDropdownWarning";
import { COOP_BLOCK } from "./Sidebar";
import { SandboxArea } from "./SandboxArea";

Expand Down Expand Up @@ -61,11 +62,22 @@ const SidebarContainer: React.FC<PropsWithChildren<SidebarContainerProps>> = ({
</Heading>
</Flex>
{subtitle && (
<Text fontSize="sm" color="primary.blue.dark.main">
<Text
fontSize="sm"
color={
subtitle === "Concentration Undecided"
? "red.500"
: "primary.blue.dark.main"
}
fontStyle={
subtitle === "Concentration Undecided" ? "italic" : "normal"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also can be a constant value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just updated

}
>
{subtitle}
</Text>
)}
</Box>
<ConcentrationDropdownWarning />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be in a conditional?

{renderDropdownWarning && <DropdownWarning />}
{creditsTaken !== undefined && (
<Flex mb="sm" alignItems="baseline" columnGap="xs">
Expand Down