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

Add a column for the judgement state -- whether a team has been judged #467

Merged
merged 4 commits into from
Apr 16, 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
16 changes: 15 additions & 1 deletion components/judges/TeamSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ function withCheckMark(value: string) {
</Row>
);
}

const optionComparator = (input: string, option: string) => {
let searchPosition = 0;
const cin = input.toLowerCase();
const opt = option.toLowerCase();
for (let i = 0; i < opt.length; ++i) {
if (opt[i] === cin[searchPosition]) ++searchPosition;
else break;
}
return searchPosition === input.length;
};

export default function TeamSelect(props: TeamSelectProps) {
const { teamsData, currentTeamID, handleChange } = props;
const { data: session } = useSession();
Expand All @@ -34,10 +46,12 @@ export default function TeamSelect(props: TeamSelectProps) {
Team:
</strong>
<Select
showSearch
value={currentTeamID ? currentTeamID : 'Select a team'}
style={{ width: 300, maxWidth: '60vw' }}
onChange={handleChange}
allowClear>
allowClear
filterOption={(input, option) => optionComparator(input, String(option?.children))}>
{session?.userType === 'JUDGE' && (
<OptGroup label="My Teams">
{teamsData
Expand Down
12 changes: 10 additions & 2 deletions components/judges/schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export function JudgeSchedule({ data, cutoffIndex, handleChange }: ScheduleProps
title: 'Project',
dataIndex: 'project',
key: 'project',
width: '30%',
width: '25%',
render: ({ name, link }: { name: string; link: URL }) => (
<>
<td>{name}</td>
Expand All @@ -223,7 +223,7 @@ export function JudgeSchedule({ data, cutoffIndex, handleChange }: ScheduleProps
title: 'Team Members',
dataIndex: 'teamMembers',
key: 'teamMembers',
width: '30%',
width: '25%',
render: (members: User[]) => members.map(member => <Tag key={member.id}>{member.name}</Tag>),
},
{
Expand All @@ -244,6 +244,13 @@ export function JudgeSchedule({ data, cutoffIndex, handleChange }: ScheduleProps
</Button>
),
},
{
title: 'Judgement State',
dataIndex: 'scores',
key: 'scores',
width: '10%',
render: (scores: []) => <Tag>{scores.length ? 'Judged' : 'Without Judgement'}</Tag>,
},
];
const dataSource = data.slice(showPast ? 0 : cutoffIndex).map(item => {
return {
Expand All @@ -253,6 +260,7 @@ export function JudgeSchedule({ data, cutoffIndex, handleChange }: ScheduleProps
teamMembers: item.team.members,
judge: item.judge,
teamId: item.team._id,
scores: item.team.scores,
};
});

Expand Down
Loading