@@ -22,7 +22,7 @@ function getCautionColors(caution) {
2222 return { } ;
2323}
2424
25- export default function PartnerPage ( { students } ) {
25+ export default function PartnerPage ( { students, hidePartner } ) {
2626 const [ newStudentEmail , setNewStudentEmail ] = useState ( '' ) ;
2727 const [ newStudentUsername , setNewStudentUsername ] = useState ( '' ) ;
2828 const fetch = useFetcher ( ) ;
@@ -39,48 +39,55 @@ export default function PartnerPage({ students }) {
3939 < ListItem > < Link href = { `#s-${ s . id } ` } > { s . name } </ Link > </ ListItem >
4040 ) ) }
4141 </ List >
42- < Box mt = { 8 } >
43- < Heading as = "h4" fontSize = "md" > Associate Student</ Heading >
44- < Text fontSize = "sm" fontWeight = "bold" > Email</ Text >
45- < Input
46- onChange = { ( e ) => setNewStudentEmail ( e . target . value ) }
47- value = { newStudentEmail }
48- />
49- < Text fontSize = "sm" fontWeight = "bold" > or CodeDay Username</ Text >
50- < Input
51- onChange = { ( e ) => setNewStudentUsername ( e . target . value ) }
52- value = { newStudentUsername }
53- />
54- < Button
55- onClick = { async ( ) => {
56- try {
57- const result = await fetch (
58- AssociatePartnerCodeMutation ,
59- {
60- where : {
61- username : newStudentUsername || undefined ,
62- email : newStudentEmail || undefined ,
42+ { ! hidePartner && (
43+ < Box mt = { 8 } >
44+ < Heading as = "h4" fontSize = "md" > Associate Student</ Heading >
45+ < Text fontSize = "sm" fontWeight = "bold" > Email</ Text >
46+ < Input
47+ onChange = { ( e ) => setNewStudentEmail ( e . target . value ) }
48+ value = { newStudentEmail }
49+ />
50+ < Text fontSize = "sm" fontWeight = "bold" > or CodeDay Username</ Text >
51+ < Input
52+ onChange = { ( e ) => setNewStudentUsername ( e . target . value ) }
53+ value = { newStudentUsername }
54+ />
55+ < Button
56+ onClick = { async ( ) => {
57+ try {
58+ const result = await fetch (
59+ AssociatePartnerCodeMutation ,
60+ {
61+ where : {
62+ username : newStudentUsername || undefined ,
63+ email : newStudentEmail || undefined ,
64+ } ,
6365 } ,
64- } ,
65- ) ;
66- if ( result . labs . associatePartnerCode . id ) {
67- success ( `Associated ${ result . labs . associatePartnerCode . givenName } ${ result . labs . associatePartnerCode . surname } .` ) ;
68- setNewStudentEmail ( '' ) ;
69- setNewStudentUsername ( '' ) ;
70- } else throw new Error ( ) ;
71- } catch ( ex ) {
72- console . error ( ex ) ;
73- error ( 'Student not found.' ) ;
74- }
75- } }
76- >
77- Associate
78- </ Button >
79- </ Box >
66+ ) ;
67+ if ( result . labs . associatePartnerCode . id ) {
68+ success ( `Associated ${ result . labs . associatePartnerCode . givenName } ${ result . labs . associatePartnerCode . surname } .` ) ;
69+ setNewStudentEmail ( '' ) ;
70+ setNewStudentUsername ( '' ) ;
71+ } else throw new Error ( ) ;
72+ } catch ( ex ) {
73+ console . error ( ex ) ;
74+ error ( 'Student not found.' ) ;
75+ }
76+ } }
77+ >
78+ Associate
79+ </ Button >
80+ </ Box >
81+ ) }
8082 </ Box >
8183 < Box >
8284 { students
8385 . filter ( ( s ) => s . status !== 'CANCELED' )
86+ . sort ( ( a , b ) => {
87+ const mentorA = a . projects ?. [ 0 ] ?. mentors ?. [ 0 ] ?. name || '' ;
88+ const mentorB = b . projects ?. [ 0 ] ?. mentors ?. [ 0 ] ?. name || '' ;
89+ return mentorA . localeCompare ( mentorB ) ;
90+ } )
8491 . map ( ( s ) => {
8592 const trainingSubmissions = ( s . projects || [ ] ) . flatMap ( ( p ) => p . tags )
8693 . filter ( ( t ) => t . trainingLink )
@@ -98,6 +105,7 @@ export default function PartnerPage({ students }) {
98105 < Link name = { `s-${ s . id } ` } href = { `/dash/s/${ s . token } ` } target = "_blank" >
99106 < Heading as = "h4" fontSize = "2xl" > { s . name } { s . status !== 'ACCEPTED' && `(Status: ${ s . status } )` } </ Heading >
100107 </ Link >
108+ < Text > Mentored by { s . projects . flatMap ( ( p ) => p . mentors ) . flatMap ( ( m ) => m . name ) . join ( ', ' ) } </ Text >
101109 < Accordion allowToggle >
102110 < AccordionItem >
103111 < AccordionButton >
@@ -125,7 +133,7 @@ export default function PartnerPage({ students }) {
125133
126134 < AccordionItem >
127135 < AccordionButton
128- { ...getCautionColors ( ( s . hasProjectPreferences || s . skipPreferences || s . project ) ? 1 : 0 ) }
136+ { ...getCautionColors ( ( s . hasProjectPreferences || s . skipPreferences || ( s . projects && s . projects . length > 0 ) ) ? 0 : 1 ) }
129137 >
130138 Project
131139 < AccordionIcon />
@@ -146,7 +154,7 @@ export default function PartnerPage({ students }) {
146154
147155 < AccordionItem >
148156 < AccordionButton
149- { ...getCautionColors ( 1 - ( s . trainingSubmissions . filter ( ( ts ) => ts . submission ) . length / s . trainingSubmissions . length ) ) }
157+ { ...getCautionColors ( 1 - ( s . trainingSubmissions . filter ( ( ts ) => ts . submission ) . length / Math . min ( 3 , s . trainingSubmissions . length ) ) ) }
150158 >
151159 Onboarding Assignments
152160 < AccordionIcon />
0 commit comments