Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
auhc99 committed Mar 15, 2024
1 parent 333ffb3 commit b4adde0
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 115 deletions.
2 changes: 1 addition & 1 deletion backend/controllers/teamController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getTeamsByCourse = async (req: Request, res: Response) => {
console.error('Error fetching teams:', error);
res.status(500).json({ error: 'Failed to fetch teams' });
}
}
};

export const deleteTeam = async (req: Request, res: Response) => {
const teamId = req.params.id;
Expand Down
2 changes: 1 addition & 1 deletion backend/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ export const getUserByHandle = async (req: Request, res: Response) => {
} catch (error) {
res.status(500).json({ error: 'Failed to fetch user by git handle' });
}
}
};
16 changes: 8 additions & 8 deletions backend/jobs/githubJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ const getCourseData = async (
if (process.env.NEW_FILTER) {
const teamMembers = await getTeamMembers(repo.id);
if (teamMembers) {
commits.data = commits.data.filter(commit =>
commit.author && teamMembers.has(commit.author.login)
commits.data = commits.data.filter(
commit => commit.author && teamMembers.has(commit.author.login)
);
issues.data = issues.data.filter(issue =>
issue.user && teamMembers.has(issue.user.login)
issues.data = issues.data.filter(
issue => issue.user && teamMembers.has(issue.user.login)
);
prs.data = prs.data.filter(pr =>
pr.user && teamMembers.has(pr.user.login)
prs.data = prs.data.filter(
pr => pr.user && teamMembers.has(pr.user.login)
);
contributors.data = contributors.data.filter(contributor =>
contributor.login && teamMembers.has(contributor.login)
contributors.data = contributors.data.filter(
contributor => contributor.login && teamMembers.has(contributor.login)
);
}
}
Expand Down
13 changes: 7 additions & 6 deletions backend/services/teamSetService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import TeamModel, { Team } from '../models/Team';
import TeamSetModel, { TeamSet } from '../models/TeamSet';
import { BadRequestError, NotFoundError } from './errors';

export const getTeamSetsByCourseId = async (courseId: string) => await TeamSetModel.find({ course: courseId }).populate<{ teams: Team[] }>({
path: 'teams',
populate: {
path: 'members',
},
});
export const getTeamSetsByCourseId = async (courseId: string) =>
await TeamSetModel.find({ course: courseId }).populate<{ teams: Team[] }>({
path: 'teams',
populate: {
path: 'members',
},
});

export const deleteTeamSetById = async (teamSetId: string) => {
const teamSet = await TeamSetModel.findById(teamSetId);
Expand Down
2 changes: 1 addition & 1 deletion backend/services/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ export const getUserByGitHandle = async (gitHandle: string) => {
};

return profile;
}
};
2 changes: 1 addition & 1 deletion multi-git-dashboard/src/components/GitHandle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ProfileGetter } from './views/Overview';

export interface GitHandleProps {
gitHandle: string;
profileGetter: ProfileGetter
profileGetter: ProfileGetter;
}

export const GitHandle: React.FC<GitHandleProps> = (props: GitHandleProps) => (
Expand Down
60 changes: 39 additions & 21 deletions multi-git-dashboard/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { Center, Stack, Title, Tooltip, UnstyledButton, rem } from '@mantine/core';
import {
Center,
Stack,
Title,
Tooltip,
UnstyledButton,
rem,
} from '@mantine/core';
import {
IconGitBranch,
IconHelp,
IconHome2,
IconListDetails,
IconLogout,
IconSettings2,
IconUserCircle
IconUserCircle,
} from '@tabler/icons-react';
import { signOut, useSession } from 'next-auth/react';
import { useRouter } from 'next/router';
Expand All @@ -21,9 +28,20 @@ interface NavbarLinkProps {
onClick: (event: React.MouseEvent) => void;
}

const NavbarLink = ({ icon: Icon, label, active, disabled, onClick }: NavbarLinkProps) => (
const NavbarLink = ({
icon: Icon,
label,
active,
disabled,
onClick,
}: NavbarLinkProps) => (
<Tooltip label={label} position="right" transitionProps={{ duration: 0 }}>
<UnstyledButton onClick={onClick} style={disabled ? { cursor: 'default' } : undefined} className={classes.link} data-active={active || undefined}>
<UnstyledButton
onClick={onClick}
style={disabled ? { cursor: 'default' } : undefined}
className={classes.link}
data-active={active || undefined}
>
<Icon style={{ width: rem(20), height: rem(20) }} stroke={1.5} />
</UnstyledButton>
</Tooltip>
Expand Down Expand Up @@ -102,7 +120,7 @@ const Navbar: React.FC = () => {
icon={item.icon}
label={item.label}
active={item.label === activeMainTab}
onClick={(event) => {
onClick={event => {
event.preventDefault();
if (courseId) {
logSessionTime(activeCourseTab, true);
Expand Down Expand Up @@ -207,21 +225,23 @@ const Navbar: React.FC = () => {
</Center>

<div className={classes.navbarMain}>
<Stack justify='center' gap={0}>
<Stack justify="center" gap={0}>
{mainLinks}
</Stack>
</div>

<Stack justify='center' gap={0}>
<Stack justify="center" gap={0}>
<NavbarLink
onClick={() => { }}
onClick={() => {}}
icon={IconUserCircle}
label={`Hello, ${session && session.user ? session.user.name : 'user'}`}
disabled
/>

<NavbarLink
onClick={() => window.open('https://forms.gle/41KcH8gFh3uDfzQGA', '_blank')}
onClick={() =>
window.open('https://forms.gle/41KcH8gFh3uDfzQGA', '_blank')
}
icon={IconHelp}
label="Submit issue / feature"
/>
Expand All @@ -233,18 +253,16 @@ const Navbar: React.FC = () => {
/>
</Stack>
</nav>
{
isCourseRoute && courseId && (
<nav className={classes.courseNavbar}>
<div className={classes.navbarMain}>
<Title order={3} className={classes.title}>
{courseCode}
</Title>
{courseLinks}
</div>
</nav>
)
}
{isCourseRoute && courseId && (
<nav className={classes.courseNavbar}>
<div className={classes.navbarMain}>
<Title order={3} className={classes.title}>
{courseCode}
</Title>
{courseLinks}
</div>
</nav>
)}
</div>
);
};
Expand Down
29 changes: 22 additions & 7 deletions multi-git-dashboard/src/components/cards/OverviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ export const OverviewCard: React.FC<OverviewProps> = ({
team,
teamData,
teamDatas,
profileGetter
profileGetter,
}) => {
const calculateCurrentWeek = () => {
const currentWeek = dayjs().diff(START_DATE, 'week');
return currentWeek >= BREAK_START_WEEK ? currentWeek + BREAK_DURATION_WEEKS : currentWeek;
return currentWeek >= BREAK_START_WEEK
? currentWeek + BREAK_DURATION_WEEKS
: currentWeek;
};
const totalWeeks = calculateCurrentWeek();

const [selectedWeekRange, setSelectedWeekRange] = useState<[number, number]>([0, totalWeeks]);
const [selectedWeekRange, setSelectedWeekRange] = useState<[number, number]>([
0,
totalWeeks,
]);

return (
<Stack>
Expand All @@ -45,16 +50,26 @@ export const OverviewCard: React.FC<OverviewProps> = ({
max={totalWeeks}
minRange={1}
onChange={setSelectedWeekRange}
label={(value) => `Week ${value + 1}`}
label={value => `Week ${value + 1}`}
marks={Array.from({ length: totalWeeks + 1 }, (_, i) => ({
value: i,
label: `Week ${i + 1}`
label: `Week ${i + 1}`,
}))}
mx={20}
mb={20}
/>
<Analytics team={team} teamData={teamData} teamDatas={teamDatas} selectedWeekRange={selectedWeekRange} />
<PR team={team} teamData={teamData} selectedWeekRange={selectedWeekRange} profileGetter={profileGetter} />
<Analytics
team={team}
teamData={teamData}
teamDatas={teamDatas}
selectedWeekRange={selectedWeekRange}
/>
<PR
team={team}
teamData={teamData}
selectedWeekRange={selectedWeekRange}
profileGetter={profileGetter}
/>
</Stack>
);
};
Expand Down
18 changes: 11 additions & 7 deletions multi-git-dashboard/src/components/cards/ProfileCard.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { capitalize } from '@/lib/utils';
import {
Box, Loader,
Text
} from '@mantine/core';
import { Box, Loader, Text } from '@mantine/core';
import { Profile } from '@shared/types/Profile';
import { useEffect, useState } from 'react';
import { GitHandleProps } from '../GitHandle';

interface ProfileCardProps extends GitHandleProps { }
interface ProfileCardProps extends GitHandleProps {}

export const ProfileCard: React.FC<ProfileCardProps> = ({ gitHandle, profileGetter }) => {
export const ProfileCard: React.FC<ProfileCardProps> = ({
gitHandle,
profileGetter,
}) => {
const [loading, setLoading] = useState(true);
const [error, setError] = useState('');
const [profile, setProfile] = useState<Profile>({} as Profile);
Expand All @@ -33,5 +33,9 @@ export const ProfileCard: React.FC<ProfileCardProps> = ({ gitHandle, profileGett
if (loading) return <Loader />;
if (error) return <Box>{error}</Box>;

return Object.entries(profile).map(([key, value]) => <Text key={key}>{capitalize(key)}: {value}</Text>);
return Object.entries(profile).map(([key, value]) => (
<Text key={key}>
{capitalize(key)}: {value}
</Text>
));
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,32 @@ export interface AnalyticsProps {
}

// TODO: Migrate Recharts -> Mantine Charts
const Analytics: React.FC<AnalyticsProps> = ({ team, teamData, teamDatas, selectedWeekRange }) => {
const Analytics: React.FC<AnalyticsProps> = ({
team,
teamData,
teamDatas,
selectedWeekRange,
}) => {
const [embla, setEmbla] = useState<Embla | null>(null);

const charts = {
'Breakdown': OverallActivity,
Breakdown: OverallActivity,
'Weekly Activity': WeeklyContributions,
'Individual Activity': IndividualAnalytics
'Individual Activity': IndividualAnalytics,
};

const slides = Object.entries(charts).map(([componentName, Component]) => (
<Carousel.Slide key={componentName}>
<Stack>
<Center><Title order={3}>{componentName}</Title></Center>
<Component team={team} teamData={teamData} teamDatas={teamDatas} selectedWeekRange={selectedWeekRange} />
<Center>
<Title order={3}>{componentName}</Title>
</Center>
<Component
team={team}
teamData={teamData}
teamDatas={teamDatas}
selectedWeekRange={selectedWeekRange}
/>
</Stack>
</Carousel.Slide>
));
Expand Down
Loading

0 comments on commit b4adde0

Please sign in to comment.