Skip to content

Commit

Permalink
fix: Update variable name in StudentStatsCard and StudentStatsModal c…
Browse files Browse the repository at this point in the history
…omponents
  • Loading branch information
valerydluski committed Sep 9, 2024
1 parent 959e354 commit 0afa81d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
14 changes: 7 additions & 7 deletions client/src/components/Profile/__test__/StudentStatsCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('StudentStatsCard', () => {
scoreWeight: 1,
name: 'Task 1',
descriptionUri: 'https://description.com',
taskGithubPrUris: 'https://description.com',
githubPrUri: 'https://description.com',
score: 120,
comment: 'test',
},
Expand All @@ -35,7 +35,7 @@ describe('StudentStatsCard', () => {
scoreWeight: 1,
name: 'Task 2',
descriptionUri: 'https://description.com',
taskGithubPrUris: 'https://description.com',
githubPrUri: 'https://description.com',
score: 20,
comment: 'test',
},
Expand All @@ -44,7 +44,7 @@ describe('StudentStatsCard', () => {
scoreWeight: 1,
name: 'Task 3',
descriptionUri: 'https://description.com',
taskGithubPrUris: 'https://description.com',
githubPrUri: 'https://description.com',
score: 90,
comment: 'test',
},
Expand All @@ -70,7 +70,7 @@ describe('StudentStatsCard', () => {
scoreWeight: 1,
name: 'Task 1',
descriptionUri: 'https://description.com',
taskGithubPrUris: 'https://description.com',
githubPrUri: 'https://description.com',
score: 20,
comment: 'test',
},
Expand All @@ -79,7 +79,7 @@ describe('StudentStatsCard', () => {
scoreWeight: 1,
name: 'Task 2',
descriptionUri: 'https://description.com',
taskGithubPrUris: 'https://description.com',
githubPrUri: 'https://description.com',
score: null,
comment: null,
},
Expand All @@ -88,7 +88,7 @@ describe('StudentStatsCard', () => {
scoreWeight: 1,
name: 'Task 3',
descriptionUri: 'https://description.com',
taskGithubPrUris: 'https://description.com',
githubPrUri: 'https://description.com',
score: 10,
comment: 'test',
},
Expand All @@ -97,7 +97,7 @@ describe('StudentStatsCard', () => {
scoreWeight: 1,
name: 'Task 4',
descriptionUri: 'https://description.com',
taskGithubPrUris: 'https://description.com',
githubPrUri: 'https://description.com',
score: null,
comment: null,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('StudentStatsModal', () => {
scoreWeight: 1,
name: 'Task 1',
descriptionUri: 'https://description.com',
taskGithubPrUris: 'https://description.com',
githubPrUri: 'https://description.com',
score: 120,
comment: 'test',
},
Expand All @@ -36,7 +36,7 @@ describe('StudentStatsModal', () => {
scoreWeight: 1,
name: 'Task 2',
descriptionUri: 'https://description.com',
taskGithubPrUris: 'https://description.com',
githubPrUri: 'https://description.com',
score: 20,
comment: 'test',
},
Expand All @@ -45,7 +45,7 @@ describe('StudentStatsModal', () => {
scoreWeight: 1,
name: 'Task 3',
descriptionUri: 'https://description.com',
taskGithubPrUris: 'https://description.com',
githubPrUri: 'https://description.com',
score: 90,
comment: 'test',
},
Expand Down
27 changes: 13 additions & 14 deletions client/src/modules/StudentDashboard/components/TasksStatsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { Modal, Table, Typography } from 'antd';
import { dateTimeRenderer, dateRenderer } from 'components/Table';
import { TaskStat } from './TasksStatsCard';
Expand All @@ -14,26 +13,25 @@ type Props = {
};

export function TasksStatsModal(props: Props) {
const { tableName, tasks, courseName } = props;
const courseTasks = tasks.map((task, idx) => ({ key: `student-stats-modal-task-${idx}`, ...task }));
const { tableName, tasks, courseName, isVisible, onHide } = props;
const columnWidth = 150;
// where 500 is approximate sum of columns
const tableWidth = 2 * columnWidth + 500;

return (
<Modal
title={`${courseName} statistics`}
open={props.isVisible}
onCancel={props.onHide}
open={isVisible}
onCancel={onHide}
footer={null}
width={'90%'}
style={{ top: 30 }}
>
<p style={{ textAlign: 'center', fontWeight: 700 }}>{tableName.toUpperCase()}</p>
<Table
dataSource={courseTasks}
dataSource={tasks}
size="small"
rowKey="key"
rowKey="id"
scroll={{ x: tableWidth, y: 'calc(100vh - 250px)' }}
pagination={false}
columns={[
Expand All @@ -52,7 +50,7 @@ export function TasksStatsModal(props: Props) {
},
{
title: 'Score / Max',
width: 70,
width: 120,
dataIndex: 'score',
render: (score: string, { maxScore }: any) => (
<>
Expand All @@ -61,12 +59,12 @@ export function TasksStatsModal(props: Props) {
),
},
{
title: '*Weight',
width: 70,
title: 'Weight',
width: 140,
dataIndex: 'scoreWeight',
render: (scoreWeight: number, { score }: any) => (
<Text>
*{scoreWeight}
{Number(score)} * {scoreWeight}
{score ? (
<Text>
{' '}
Expand All @@ -79,13 +77,13 @@ export function TasksStatsModal(props: Props) {
),
},
{
title: '*Start date',
title: 'Start date',
width: 140,
dataIndex: 'startDate',
render: (startDate: string) => <Text>{dateRenderer(startDate)}</Text>,
},
{
title: '*Deadline',
title: 'Deadline',
width: 140,
dataIndex: 'endDate',
render: (endDate: string) => <Text>{dateTimeRenderer(endDate)}</Text>,
Expand All @@ -96,10 +94,11 @@ export function TasksStatsModal(props: Props) {
ellipsis: false,
},
{
title: 'Github PR Uri',
title: 'Github PR Url',
dataIndex: 'githubPrUri',
render: (uri: string) => (uri ? <a href={uri}>PR</a> : uri),
ellipsis: true,
width: 120,
},
]}
/>
Expand Down
5 changes: 3 additions & 2 deletions client/src/pages/course/student/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ function Page() {
scheduleItems
.filter(scheduleItem => scheduleItem.type === CourseScheduleItemDtoTypeEnum.CourseTask)
.map(task => {
const { comment, taskGithubPrUris } =
const { comment, githubPrUri } =
tasksDetailCurrentCourse.find(taskDetail => taskDetail.name === task.name) ?? {};
return { ...task, comment, githubPrUri: taskGithubPrUris };

return { ...task, comment, githubPrUri };
}),
'status',
),
Expand Down
2 changes: 1 addition & 1 deletion common/models/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export interface StudentTasksDetail {
scoreWeight: number;
name: string;
descriptionUri: string;
taskGithubPrUris: string;
githubPrUri: string;
score: number;
comment: string;
interviewDate?: string;
Expand Down

0 comments on commit 0afa81d

Please sign in to comment.