Skip to content

Commit 1e3cb55

Browse files
authored
Merge pull request #1203 from topcoder-platform/PM-1504_edit-create-scorecard
Fix sortOrder for scorecardQuestions & make error more visible
2 parents 7b5886f + 3c12410 commit 1e3cb55

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/apps/review/src/pages/scorecards/EditScorecardPage/EditScorecardPage.module.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@
8888
.headerArea {
8989
background: #0F172A;
9090
color: $tc-white;
91+
92+
:global(.input-error) {
93+
font-family: "Nunito Sans", sans-serif;
94+
background: #E2CBC0;
95+
width: max-content;
96+
padding: 0 $sp-2;
97+
border-radius: 2px;
98+
font-size: 14px;
99+
line-height: 20px;
100+
font-weight: bold;
101+
}
91102
}
92103

93104
.contentArea {
@@ -103,6 +114,17 @@
103114
.headerArea {
104115
background: $teal-160;
105116
color: $tc-white;
117+
118+
:global(.input-error) {
119+
font-family: "Nunito Sans", sans-serif;
120+
background: #E2CBC0;
121+
width: max-content;
122+
padding: 0 $sp-2;
123+
border-radius: 2px;
124+
font-size: 14px;
125+
line-height: 20px;
126+
font-weight: bold;
127+
}
106128
}
107129

108130
.contentArea {

src/apps/review/src/pages/scorecards/EditScorecardPage/components/ScorecardQuestionForm.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ const ScorecardQuestionForm: FC<ScorecardQuestionFormProps> = props => {
6969
})
7070

7171
const handleRemove = useCallback(async (index: number, field: any) => {
72+
const fieldName = field.name ? field.name : `Question ${props.sectionIndex}.${index + 1}`
7273
if (!await ctx.confirm({
73-
content: `Are you sure you want to remove "${field.name ? field.name : `Question ${index + 1}`}" question?`,
74+
content: `Are you sure you want to remove "${fieldName}" question?`,
7475
title: 'Confirm Remove Question',
7576
})) {
7677
return
@@ -82,7 +83,7 @@ const ScorecardQuestionForm: FC<ScorecardQuestionFormProps> = props => {
8283
const handleAddQuestion = useCallback(() => {
8384
formQuestionsArray.append({
8485
...getEmptyScorecardQuestion(),
85-
sortOrder: Math.max(...formQuestionsArray.fields.map(f => get(f, 'sortOrder', 0))) + 1,
86+
sortOrder: (Math.max(0, ...formQuestionsArray.fields.map(f => get(f, 'sortOrder', 0))) || 0) + 1,
8687
})
8788
}, [formQuestionsArray])
8889

0 commit comments

Comments
 (0)