Skip to content

Commit 563ae6d

Browse files
committed
Add CSV error line number
1 parent acae905 commit 563ae6d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/pages/academy/adminPanel/subcomponents/AddUserPanel.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ const AddUserPanel: React.FC<AddUserPanelProps> = props => {
9494
hasInvalidInput = true;
9595
}
9696

97-
for (const e of data) {
97+
for (let i = 0; i < data.length; i++) {
9898
// Incorrect number of columns
99-
if (!(e.data.length === 2 || e.data.length === 3)) {
99+
if (!(data[i].data.length === 2 || data[i].data.length === 3)) {
100100
setInvalidCsvMsg(
101101
<>
102102
<div>
103-
Invalid format! Please ensure that the username and role is specified for each row
104-
entry!
103+
Invalid format (line {i})! Please ensure that the username and role is specified for
104+
each row entry!
105105
</div>
106106
<br />
107107
<div>
@@ -115,9 +115,9 @@ const AddUserPanel: React.FC<AddUserPanelProps> = props => {
115115
break;
116116
}
117117
// Invalid role specified
118-
if (!Object.values(Role).includes(e.data[1])) {
118+
if (!Object.values(Role).includes(data[i].data[1])) {
119119
setInvalidCsvMsg(
120-
'Invalid role! Please ensure that the second column of each entry contains one of the following: admin, staff, student'
120+
`Invalid role (line ${i})! Please ensure that the second column of each entry contains one of the following: admin, staff, student'`
121121
);
122122
hasInvalidInput = true;
123123
break;

0 commit comments

Comments
 (0)