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

in progress display for a section once it's in progress #756

Merged
merged 4 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions packages/common/src/major2-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type CourseError = {
type: typeof MajorValidationErrorType.Course;
requiredCourse: string;
};

export const CourseError = (c: IRequiredCourse): CourseError => ({
type: MajorValidationErrorType.Course,
requiredCourse: courseToString(c),
Expand Down
Empty file added packages/common/src/test.js
Empty file.
1 change: 0 additions & 1 deletion packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ export type Requirement2 =
| ICourseRange2
| IRequiredCourse
| Section;

/**
* Represents a requirement where X number of credits need to be completed from
* a list of courses.
Expand Down
21 changes: 20 additions & 1 deletion packages/frontend/components/Sidebar/NUPathSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ const NUPathSection: React.FC<NUPathSectionProps> = ({

if (loading) {
validationStatus = SidebarValidationStatus.Loading;
} else if (
Object.keys(nupathMap).length > 0 &&
Object.keys(nupathMap).length < 13
) {
validationStatus = SidebarValidationStatus.InProgress;
} else if (Object.keys(nupathMap).length === 13 && wiCount >= 2) {
// Sidebar is complete if all 13 nupaths have been fulfilled (including 2 writing intensives)
validationStatus = SidebarValidationStatus.Complete;
Expand Down Expand Up @@ -105,11 +110,15 @@ const NUPathSection: React.FC<NUPathSectionProps> = ({
? green
: validationStatus === SidebarValidationStatus.Error
? grey
: validationStatus === SidebarValidationStatus.InProgress
? "orange"
: "transparent"
}
borderColor={
validationStatus === SidebarValidationStatus.Complete
? green
: validationStatus === SidebarValidationStatus.InProgress
? "orange"
: grey
}
color={
Expand All @@ -130,7 +139,7 @@ const NUPathSection: React.FC<NUPathSectionProps> = ({
p="xs"
>
{/*
The following three icons appear and disappear based on opacity to allow for transitions (if they're conditionally rendered, then transitions can't occur).
The following four icons appear and disappear based on opacity to allow for transitions (if they're conditionally rendered, then transitions can't occur).
*/}
<CheckIcon
position="absolute"
Expand Down Expand Up @@ -160,6 +169,16 @@ const NUPathSection: React.FC<NUPathSectionProps> = ({
transition="opacity 0.25s ease"
transitionDelay="0.1s"
/>
<Text
opacity={
validationStatus === SidebarValidationStatus.InProgress ? 1 : 0
}
fontSize="s"
boxSize="34px"
color="white"
>
...
</Text>
</Box>
<Text color="primary.blue.dark.main" mt="0" fontSize="sm">
NUpath Requirements
Expand Down
26 changes: 24 additions & 2 deletions packages/frontend/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export enum SidebarValidationStatus {
Loading = "Loading",
Error = "Error",
Complete = "Complete",
InProgress = "InProgress",
}

export const COOP_BLOCK: ScheduleCourse2<string> = {
Expand Down Expand Up @@ -106,6 +107,7 @@ const Sidebar: React.FC<SidebarProps> = memo(
concentration: selectedPlan.concentration,
requestNumber: currentRequestNum,
};

workerRef.current?.postMessage(validationInfo);
};

Expand Down Expand Up @@ -188,8 +190,17 @@ const Sidebar: React.FC<SidebarProps> = memo(
let concentrationValidationStatus = SidebarValidationStatus.Complete;
if (validationStatus === undefined) {
concentrationValidationStatus = SidebarValidationStatus.Loading;
} else if (concentrationValidationError) {
} else if (
concentrationValidationError &&
concentrationValidationError.type === "AND" &&
concentrationValidationError.error.type === "AND_UNSAT_CHILD" &&
concentrationValidationError.error.childErrors[0].type === "SECTION" &&
concentrationValidationError.error.childErrors[0]
.maxPossibleChildCount === 0
) {
concentrationValidationStatus = SidebarValidationStatus.Error;
} else {
concentrationValidationStatus = SidebarValidationStatus.InProgress;
}

const creditsTaken = totalCreditsInSchedule(selectedPlan.schedule);
Expand All @@ -215,10 +226,21 @@ const Sidebar: React.FC<SidebarProps> = memo(
getSectionError(index, validationStatus);

let sectionValidationStatus = SidebarValidationStatus.Complete;

if (validationStatus === undefined) {
sectionValidationStatus = SidebarValidationStatus.Loading;
} else if (sectionValidationError) {
} else if (
sectionValidationError &&
sectionValidationError.type === "SECTION" &&
sectionValidationError.maxPossibleChildCount === 0
) {
sectionValidationStatus = SidebarValidationStatus.Error;
} else if (
sectionValidationError &&
sectionValidationError.type === "SECTION" &&
sectionValidationError.maxPossibleChildCount > 0
) {
sectionValidationStatus = SidebarValidationStatus.InProgress;
}

return (
Expand Down
22 changes: 19 additions & 3 deletions packages/frontend/components/Sidebar/SidebarSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SmallCloseIcon,
WarningTwoIcon,
} from "@chakra-ui/icons";

import { Box, Flex, Spinner, Stack, Text } from "@chakra-ui/react";
import { ScheduleCourse2, Section } from "@graduate/common";
import { useState } from "react";
Expand Down Expand Up @@ -85,11 +86,15 @@ const SidebarSection: React.FC<SidebarSectionProps> = ({
? green
: validationStatus === SidebarValidationStatus.Error
? grey
: validationStatus === SidebarValidationStatus.InProgress
? "orange"
: "transparent"
}
borderColor={
validationStatus === SidebarValidationStatus.Complete
? green
: validationStatus === SidebarValidationStatus.InProgress
? "orange"
: grey
}
color={
Expand All @@ -101,16 +106,17 @@ const SidebarSection: React.FC<SidebarSectionProps> = ({
width="18px"
height="18px"
display="flex"
transition="background 0.25s ease, color 0.25s ease, border 0.25s ease"
transitionDelay="0.1s"
alignItems="center"
justifyContent="center"
transition="background 0.25s ease, color 0.25s ease, border 0.25s ease"
transitionDelay="0.1s"
borderRadius="2xl"
mt="4xs"
p="xs"
position="relative"
>
{/*
The following three icons appear and disappear based on opacity to allow for transitions (if they're conditionally rendered, then transitions can't occur).
The following four icons appear and disappear based on opacity to allow for transitions (if they're conditionally rendered, then transitions can't occur).
*/}
<CheckIcon
position="absolute"
Expand Down Expand Up @@ -140,6 +146,16 @@ const SidebarSection: React.FC<SidebarSectionProps> = ({
transition="opacity 0.25s ease"
transitionDelay="0.1s"
/>
<Text
opacity={
validationStatus === SidebarValidationStatus.InProgress ? 1 : 0
}
fontSize="s"
boxSize="34px"
color="white"
>
...
</Text>
</Box>
<Text color="primary.blue.dark.main" mt="0" fontSize="sm">
{section.title}
Expand Down
Loading