Skip to content

Commit

Permalink
Created Tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
ShireenKumar committed Jan 19, 2025
1 parent a722aa2 commit f0fa69b
Showing 1 changed file with 74 additions and 57 deletions.
131 changes: 74 additions & 57 deletions packages/frontend/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Link, Stack, Text } from "@chakra-ui/react";
import { Tabs, TabList, Tab, TabPanels, TabPanel, Box } from "@chakra-ui/react";

Check failure on line 2 in packages/frontend/components/Sidebar/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / Run linting for all packages

'Box' is defined but never used. Allowed unused vars must match /^_/u
import {
MajorValidationError,
MajorValidationResult,
Expand Down Expand Up @@ -238,69 +239,85 @@ const Sidebar: React.FC<SidebarProps> = memo(
dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-nupath`}
loading={isCoursesLoading}
/>
{major.requirementSections.map((section, index) => {
const sectionValidationError: MajorValidationError | undefined =
getSectionError(index, validationStatus);

let sectionValidationStatus = SidebarValidationStatus.Complete;

if (validationStatus === undefined) {
sectionValidationStatus = SidebarValidationStatus.Loading;
} else if (
sectionValidationError &&
sectionValidationError.type === "SECTION" &&
sectionValidationError.maxPossibleChildCount === 0
) {
sectionValidationStatus = SidebarValidationStatus.Error;
} else if (
sectionValidationError &&
sectionValidationError.type === "SECTION" &&
sectionValidationError.maxPossibleChildCount > 0
) {
sectionValidationStatus = SidebarValidationStatus.InProgress;
}
<Tabs>
<TabList>
<Tab>Major</Tab>
<Tab>Minor(s)</Tab>
</TabList>
<TabPanels>
<TabPanel>
{major.requirementSections.map((section, index) => {
const sectionValidationError:
| MajorValidationError
| undefined = getSectionError(index, validationStatus);

let sectionValidationStatus =
SidebarValidationStatus.Complete;

if (validationStatus === undefined) {
sectionValidationStatus = SidebarValidationStatus.Loading;
} 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 (
<SidebarSection
key={section.title}
section={section}
validationStatus={sectionValidationStatus}
courseData={courseData}
dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-${index}`}
loading={isCoursesLoading}
coursesTaken={coursesTaken}
/>
);
})}

{concentration && (
<SidebarSection
validationStatus={concentrationValidationStatus}
section={concentration}
courseData={courseData}
dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-concentration`}
coursesTaken={[]}
/>
)}

{minorResponse.minor && (
<>
<Text>Requirements for {minorResponse.minor.name}</Text>
{minorResponse.minor?.requirementSections.map(
(section, index) => {
return (
<SidebarSection
key={index}
key={section.title}
section={section}
validationStatus={sectionValidationStatus}
courseData={courseData}
dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-minor`}
validationStatus={SidebarValidationStatus.InProgress}
></SidebarSection>
dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-${index}`}
loading={isCoursesLoading}
coursesTaken={coursesTaken}
/>
);
}
)}
</>
)}
})}

{concentration && (
<SidebarSection
validationStatus={concentrationValidationStatus}
section={concentration}
courseData={courseData}
dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-concentration`}
coursesTaken={[]}
/>
)}
</TabPanel>
<TabPanel>
{minorResponse.minor && (
<>
<Text>Minor Requirments</Text>
{minorResponse.minor?.requirementSections.map(
(section, index) => {
return (
<SidebarSection
key={index}
section={section}
courseData={courseData}
dndIdPrefix={`${SIDEBAR_DND_ID_PREFIX}-minor`}
validationStatus={
SidebarValidationStatus.InProgress
}
></SidebarSection>
);
}
)}
</>
)}
</TabPanel>
</TabPanels>
</Tabs>
</>
)}
</SidebarContainer>
Expand Down

0 comments on commit f0fa69b

Please sign in to comment.