@@ -84,8 +84,14 @@ const StudentPage = () => {
8484 } ,
8585 } ) ) ;
8686 await addStudents ( payload ) ;
87- toast . success ( "Students added successfully" ) ;
87+ toast . success (
88+ `Successfully imported ${ data . length } student${ data . length > 1 ? "s" : "" } ` ,
89+ ) ;
8890 setImportOpen ( false ) ;
91+
92+ // Refresh student data
93+ const updatedData = await fetchStudentData ( ) ;
94+ setStudents ( updatedData ) ;
8995 } catch ( e ) {
9096 toast . error ( "Failed to add students" ) ;
9197 }
@@ -94,7 +100,47 @@ const StudentPage = () => {
94100
95101 const parseStudentRow = ( row : any ) => {
96102 if ( ! row . rollNo || ! row . name || ! row . email ) return null ;
97- return row ;
103+
104+ // Convert enum fields to uppercase for backend compatibility
105+ const category = row . category ?. toUpperCase ( ) ;
106+ const gender = row . gender ?. toUpperCase ( ) ;
107+
108+ // Validate enum values
109+ const validCategories = [
110+ "GENERAL" ,
111+ "OBC" ,
112+ "SC" ,
113+ "ST" ,
114+ "EWS" ,
115+ "GENERAL_PWD" ,
116+ "OBC_PWD" ,
117+ "SC_PWD" ,
118+ "ST_PWD" ,
119+ "EWS_PWD" ,
120+ ] ;
121+ const validGenders = [ "MALE" , "FEMALE" , "OTHER" ] ;
122+
123+ if ( category && ! validCategories . includes ( category ) ) {
124+ console . warn ( `Invalid category: ${ category } for student ${ row . rollNo } ` ) ;
125+ return null ;
126+ }
127+
128+ if ( gender && ! validGenders . includes ( gender ) ) {
129+ console . warn ( `Invalid gender: ${ gender } for student ${ row . rollNo } ` ) ;
130+ return null ;
131+ }
132+
133+ const processedRow = {
134+ rollNo : row . rollNo ,
135+ category : category ,
136+ gender : gender ,
137+ cpi : row . cpi ,
138+ name : row . name ,
139+ email : row . email ,
140+ contact : row . contact ,
141+ } ;
142+
143+ return processedRow ;
98144 } ;
99145
100146 const handleBulkAction = ( rows : DTO [ ] ) => {
@@ -175,6 +221,7 @@ const StudentPage = () => {
175221 templateFileName = "students_template.csv"
176222 parseRow = { parseStudentRow }
177223 entityName = "students"
224+ cleanData = { true }
178225 />
179226 < div >
180227 { students . length > 0 && (
0 commit comments