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

Added CV Form to HeadRef and FTA #929

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 7 additions & 1 deletion apps/backend/src/routers/api/divisions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ router.use(

router.use(
'/:divisionId/cv-forms',
roleValidator(['judge-advisor', 'tournament-manager', 'lead-judge']),
roleValidator([
'judge-advisor',
'tournament-manager',
'lead-judge',
'head-referee',
'field-manager'
]),
cvFormsRouter
);

Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/pages/lems/cv-forms/[cvFormId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Page: NextPage<Props> = ({ user, teams, division, cvForm: initialCvForm })
return (
<RoleAuthorizer
user={user}
allowedRoles={['judge-advisor', 'tournament-manager']}
allowedRoles={['judge-advisor', 'tournament-manager', 'head-referee', 'field-manager']}
onFail={() => {
router.push(`/lems/${user.role}`);
enqueueSnackbar('לא נמצאו הרשאות מתאימות.', { variant: 'error' });
Expand Down
73 changes: 53 additions & 20 deletions apps/frontend/pages/lems/field-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ import {
Team,
DivisionWithEvent,
JudgingSession,
RobotGameMatchParticipant
RobotGameMatchParticipant,
CoreValuesForm
} from '@lems/types';
import { TabPanel, TabContext } from '@mui/lab';
import { Paper, Tab, Tabs } from '@mui/material';
import Layout from '../../components/layout';
import { RoleAuthorizer } from '../../components/role-authorizer';
import CVPanel from '../../components/cv-form/cv-panel';
import { getUserAndDivision, serverSideGetRequests } from '../../lib/utils/fetch';
import { localizedRoles } from '../../localization/roles';
import { useWebsocket } from '../../hooks/use-websocket';
import { useQueryParam } from '../../hooks/use-query-param';
import { localizeDivisionTitle } from '../../localization/event';
import RematchManager from '../../components/field-manager/rematch-manager';
import StaggerEditor from '../../components/field-manager/stagger-editor/stagger-editor';
Expand All @@ -30,6 +35,7 @@ interface Props {
matches: Array<WithId<RobotGameMatch>>;
sessions: Array<WithId<JudgingSession>>;
tables: Array<WithId<RobotGameTable>>;
cvForms: Array<WithId<CoreValuesForm>>;
}

const Page: NextPage<Props> = ({
Expand All @@ -38,13 +44,16 @@ const Page: NextPage<Props> = ({
divisionState: initialDivisionState,
teams: initialTeams,
matches: initialMatches,
sessions: initialSessions
sessions: initialSessions,
cvForms: initialCvForms
}) => {
const [activeTab, setActiveTab] = useQueryParam('tab', '1');
const router = useRouter();
const [teams, setTeams] = useState<Array<WithId<Team>>>(initialTeams);
const [matches, setMatches] = useState<Array<WithId<RobotGameMatch>>>(initialMatches);
const [sessions, setSessions] = useState<Array<WithId<JudgingSession>>>(initialSessions);
const [divisionState, setDivisionState] = useState<WithId<DivisionState>>(initialDivisionState);
const [cvForms, setCvForms] = useState<Array<WithId<CoreValuesForm>>>(initialCvForms);

const handleTeamRegistered = (team: WithId<Team>) => {
setTeams(teams =>
Expand Down Expand Up @@ -190,23 +199,46 @@ const Page: NextPage<Props> = ({
connectionStatus={connectionStatus}
color={division.color}
>
<RematchManager
teams={teams}
matches={matches}
divisionState={divisionState}
sessions={sessions}
isStaggered={!!division.staggered}
onScheduleRematch={handleScheduleRematch}
/>
{division.staggered && (
<StaggerEditor
divisionState={divisionState}
matches={matches}
teams={teams}
onSwitchParticipants={handleSwitchParticipants}
onMergeMatches={handleMergeMatches}
/>
)}
<TabContext value={activeTab}>
<Paper sx={{ mt: 2 }}>
<Tabs
value={activeTab}
onChange={(_e, newValue: string) => setActiveTab(newValue)}
centered
>
<Tab label="הענקת מקצה חוזר" value="1" />
<Tab label="טפסי CV" value="2" />
</Tabs>
</Paper>
<TabPanel value="1">
<RematchManager
teams={teams}
matches={matches}
divisionState={divisionState}
sessions={sessions}
isStaggered={!!division.staggered}
onScheduleRematch={handleScheduleRematch}
/>
{division.staggered && (
<StaggerEditor
divisionState={divisionState}
matches={matches}
teams={teams}
onSwitchParticipants={handleSwitchParticipants}
onMergeMatches={handleMergeMatches}
/>
)}
</TabPanel>
<TabPanel value={'2'}>
<CVPanel
user={user}
teams={teams}
cvForms={cvForms}
division={division}
socket={socket}
/>
</TabPanel>
</TabContext>
</Layout>
</RoleAuthorizer>
);
Expand All @@ -223,7 +255,8 @@ export const getServerSideProps: GetServerSideProps = async ctx => {
divisionState: `/api/divisions/${divisionId}/state`,
matches: `/api/divisions/${divisionId}/matches`,
sessions: `/api/divisions/${divisionId}/sessions`,
tables: `/api/divisions/${divisionId}/tables`
tables: `/api/divisions/${divisionId}/tables`,
cvForms: `/api/divisions/${divisionId}/cv-forms`
},
ctx
);
Expand Down
73 changes: 57 additions & 16 deletions apps/frontend/pages/lems/head-referee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,30 @@ import { GetServerSideProps, NextPage } from 'next';
import { useRouter } from 'next/router';
import { WithId } from 'mongodb';
import { enqueueSnackbar } from 'notistack';
import { Paper, Typography } from '@mui/material';
import { Paper, Tab, Tabs, Typography } from '@mui/material';
import Grid from '@mui/material/Grid2';
import { TabPanel, TabContext } from '@mui/lab';
import {
SafeUser,
Scoresheet,
RobotGameMatch,
RobotGameTable,
DivisionState,
Team,
DivisionWithEvent
DivisionWithEvent,
CoreValuesForm
} from '@lems/types';
import { RoleAuthorizer } from '../../components/role-authorizer';
import Layout from '../../components/layout';
import WelcomeHeader from '../../components/general/welcome-header';
import CVPanel from '../../components/cv-form/cv-panel';
import { getUserAndDivision, serverSideGetRequests } from '../../lib/utils/fetch';
import { localizedRoles } from '../../localization/roles';
import { useWebsocket } from '../../hooks/use-websocket';
import HeadRefereeRoundSchedule from '../../components/field/head-referee/head-referee-round-schedule';
import ScoresheetStatusReferences from '../../components/field/head-referee/scoresheet-status-references';
import { localizeDivisionTitle } from '../../localization/event';
import { useQueryParam } from '../../hooks/use-query-param';

interface Props {
user: WithId<SafeUser>;
Expand All @@ -31,6 +35,8 @@ interface Props {
tables: Array<WithId<RobotGameTable>>;
scoresheets: Array<WithId<Scoresheet>>;
matches: Array<WithId<RobotGameMatch>>;
teams: Array<WithId<Team>>;
cvForms: Array<WithId<CoreValuesForm>>;
}

const Page: NextPage<Props> = ({
Expand All @@ -39,13 +45,18 @@ const Page: NextPage<Props> = ({
divisionState: initialDivisionState,
tables,
scoresheets: initialScoresheets,
matches: initialMatches
matches: initialMatches,
teams: initialTeams,
cvForms: initialCvForms
}) => {
const router = useRouter();
const [activeTab, setActiveTab] = useQueryParam('tab', '1');
const [divisionState, setDivisionState] = useState<WithId<DivisionState>>(initialDivisionState);
const [matches, setMatches] = useState<Array<WithId<RobotGameMatch>>>(initialMatches);
const [scoresheets, setScoresheets] = useState<Array<WithId<Scoresheet>>>(initialScoresheets);
const [showGeneralSchedule] = useState<boolean>(true);
const [teams, setTeams] = useState<Array<WithId<Team>>>(initialTeams);
const [cvForms, setCvForms] = useState<Array<WithId<CoreValuesForm>>>(initialCvForms);

const headRefereeGeneralSchedule =
(showGeneralSchedule && division.schedule?.filter(s => s.roles.includes('head-referee'))) || [];
Expand Down Expand Up @@ -119,7 +130,7 @@ const Page: NextPage<Props> = ({
);
};

const { connectionStatus } = useWebsocket(
const { socket, connectionStatus } = useWebsocket(
division._id.toString(),
['field', 'pit-admin'],
undefined,
Expand Down Expand Up @@ -188,17 +199,45 @@ const Page: NextPage<Props> = ({
divisionState={divisionState}
color={division.color}
>
<WelcomeHeader division={division} user={user} />
<Paper sx={{ p: 2 }}>
<ScoresheetStatusReferences />
<Typography textAlign="center" fontSize="0.85rem" sx={{ pt: 1 }} color="textSecondary">
הניקוד במקצה יופיע מעל הכפתור. צבע הרקע של הניקוד מעיד על ציון המקצועיות האדיבה של
הקבוצה.
</Typography>
</Paper>
<Grid container spacing={2} my={4}>
{...roundSchedules}
</Grid>
<TabContext value={activeTab}>
<Paper sx={{ mt: 2 }}>
<Tabs
value={activeTab}
onChange={(_e, newValue: string) => setActiveTab(newValue)}
centered
>
<Tab label="זירה" value="1" />
<Tab label="טפסי CV" value="2" />
</Tabs>
</Paper>
<WelcomeHeader division={division} user={user} />
<TabPanel value="1">
<Paper sx={{ p: 2 }}>
<ScoresheetStatusReferences />
<Typography
textAlign="center"
fontSize="0.85rem"
sx={{ pt: 1 }}
color="textSecondary"
>
הניקוד במקצה יופיע מעל הכפתור. צבע הרקע של הניקוד מעיד על ציון המקצועיות האדיבה של
הקבוצה.
</Typography>
</Paper>
<Grid container spacing={2} my={4}>
{...roundSchedules}
</Grid>
</TabPanel>
<TabPanel value="2">
<CVPanel
user={user}
teams={teams}
cvForms={cvForms}
division={division}
socket={socket}
/>
</TabPanel>
</TabContext>
</Layout>
</RoleAuthorizer>
);
Expand All @@ -214,7 +253,9 @@ export const getServerSideProps: GetServerSideProps = async ctx => {
divisionState: `/api/divisions/${divisionId}/state`,
tables: `/api/divisions/${divisionId}/tables`,
matches: `/api/divisions/${divisionId}/matches`,
scoresheets: `/api/divisions/${divisionId}/scoresheets`
scoresheets: `/api/divisions/${divisionId}/scoresheets`,
cvForms: `/api/divisions/${divisionId}/cv-forms`,
teams: `/api/divisions/${divisionId}/teams`
},
ctx
);
Expand Down