Skip to content

Commit 79b8cdf

Browse files
committed
TaskSolutionPage: fix
1 parent 8e206c2 commit 79b8cdf

1 file changed

Lines changed: 76 additions & 81 deletions

File tree

hwproj.front/src/components/Solutions/TaskSolutionsPage.tsx

Lines changed: 76 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -59,99 +59,94 @@ const TaskSolutionsPage: FC<RouteComponentProps<ITaskSolutionsProps>> = (props)
5959
: undefined
6060

6161
if (taskSolution.isLoaded) {
62-
if (
63-
!ApiSingleton.authService.isLoggedIn() ||
64-
!taskSolution.course.courseMates!.some(
65-
(cm) => cm.isAccepted! && cm.studentId == userId
66-
) ||
67-
!taskSolution.course.mentorIds!.includes(userId!)
68-
)
69-
{
62+
if (ApiSingleton.authService.isLoggedIn() &&
63+
(taskSolution.course.courseMates!.some((cm) => cm.isAccepted! && cm.studentId == userId)
64+
|| taskSolution.course.mentorIds!.includes(userId!))) {
7065
return (
71-
<Typography variant="h6">
72-
Страница не найдена
73-
</Typography>
74-
)
75-
}
76-
77-
return (
78-
<div style={{ marginBottom: '50px' }}>
79-
<Grid container justify="center" style={{marginTop: '20px'}}>
80-
<Grid container justifyContent="space-between" xs={11} >
81-
<Grid item>
82-
<Link
83-
component="button"
84-
style={{color: '#212529'}}
85-
onClick={() => window.location.assign('/courses/' + taskSolution.course.id)}
86-
>
87-
<Typography>
88-
Назад к курсу
89-
</Typography>
90-
</Link>
91-
</Grid>
92-
</Grid>
93-
<Grid container xs={11}>
94-
<Grid item xs={12}>
95-
<Task
96-
task={taskSolution.task}
97-
forStudent={true}
98-
forMentor={false}
99-
onDeleteClick={() => 3}
100-
isExpanded={true}
101-
showForCourse={false}
102-
/>
66+
<div style={{marginBottom: '50px'}}>
67+
<Grid container justify="center" style={{marginTop: '20px'}}>
68+
<Grid container justifyContent="space-between" xs={11}>
69+
<Grid item>
70+
<Link
71+
component="button"
72+
style={{color: '#212529'}}
73+
onClick={() => window.location.assign('/courses/' + taskSolution.course.id)}
74+
>
75+
<Typography>
76+
Назад к курсу
77+
</Typography>
78+
</Link>
79+
</Grid>
10380
</Grid>
104-
{!taskSolution.addSolution && (
105-
<Grid item xs={6}>
106-
<TaskSolutions
81+
<Grid container xs={11}>
82+
<Grid item xs={12}>
83+
<Task
84+
task={taskSolution.task}
85+
forStudent={true}
10786
forMentor={false}
108-
taskId={+props.match.params.taskId}
109-
studentId={userId as string}
110-
maxRating={taskSolution.task!.maxRating!}
87+
onDeleteClick={() => 3}
88+
isExpanded={true}
89+
showForCourse={false}
11190
/>
11291
</Grid>
113-
)}
114-
{(!taskSolution.addSolution && taskSolution.task.canSendSolution) && (
115-
<Grid item xs={12} style={{ marginTop: "16px" }}>
116-
<Button
117-
size="small"
118-
variant="contained"
119-
color="primary"
120-
onClick={(e) => {
121-
e.persist()
122-
setTaskSolution((prevState) => ({
123-
...prevState,
124-
addSolution: true,
125-
}))
126-
}}
127-
>
128-
Добавить решение
129-
</Button>
130-
</Grid>
131-
)}
132-
{taskSolution.addSolution && (
133-
<Grid item xs={6}>
134-
<div>
92+
{!taskSolution.addSolution && (
93+
<Grid item xs={6}>
13594
<TaskSolutions
13695
forMentor={false}
13796
taskId={+props.match.params.taskId}
13897
studentId={userId as string}
13998
maxRating={taskSolution.task!.maxRating!}
14099
/>
141-
</div>
142-
<div style={{ marginTop: "16px" }}>
143-
<AddSolution
144-
taskId={+props.match.params.taskId}
145-
onAdd={getTask}
146-
onCancel={onCancelAddSolution}
147-
/>
148-
</div>
149-
</Grid>
150-
)}
100+
</Grid>
101+
)}
102+
{(!taskSolution.addSolution && taskSolution.task.canSendSolution) && (
103+
<Grid item xs={12} style={{marginTop: "16px"}}>
104+
<Button
105+
size="small"
106+
variant="contained"
107+
color="primary"
108+
onClick={(e) => {
109+
e.persist()
110+
setTaskSolution((prevState) => ({
111+
...prevState,
112+
addSolution: true,
113+
}))
114+
}}
115+
>
116+
Добавить решение
117+
</Button>
118+
</Grid>
119+
)}
120+
{taskSolution.addSolution && (
121+
<Grid item xs={6}>
122+
<div>
123+
<TaskSolutions
124+
forMentor={false}
125+
taskId={+props.match.params.taskId}
126+
studentId={userId as string}
127+
maxRating={taskSolution.task!.maxRating!}
128+
/>
129+
</div>
130+
<div style={{marginTop: "16px"}}>
131+
<AddSolution
132+
taskId={+props.match.params.taskId}
133+
onAdd={getTask}
134+
onCancel={onCancelAddSolution}
135+
/>
136+
</div>
137+
</Grid>
138+
)}
139+
</Grid>
151140
</Grid>
152-
</Grid>
153-
</div>
154-
)
141+
</div>
142+
)
143+
} else {
144+
return (
145+
<Typography variant="h6">
146+
Страница не найдена
147+
</Typography>
148+
)
149+
}
155150
}
156151
return (
157152
<div>

0 commit comments

Comments
 (0)