Skip to content

Commit

Permalink
started edit plan model
Browse files Browse the repository at this point in the history
TODO MAKE CURRENT MINOR SHOW UP IN EDIT DROPDOWN
  • Loading branch information
hellolol2016 committed Dec 3, 2024
1 parent 6393f2c commit 902beb3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
31 changes: 16 additions & 15 deletions packages/frontend/components/Plan/AddPlanModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,14 @@ export const AddPlanModal: React.FC<AddPlanModalProps> = ({
const onCloseAddPlanModal = () => {
reset();
setIsNoMajorSelected(false);
setIsNoMinorSelected(false);
onCloseDisplay();
};

const title = watch("name");
const catalogYear = watch("catalogYear");
const majorName = watch("major");
const minorName = watch("minor");
//const minorName = watch("minor");
const concentration = watch("concentration");
const agreeToBetaMajor = watch("agreeToBetaMajor");

Expand Down Expand Up @@ -324,20 +325,6 @@ export const AddPlanModal: React.FC<AddPlanModalProps> = ({
isSearchable
useFuzzySearch
/>
<PlanSelect
label="Minor"
placeholder="Select a Minor"
name="minor"
control={control}
options={extractSupportedMinorOptions(
catalogYear,
supportedMinorsData
)}
//rules={{ required: "Minor is required." }}
isDisabled={!catalogYear}
isSearchable
useFuzzySearch
/>
<Flex align="center">
<Text size="xs" mr="xs">
Can&apos;t find your major / minor?
Expand All @@ -362,6 +349,20 @@ export const AddPlanModal: React.FC<AddPlanModalProps> = ({
useFuzzySearch
/>
)}
<PlanSelect
label="Minor"
placeholder="Select a Minor"
name="minor"
control={control}
options={extractSupportedMinorOptions(
catalogYear,
supportedMinorsData
)}
//rules={{ required: "Minor is required." }}
isDisabled={!catalogYear}
isSearchable
useFuzzySearch
/>
{majorName && !isValidatedMajor && (
<Flex alignItems="center">
<Checkbox
Expand Down
24 changes: 24 additions & 0 deletions packages/frontend/components/Plan/EditPlanModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import {
USE_STUDENT_WITH_PLANS_SWR_KEY,
useStudentWithPlans,
useSupportedMajors,
useSupportedMinors,
} from "../../hooks";
import {
extractSupportedMajorOptions,
extractSupportedMinorOptions,
extractSupportedMajorYears,
handleApiClientError,
noLeadOrTrailWhitespacePattern,
Expand All @@ -49,6 +51,7 @@ type EditPlanModalProps = {
type EditPlanInput = {
name: string;
major: string;
minor?: string;
catalogYear: number;
concentration: string;
agreeToBetaMajor: boolean;
Expand All @@ -57,6 +60,8 @@ type EditPlanInput = {
export const EditPlanModal: React.FC<EditPlanModalProps> = ({ plan }) => {
const { supportedMajorsData, error: supportedMajorsError } =
useSupportedMajors();
const { supportedMinorsData, error: supportedMinorsError } =
useSupportedMinors();
const { mutate } = useSWRConfig();
const router = useRouter();
const { onOpen, onClose: onCloseDisplay, isOpen } = useDisclosure();
Expand Down Expand Up @@ -86,6 +91,7 @@ export const EditPlanModal: React.FC<EditPlanModalProps> = ({ plan }) => {
name: plan.name,
catalogYear: plan.catalogYear,
major: plan.major,
minor: plan.minor,
concentration: plan.concentration,
});

Expand All @@ -103,6 +109,9 @@ export const EditPlanModal: React.FC<EditPlanModalProps> = ({ plan }) => {
if (supportedMajorsError) {
handleApiClientError(supportedMajorsError, router);
}
if (supportedMinorsError) {
handleApiClientError(supportedMinorsError, router);
}

if (!student) {
return <></>;
Expand Down Expand Up @@ -323,6 +332,21 @@ export const EditPlanModal: React.FC<EditPlanModalProps> = ({ plan }) => {
useFuzzySearch
/>
)}
<PlanSelect
label="Minor"
placeholder="Select a Minor"
name="minor"
control={control}
options={extractSupportedMinorOptions(
catalogYear,
supportedMinorsData
)}
//TODO:::: HOW TO HAVE DFAULT VALUEEEEEEEEEEE :DDDDD
//rules={{ required: "Minor is required." }}
isDisabled={!catalogYear}
isSearchable
useFuzzySearch
/>
{majorName && !isValidatedMajor && (
<Flex alignItems="center">
<Checkbox
Expand Down

0 comments on commit 902beb3

Please sign in to comment.