From d926b4e47e672d727e698336bb3c8c288e78db98 Mon Sep 17 00:00:00 2001 From: Valery <57412523+valerydluski@users.noreply.github.com> Date: Mon, 23 Dec 2024 22:34:59 +0100 Subject: [PATCH] refactor: replace stageInterviewType with TaskDtoTypeEnum in interview-related components (#2567) --- client/src/domain/interview.tsx | 5 ++--- .../pages/InterviewFeedback/getServerSideProps.ts | 10 +++++----- .../InterviewWaitingList/getServerSideProps.ts | 5 ++--- .../Mentor/pages/InterviewWaitingList/index.tsx | 6 +++--- .../components/RegistrationNoticeAlert.tsx | 5 ++--- .../src/modules/Mentor/pages/Interviews/index.tsx | 7 +++++-- client/src/pages/course/admin/events.tsx | 1 + client/src/pages/course/admin/tasks.tsx | 2 +- .../src/pages/course/interview/[type]/feedback.tsx | 4 ++-- client/src/pages/course/student/interviews.tsx | 13 ++++++++----- 10 files changed, 31 insertions(+), 27 deletions(-) diff --git a/client/src/domain/interview.tsx b/client/src/domain/interview.tsx index 59552512e8..f103d6aff1 100644 --- a/client/src/domain/interview.tsx +++ b/client/src/domain/interview.tsx @@ -1,4 +1,5 @@ import { Tag } from 'antd'; +import { TaskDtoTypeEnum } from 'api'; import { StageInterviewFeedbackVerdict, InterviewDetails as CommonInterviewDetails } from 'common/models'; import { Decision } from 'data/interviews/technical-screening'; import dayjs from 'dayjs'; @@ -48,8 +49,6 @@ export enum InterviewStatus { Canceled, } -export const stageInterviewType = 'stage-interview'; - export function isInterviewRegistrationInProgress(interviewStartDate: string) { const startDate = dayjs(interviewStartDate).subtract(2, 'weeks'); @@ -79,7 +78,7 @@ export function getInterviewFeedbackUrl({ if (!featureToggles.feedback && isScreening) { return `/course/mentor/interview-technical-screening?course=${courseAlias}&githubId=${studentGithubId}`; } - const type = isScreening ? stageInterviewType : template; + const type = isScreening ? TaskDtoTypeEnum.StageInterview : template; return `/course/interview/${type}/feedback?course=${courseAlias}&githubId=${studentGithubId}&studentId=${studentId}&interviewId=${interviewId}`; } diff --git a/client/src/modules/Interviews/pages/InterviewFeedback/getServerSideProps.ts b/client/src/modules/Interviews/pages/InterviewFeedback/getServerSideProps.ts index dd763a72ee..fcaa6e9db7 100644 --- a/client/src/modules/Interviews/pages/InterviewFeedback/getServerSideProps.ts +++ b/client/src/modules/Interviews/pages/InterviewFeedback/getServerSideProps.ts @@ -5,10 +5,10 @@ import { StudentsApi, CoursesInterviewsApi, InterviewFeedbackDto, + TaskDtoTypeEnum, } from 'api'; import { templates } from 'data/interviews'; import { getTasksTotalScore } from 'domain/course'; -import { stageInterviewType } from 'domain/interview'; import { notAuthorizedResponse } from 'modules/Course/data'; import { GetServerSideProps, GetServerSidePropsContext } from 'next'; import { ParsedUrlQuery } from 'querystring'; @@ -25,7 +25,7 @@ export type StageFeedbackProps = CourseOnlyPageProps & { studentsCount: number; }; interviewFeedback: InterviewFeedbackDto; - type: typeof stageInterviewType; + type: typeof TaskDtoTypeEnum.StageInterview; }; export type FeedbackProps = CourseOnlyPageProps & { @@ -49,7 +49,7 @@ export const getServerSideProps: GetServerSideProps = async ctx => { return notAuthorizedResponse; } - const pageProps = await (type === stageInterviewType + const pageProps = await (type === TaskDtoTypeEnum.StageInterview ? getStageInterviewData({ ctx, courseId: course.id, token }) : getInterviewData({ ctx, courseId: course.id, token })); @@ -96,7 +96,7 @@ async function getStageInterviewData({ new StudentsApi(axiosConfig).getStudent(Number(studentId)), new CoursesTasksApi(axiosConfig).getCourseTasks(courseId), new CourseStatsApi(axiosConfig).getCourseStats(courseId), - new CoursesInterviewsApi(axiosConfig).getInterviewFeedback(courseId, interviewId, stageInterviewType), + new CoursesInterviewsApi(axiosConfig).getInterviewFeedback(courseId, interviewId, TaskDtoTypeEnum.StageInterview), ]); if (!student) { throw new Error('Student not found'); @@ -110,7 +110,7 @@ async function getStageInterviewData({ studentsCount: activeStudentsCount, }, interviewFeedback, - type: stageInterviewType, + type: TaskDtoTypeEnum.StageInterview, }; } diff --git a/client/src/modules/Mentor/pages/InterviewWaitingList/getServerSideProps.ts b/client/src/modules/Mentor/pages/InterviewWaitingList/getServerSideProps.ts index 7f6078a9b8..e989944463 100644 --- a/client/src/modules/Mentor/pages/InterviewWaitingList/getServerSideProps.ts +++ b/client/src/modules/Mentor/pages/InterviewWaitingList/getServerSideProps.ts @@ -1,11 +1,10 @@ -import { CoursesApi, CoursesInterviewsApi } from 'api'; +import { CoursesApi, CoursesInterviewsApi, TaskDtoTypeEnum } from 'api'; import { notAuthorizedResponse, noAccessResponse } from 'modules/Course/data'; import { GetServerSideProps } from 'next'; import type { PageProps } from './index'; import { getApiConfiguration } from 'utils/axios'; import { getTokenFromContext } from 'utils/server'; import dayjs from 'dayjs'; -import { stageInterviewType } from 'domain/interview'; export const getServerSideProps: GetServerSideProps = async ctx => { try { @@ -35,7 +34,7 @@ export const getServerSideProps: GetServerSideProps = async ctx => { return notAuthorizedResponse; } - const isStage = interview.type === stageInterviewType; + const isStage = interview.type === TaskDtoTypeEnum.StageInterview; if (!isStage && dayjs(interview.startDate).isAfter(dayjs())) { return notAuthorizedResponse; } diff --git a/client/src/modules/Mentor/pages/InterviewWaitingList/index.tsx b/client/src/modules/Mentor/pages/InterviewWaitingList/index.tsx index d5f7a0e563..944e93706d 100644 --- a/client/src/modules/Mentor/pages/InterviewWaitingList/index.tsx +++ b/client/src/modules/Mentor/pages/InterviewWaitingList/index.tsx @@ -16,9 +16,9 @@ import { useAsync } from 'react-use'; import { CourseService } from 'services/course'; import { CoursePageProps } from 'services/models'; import { isCourseManager, isMentor } from 'domain/user'; -import { AvailableStudentDto, CoursesInterviewsApi, InterviewDto } from 'api'; +import { AvailableStudentDto, CoursesInterviewsApi, InterviewDto, TaskDtoTypeEnum } from 'api'; import { getApiConfiguration } from 'utils/axios'; -import { getRating, stageInterviewType } from 'domain/interview'; +import { getRating } from 'domain/interview'; import { SessionContext } from 'modules/Course/contexts'; const api = new CoursesInterviewsApi(getApiConfiguration()); @@ -32,7 +32,7 @@ export function InterviewWaitingList({ course, interview }: PageProps) { const [loading, withLoading] = useLoading(false); const [availableStudents, setAvailableStudents] = useState([]); const courseService = useMemo(() => new CourseService(courseId), [courseId]); - const isStageInterview = interview.type === stageInterviewType; + const isStageInterview = interview.type === TaskDtoTypeEnum.StageInterview; useAsync( withLoading(async () => { diff --git a/client/src/modules/Mentor/pages/Interviews/components/RegistrationNoticeAlert.tsx b/client/src/modules/Mentor/pages/Interviews/components/RegistrationNoticeAlert.tsx index 85cfa51133..da550e10e1 100644 --- a/client/src/modules/Mentor/pages/Interviews/components/RegistrationNoticeAlert.tsx +++ b/client/src/modules/Mentor/pages/Interviews/components/RegistrationNoticeAlert.tsx @@ -2,8 +2,7 @@ import { Alert, Typography } from 'antd'; import InfoCircleTwoTone from '@ant-design/icons/InfoCircleTwoTone'; import dayjs from 'dayjs'; import { useContext } from 'react'; -import { stageInterviewType } from 'domain/interview'; -import { InterviewDto } from 'api'; +import { InterviewDto, TaskDtoTypeEnum } from 'api'; import { MentorOptionsContext } from './MentorPreferencesModal'; import { useAlert } from '../hooks/useAlert'; @@ -15,7 +14,7 @@ export function RegistrationNoticeAlert(props: { interview: InterviewDto; startD if (isDismissed) return null; - if (interview.type !== stageInterviewType) { + if (interview.type !== TaskDtoTypeEnum.StageInterview) { return null; } diff --git a/client/src/modules/Mentor/pages/Interviews/index.tsx b/client/src/modules/Mentor/pages/Interviews/index.tsx index a806acaa0a..de90d9b348 100644 --- a/client/src/modules/Mentor/pages/Interviews/index.tsx +++ b/client/src/modules/Mentor/pages/Interviews/index.tsx @@ -1,4 +1,4 @@ -import { CoursesInterviewsApi, InterviewDto } from 'api'; +import { CoursesInterviewsApi, InterviewDto, TaskDtoTypeEnum } from 'api'; import { PageLayout } from 'components/PageLayout'; import { useLoading } from 'components/useLoading'; import { useCallback, useState, useContext } from 'react'; @@ -24,7 +24,10 @@ export function Interviews() { const loadData = async () => { const [{ data }] = await Promise.all([ - new CoursesInterviewsApi().getInterviews(course.id, false, ['interview', 'stage-interview']), + new CoursesInterviewsApi().getInterviews(course.id, false, [ + TaskDtoTypeEnum.Interview, + TaskDtoTypeEnum.StageInterview, + ]), fetchStudentInterviews(), ]); diff --git a/client/src/pages/course/admin/events.tsx b/client/src/pages/course/admin/events.tsx index 0c8720fd2d..5bd9273cec 100644 --- a/client/src/pages/course/admin/events.tsx +++ b/client/src/pages/course/admin/events.tsx @@ -92,6 +92,7 @@ function Page() { size="small" dataSource={data} columns={getColumns(handleEditEvent, handleDeleteItem, { timeZone, events })} + scroll={{ x: 1020, y: 'calc(100vh - 265px)' }} /> {modalData && ( {modalData ? ( setModalData(null)} onSubmit={handleModalSubmit} data={modalData} /> diff --git a/client/src/pages/course/interview/[type]/feedback.tsx b/client/src/pages/course/interview/[type]/feedback.tsx index 1681649659..e949ad56ed 100644 --- a/client/src/pages/course/interview/[type]/feedback.tsx +++ b/client/src/pages/course/interview/[type]/feedback.tsx @@ -1,4 +1,4 @@ -import { stageInterviewType } from 'domain/interview'; +import { TaskDtoTypeEnum } from 'api'; import { SessionProvider, ActiveCourseProvider } from 'modules/Course/contexts'; import { Feedback } from 'modules/Interviews/pages/feedback'; import { InterviewFeedback } from 'modules/Interviews/pages/InterviewFeedback'; @@ -11,7 +11,7 @@ export default function (props: PageProps) { return ( - {props.type === stageInterviewType ? : } + {props.type === TaskDtoTypeEnum.StageInterview ? : } ); diff --git a/client/src/pages/course/student/interviews.tsx b/client/src/pages/course/student/interviews.tsx index 14a4dcc078..bd864094d8 100644 --- a/client/src/pages/course/student/interviews.tsx +++ b/client/src/pages/course/student/interviews.tsx @@ -6,10 +6,10 @@ import { useMemo, useState, useContext } from 'react'; import { useAsync } from 'react-use'; import { CourseService } from 'services/course'; import { formatShortDate } from 'services/formatter'; -import { getInterviewResult, InterviewDetails, InterviewStatus, stageInterviewType } from 'domain/interview'; +import { getInterviewResult, InterviewDetails, InterviewStatus } from 'domain/interview'; import { Decision } from 'data/interviews/technical-screening'; import { ActiveCourseProvider, SessionContext, SessionProvider, useActiveCourseContext } from 'modules/Course/contexts'; -import { CoursesInterviewsApi, InterviewDto } from 'api'; +import { CoursesInterviewsApi, InterviewDto, TaskDtoTypeEnum } from 'api'; const coursesInterviewApi = new CoursesInterviewsApi(); @@ -27,7 +27,10 @@ function StudentInterviewPage() { setLoading(true); const [data, { data: interviews }] = await Promise.all([ courseService.getStudentInterviews(session.githubId), - coursesInterviewApi.getInterviews(course.id), + coursesInterviewApi.getInterviews(course.id, false, [ + TaskDtoTypeEnum.Interview, + TaskDtoTypeEnum.StageInterview, + ]), ] as const); const registeredInterviews = await getRegisteredInterviews(interviews); @@ -69,7 +72,7 @@ function StudentInterviewPage() { const getRegisteredInterviews = async (interviews: InterviewDto[]) => { const requests = interviews - .map(({ type, id }) => (type === stageInterviewType ? 'stage' : id.toString())) + .map(({ type, id }) => (type === TaskDtoTypeEnum.StageInterview ? 'stage' : id.toString())) .map(async id => { const data = await courseService.getInterviewStudent(session.githubId, id).catch(() => null); return data ? id : null; @@ -80,7 +83,7 @@ function StudentInterviewPage() { }; const renderExtra = (interview: InterviewDto) => { - const id = interview.type === stageInterviewType ? 'stage' : interview.id.toString(); + const id = interview.type === TaskDtoTypeEnum.StageInterview ? 'stage' : interview.id.toString(); const hasInterview = registeredInterviews.includes(id); return interview.studentRegistrationStartDate && new Date() < new Date(interview.studentRegistrationStartDate) ? ( Registration starts at {formatShortDate(interview.studentRegistrationStartDate)}