Skip to content

Commit 018fe02

Browse files
committed
fix: migrate @common/ code
1 parent a98e0a7 commit 018fe02

File tree

37 files changed

+254
-158
lines changed

37 files changed

+254
-158
lines changed

client/src/api/api.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3344,6 +3344,49 @@ export const EventDtoTypeEnum = {
33443344

33453345
export type EventDtoTypeEnum = typeof EventDtoTypeEnum[keyof typeof EventDtoTypeEnum];
33463346

3347+
/**
3348+
*
3349+
* @export
3350+
* @interface ExpelledStatsDto
3351+
*/
3352+
export interface ExpelledStatsDto {
3353+
/**
3354+
*
3355+
* @type {string}
3356+
* @memberof ExpelledStatsDto
3357+
*/
3358+
'id': string;
3359+
/**
3360+
*
3361+
* @type {CourseDto}
3362+
* @memberof ExpelledStatsDto
3363+
*/
3364+
'course': CourseDto;
3365+
/**
3366+
*
3367+
* @type {UserDto}
3368+
* @memberof ExpelledStatsDto
3369+
*/
3370+
'user': UserDto;
3371+
/**
3372+
*
3373+
* @type {Array<string>}
3374+
* @memberof ExpelledStatsDto
3375+
*/
3376+
'reasonForLeaving': Array<string>;
3377+
/**
3378+
*
3379+
* @type {string}
3380+
* @memberof ExpelledStatsDto
3381+
*/
3382+
'otherComment': string;
3383+
/**
3384+
*
3385+
* @type {string}
3386+
* @memberof ExpelledStatsDto
3387+
*/
3388+
'submittedAt': string;
3389+
}
33473390
/**
33483391
*
33493392
* @export
@@ -10493,7 +10536,7 @@ export const CourseStatsApiFp = function(configuration?: Configuration) {
1049310536
* @param {*} [options] Override http request option.
1049410537
* @throws {RequiredError}
1049510538
*/
10496-
async getExpelledStats(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<CourseStatsDto>>> {
10539+
async getExpelledStats(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<ExpelledStatsDto>>> {
1049710540
const localVarAxiosArgs = await localVarAxiosParamCreator.getExpelledStats(options);
1049810541
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1049910542
},
@@ -10587,7 +10630,7 @@ export const CourseStatsApiFactory = function (configuration?: Configuration, ba
1058710630
* @param {*} [options] Override http request option.
1058810631
* @throws {RequiredError}
1058910632
*/
10590-
getExpelledStats(options?: any): AxiosPromise<Array<CourseStatsDto>> {
10633+
getExpelledStats(options?: any): AxiosPromise<Array<ExpelledStatsDto>> {
1059110634
return localVarFp.getExpelledStats(options).then((request) => request(axios, basePath));
1059210635
},
1059310636
/**

client/src/components/Forms/Heroes/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { FormLayout } from 'antd/es/form/Form';
33
import { useCallback, useEffect, useState } from 'react';
44
import Masonry from 'react-masonry-css';
55
import css from 'styled-jsx/css';
6-
import { IGratitudeGetRequest, IGratitudeGetResponse, HeroesFormData } from '@common/interfaces/gratitude';
76
import heroesBadges from 'configs/heroes-badges';
8-
import { GratitudeService } from 'services/gratitude';
7+
import { GratitudeService, HeroesFormData, IGratitudeGetRequest, IGratitudeGetResponse } from 'services/gratitude';
98
import { onlyDefined } from 'utils/onlyDefined';
109
import { getFullName } from 'domain/user';
1110
import { useActiveCourseContext } from 'modules/Course/contexts';

client/src/components/Heroes/HeroesRadarTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FileExcelOutlined } from '@ant-design/icons';
22
import { SessionContext, useActiveCourseContext } from '@client/modules/Course/contexts';
33
import { onlyDefined } from '@client/utils/onlyDefined';
4-
import { IPaginationInfo } from '@common/types/pagination';
4+
import { IPaginationInfo } from '@client/utils/pagination';
55
import type { TimeRangePickerProps } from 'antd';
66
import { Button, Checkbox, DatePicker, Form, Row, Select, Space, TableProps } from 'antd';
77
import { CountryDto, GratitudesApi, HeroesRadarDto, HeroRadarDto } from 'api';

client/src/components/MentorOptions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Button, Form, FormInstance, Select } from 'antd';
2-
import { PreferredStudentsLocation } from '@common/enums/mentor';
32
import { StudentSearch } from './StudentSearch';
3+
import { MentorDetailsDtoStudentsPreferenceEnum } from '@client/api/api';
44

55
export type Options = {
66
maxStudentsLimit: number;
7-
preferedStudentsLocation: PreferredStudentsLocation;
7+
preferedStudentsLocation: MentorDetailsDtoStudentsPreferenceEnum;
88
students?: { value: number }[];
99
preselectedStudents?: { id: number; githubId: string; name: string }[];
1010
};

client/src/modules/CourseManagement/components/ExpelledStudentsStats.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { PublicSvgIcon } from '@client/components/Icons';
55
import { DEFAULT_COURSE_ICONS } from '@client/configs/course-icons';
66
import { dateUtcRenderer } from '@client/components/Table';
77
import { useExpelledStats } from '@client/modules/CourseManagement/hooks/useExpelledStats';
8-
import { DetailedExpelledStat } from '@common/models';
8+
import { ExpelledStatsDto } from '@client/api';
99

1010
const { Title, Text } = Typography;
1111

1212
const ExpelledStudentsStats: React.FC = () => {
1313
const { data, error, loading, isDeleting, handleDelete } = useExpelledStats();
1414
const [csvUrl, setCsvUrl] = React.useState<string | null>(null);
1515
const downloadRef = React.useRef<HTMLAnchorElement>(null);
16-
const columns: ColumnsType<DetailedExpelledStat> = [
16+
const columns: ColumnsType<ExpelledStatsDto> = [
1717
{
1818
title: 'Course',
1919
dataIndex: ['course', 'name'],
@@ -80,7 +80,7 @@ const ExpelledStudentsStats: React.FC = () => {
8080
return value;
8181
};
8282

83-
const getValueFromDataIndex = (row: DetailedExpelledStat, dataIndex: unknown): string => {
83+
const getValueFromDataIndex = (row: ExpelledStatsDto, dataIndex: unknown): string => {
8484
if (Array.isArray(dataIndex)) {
8585
let current: unknown = row;
8686

@@ -93,14 +93,14 @@ const ExpelledStudentsStats: React.FC = () => {
9393
}
9494

9595
if (typeof dataIndex === 'string' || typeof dataIndex === 'number') {
96-
const value = row[dataIndex as keyof DetailedExpelledStat];
96+
const value = row[dataIndex as keyof ExpelledStatsDto];
9797
return value !== undefined && value !== null ? String(value) : '';
9898
}
9999

100100
return '';
101101
};
102102

103-
const getSpecialColumnValue = (row: DetailedExpelledStat, columnKey: string): string => {
103+
const getSpecialColumnValue = (row: ExpelledStatsDto, columnKey: string): string => {
104104
switch (columnKey) {
105105
case 'reasons':
106106
return row.reasonForLeaving ? row.reasonForLeaving.map(r => r.replace(/_/g, ' ')).join('; ') : '';
@@ -115,7 +115,7 @@ const ExpelledStudentsStats: React.FC = () => {
115115
}
116116
};
117117

118-
const formatRowToCsv = (row: DetailedExpelledStat, exportableColumns: ColumnType<DetailedExpelledStat>[]): string => {
118+
const formatRowToCsv = (row: ExpelledStatsDto, exportableColumns: ColumnType<ExpelledStatsDto>[]): string => {
119119
return exportableColumns
120120
.map(col => {
121121
let value = '';
@@ -137,7 +137,7 @@ const ExpelledStudentsStats: React.FC = () => {
137137
}
138138

139139
const exportableColumns = columns.filter(
140-
(col): col is ColumnType<DetailedExpelledStat> => 'dataIndex' in col && col.dataIndex !== undefined,
140+
(col): col is ColumnType<ExpelledStatsDto> => 'dataIndex' in col && col.dataIndex !== undefined,
141141
);
142142

143143
const headers = exportableColumns

client/src/modules/CourseManagement/hooks/useExpelledStats.ts

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
1+
import { CourseStatsApi, ExpelledStatsDto } from '@client/api/api';
12
import { useRequest } from 'ahooks';
23
import { useState } from 'react';
3-
import { DetailedExpelledStat } from '@common/models';
44

5-
const fetchExpelledStats = async (): Promise<DetailedExpelledStat[]> => {
6-
const response = await fetch('/api/v2/courses/stats/expelled');
7-
if (!response.ok) {
8-
throw new Error('Failed to fetch stats');
9-
}
10-
return response.json() as Promise<DetailedExpelledStat[]>;
5+
export interface DetailedExpelledStat {
6+
id: string;
7+
course: {
8+
id: number;
9+
name: string;
10+
fullName: string;
11+
alias: string;
12+
description: string;
13+
logo: string;
14+
};
15+
user: {
16+
id: number;
17+
githubId: string;
18+
};
19+
reasonForLeaving?: string[];
20+
otherComment: string;
21+
submittedAt: Date;
22+
}
23+
24+
const api = new CourseStatsApi();
25+
26+
const fetchExpelledStats = async (): Promise<ExpelledStatsDto[]> => {
27+
const response = await api.getExpelledStats();
28+
return response.data;
1129
};
1230

1331
export const useExpelledStats = () => {
14-
const { data, error, loading, refresh } = useRequest(fetchExpelledStats);
32+
const { data, error, loading } = useRequest(fetchExpelledStats);
1533
const [isDeleting, setIsDeleting] = useState(false);
1634

1735
const handleDelete = async (id: string) => {
1836
setIsDeleting(true);
1937
try {
20-
const response = await fetch(`/api/v2/courses/stats/expelled/${id}`, {
21-
method: 'DELETE',
22-
});
23-
if (!response.ok) {
24-
throw new Error('Failed to delete stat');
25-
}
26-
if (typeof refresh === 'function') {
27-
refresh();
28-
}
38+
await api.deleteExpelledStat(id);
2939
} catch (err) {
3040
console.error('Error deleting stat:', err);
3141
} finally {

client/src/modules/CrossCheckPairs/pages/CrossCheckPairs/CrossCheckPairs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Collapse, Modal, Space, TablePaginationConfig } from 'antd';
22
import { Comment } from '@ant-design/compatible';
33
import { FilterValue } from 'antd/lib/table/interface';
4-
import { IPaginationInfo } from '@common/types/pagination';
4+
import { IPaginationInfo } from '@client/utils/pagination';
55
import { AdminPageLayout } from 'components/PageLayout';
66
import { dateTimeRenderer } from 'components/Table';
77
import { useCallback, useEffect, useMemo, useState } from 'react';

client/src/modules/Interviews/pages/StageInterviewFeedback/feedbackTemplateHandler.test.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1+
import { InterviewFeedbackValues } from '@common/models/interview';
12
import {
23
getFeedbackFromTemplate,
34
getDefaultStep,
45
isInterviewCanceled,
56
getUpdatedFeedback,
67
} from './feedbackTemplateHandler';
7-
import {
8-
Decision,
9-
Feedback,
10-
FeedbackStepId,
11-
InterviewFeedbackValues,
12-
feedbackTemplate,
13-
} from 'data/interviews/technical-screening';
8+
import { Decision, Feedback, FeedbackStepId, feedbackTemplate } from 'data/interviews/technical-screening';
149

1510
describe('getFeedbackFromTemplate', () => {
1611
test('should return default template when no feedback exists', () => {

client/src/modules/Mentor/pages/Interviews/components/MentorPreferencesModal.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { MentorOptions, Options } from 'components/MentorOptions';
33
import React, { createContext, useState } from 'react';
44
import { useAsync } from 'react-use';
55
import { CourseService } from 'services/course';
6-
import { MentorsApi } from 'api';
6+
import { MentorDetailsDtoStudentsPreferenceEnum, MentorsApi } from 'api';
77
import { getMentorId } from 'domain/user';
88
import { Session } from 'components/withSession';
9-
import { PreferredStudentsLocation } from '@common/enums/mentor';
109

1110
type Props = {
1211
course: { id: number; name: string };
@@ -46,7 +45,7 @@ function MentorOptionsModal({ course, close, session }: Props & { close: () => v
4645
const { students, maxStudentsLimit, preferedStudentsLocation } = mentor;
4746
setOptions({
4847
maxStudentsLimit,
49-
preferedStudentsLocation: preferedStudentsLocation as PreferredStudentsLocation,
48+
preferedStudentsLocation: preferedStudentsLocation as MentorDetailsDtoStudentsPreferenceEnum,
5049
students: students.map(s => ({ value: s.id })),
5150
preselectedStudents: students,
5251
});

client/src/modules/MentorTasksReview/pages/MentorTasksReview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { message, Space, TablePaginationConfig, Typography } from 'antd';
33
import { FilterValue } from 'antd/es/table/interface';
44
import { SorterResult } from 'antd/lib/table/interface';
55
import { CoursesTasksApi, CourseTaskDtoCheckerEnum, MentorReviewDto, MentorReviewsApi } from 'api';
6-
import { IPaginationInfo } from '@common/types/pagination';
6+
import { IPaginationInfo } from '@client/utils/pagination';
77
import { AdminPageLayout } from 'components/PageLayout';
88
import { useLoading } from 'components/useLoading';
99
import { isCourseManager } from 'domain/user';

0 commit comments

Comments
 (0)