Skip to content

Commit

Permalink
feat: unable to navigate before adding people
Browse files Browse the repository at this point in the history
  • Loading branch information
wxy1203 committed Sep 26, 2024
1 parent 9d12500 commit 9f518b5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
20 changes: 17 additions & 3 deletions multi-git-dashboard/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useTutorialContext } from './tutorial/TutorialContext';
import TutorialPopover from './tutorial/TutorialPopover';
import { Accordion } from '@mantine/core';


interface NavbarLinkProps {
icon: typeof IconHome2;
label: string;
Expand Down Expand Up @@ -72,6 +73,8 @@ const Navbar: React.FC = () => {
const isCourseRoute = pathname.includes('/courses/[id]');
const courseId = isCourseRoute ? (router.query.id as string) : null;

const [peopleAdded, setPeopleAdded] = useState(false);

const [activeMainTab, setActiveMainTab] = useState('Home');
const [courseCode, setCourseCode] = useState('');

Expand Down Expand Up @@ -159,6 +162,7 @@ const Navbar: React.FC = () => {
{
link: `/courses/${courseId}`,
label: 'Overview',

},
{
link: `/courses/${courseId}/people`,
Expand All @@ -167,19 +171,24 @@ const Navbar: React.FC = () => {
{
link: `/courses/${courseId}/teams`,
label: 'Teams',
disabled: !peopleAdded,
},
{
link: `/courses/${courseId}/timeline`,
label: 'Timeline',
disabled: !peopleAdded,
},
{
link: `/courses/${courseId}/assessments`,
label: 'Assessments',
disabled: !peopleAdded,
},
{
link: `/courses/${courseId}/project-management`,
label: 'Project Management',
disabled: !peopleAdded,
},

];

const courseLinks = courseLinksData.map(item => (
Expand All @@ -195,10 +204,14 @@ const Navbar: React.FC = () => {
href={item.link}
onClick={event => {
event.preventDefault();
logSessionTime(item.label, false);
setActiveCourseTab(item.label);
router.push(item.link);
if (!item.disabled) {
logSessionTime(item.label, false);
setActiveCourseTab(item.label);
router.push(item.link);
}
}}
key={item.label}
style={item.disabled ? { cursor: 'not-allowed', opacity: 0.5 } : {}}
>
<span>{item.label}</span>
</a>
Expand Down Expand Up @@ -344,6 +357,7 @@ const Navbar: React.FC = () => {
</nav>
</TutorialPopover>
)}

</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DateUtils, getTutorialHighlightColor } from '@/lib/utils';
import { Accordion, Center } from '@mantine/core';
import { TeamData } from '@shared/types/TeamData';
import { forwardRef } from 'react';
import { forwardRef, useState } from 'react';
import OverviewCard from '../cards/OverviewCard';
import { ProfileGetter, Team } from '../views/Overview';

Expand All @@ -21,7 +21,10 @@ const OverviewAccordionItem = forwardRef<
(
{ index, teamData, team, teamDatas, dateUtils, getStudentNameByGitHandle },
ref
) => (
) => {

return (

<Accordion.Item key={teamData._id} value={teamData._id} ref={ref}>
<Accordion.Control bg={getTutorialHighlightColor(7)}>
{teamData.repoName}
Expand All @@ -41,7 +44,10 @@ const OverviewAccordionItem = forwardRef<
)}
</Accordion.Panel>
</Accordion.Item>
)

);

}
);

export default OverviewAccordionItem;
2 changes: 1 addition & 1 deletion multi-git-dashboard/src/components/views/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const Overview: React.FC<OverviewProps> = ({ courseId, dateUtils }) => {
</Container>
</Center>
);
if (status === Status.Error) return <Center>No data available</Center>;
if (status === Status.Error) return <Center>No GitHub Data Available</Center>;
if (!teams.length || !teamDatas.length)
return <Center>No teams found.</Center>;

Expand Down
4 changes: 4 additions & 0 deletions multi-git-dashboard/src/components/views/PeopleInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ interface PeopleInfoProps {
hasFacultyPermission: boolean;
accountStatusRecord: Record<string, boolean>;
onUpdate: () => void;
onPeopleAdded: () => void;
}


const PeopleInfo: React.FC<PeopleInfoProps> = ({
courseId,
faculty,
Expand All @@ -35,6 +37,7 @@ const PeopleInfo: React.FC<PeopleInfoProps> = ({
hasFacultyPermission,
accountStatusRecord,
onUpdate,
onPeopleAdded,
}) => {
const [isAddingFaculty, setIsAddingFaculty] = useState(false);
const [isAddingTA, setIsAddingTA] = useState(false);
Expand Down Expand Up @@ -110,6 +113,7 @@ const PeopleInfo: React.FC<PeopleInfoProps> = ({
onUpdate();
};


const facultyData = faculty.map(faculty => ({
identifier: faculty.identifier,
name: faculty.name,
Expand Down
8 changes: 8 additions & 0 deletions multi-git-dashboard/src/pages/courses/[id]/people/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ const PeopleListPage: React.FC = () => {
getAccountStatuses();
};

const [peopleAdded, setPeopleAdded] = useState(false);

const handlePeopleAdded = () => {
setPeopleAdded(true); // Enable other tabs when people are added
};


useEffect(() => {
if (router.isReady) {
fetchPeople();
Expand Down Expand Up @@ -98,6 +105,7 @@ const PeopleListPage: React.FC = () => {
hasFacultyPermission={permission}
accountStatusRecord={accountStatusRecord}
onUpdate={onUpdate}
onPeopleAdded={handlePeopleAdded}
/>
)}
</Container>
Expand Down

0 comments on commit 9f518b5

Please sign in to comment.