@@ -4,10 +4,12 @@ import {
44 Intern ,
55 InternDiscipline ,
66 Question ,
7+ QuestionCategory ,
78 TestStatus ,
89} from '@internship-app/types' ;
910import { DataGrid , GridColDef } from '@mui/x-data-grid' ;
1011import moment from 'moment' ;
12+ import { steps } from '../../constants/interviewConstants' ;
1113
1214import styles from './index.module.css' ;
1315
@@ -132,34 +134,50 @@ export const InternInfo = ({ intern }: InternInfoProps) => {
132134 </ span >
133135
134136 { Array . isArray ( intern . interviewSlot ?. answers ) &&
135- intern . interviewSlot ?. answers . map ( ( item : Answer ) => {
136- if ( ! item . value ) return null ;
137-
138- if (
139- ! intern ?. internDisciplines ?. some (
140- ( discipline ) =>
141- discipline . discipline . toLowerCase ( ) === 'marketing' ,
142- ) &&
143- item . category === 'Marketing'
144- )
145- return null ;
146-
147- const formattedValue = Array . isArray ( item . value )
148- ? item . value . join ( ', ' )
149- : item . value ;
150-
151- return (
152- < div
153- className = { item . tick ? styles . tick : styles . atribute }
154- key = { item . id }
155- >
156- < h3 className = { styles . itemTitle } >
157- { item . question } { ! item . tick || '⚠️' }
158- </ h3 >
159- < span > { formattedValue } </ span >
160- </ div >
161- ) ;
162- } ) }
137+ intern . interviewSlot ?. answers
138+ . sort ( ( a : Answer , b : Answer ) => {
139+ const categoryCompare =
140+ steps . findIndex (
141+ ( step : { category : QuestionCategory } ) =>
142+ step . category === a . category ,
143+ ) -
144+ steps . findIndex (
145+ ( step : { category : QuestionCategory } ) =>
146+ step . category === b . category ,
147+ ) ;
148+
149+ if ( categoryCompare !== 0 ) return categoryCompare ;
150+
151+ return a . position ! - b . position ! ;
152+ } )
153+ . map ( ( item : Answer ) => {
154+ if ( ! item . value ) return null ;
155+
156+ if (
157+ ! intern ?. internDisciplines ?. some (
158+ ( discipline ) =>
159+ discipline . discipline . toLowerCase ( ) === 'marketing' ,
160+ ) &&
161+ item . category === 'Marketing'
162+ )
163+ return null ;
164+
165+ const formattedValue = Array . isArray ( item . value )
166+ ? item . value . join ( ', ' )
167+ : item . value ;
168+
169+ return (
170+ < div
171+ className = { item . tick ? styles . tick : styles . atribute }
172+ key = { item . id }
173+ >
174+ < h3 className = { styles . itemTitle } >
175+ { item . question } { ! item . tick || '⚠️' }
176+ </ h3 >
177+ < span > { formattedValue } </ span >
178+ </ div >
179+ ) ;
180+ } ) }
163181 </ div >
164182 ) }
165183 </ div >
0 commit comments