@@ -22,7 +22,7 @@ function getCautionColors(caution) {
22
22
return { } ;
23
23
}
24
24
25
- export default function PartnerPage ( { students } ) {
25
+ export default function PartnerPage ( { students, hidePartner } ) {
26
26
const [ newStudentEmail , setNewStudentEmail ] = useState ( '' ) ;
27
27
const [ newStudentUsername , setNewStudentUsername ] = useState ( '' ) ;
28
28
const fetch = useFetcher ( ) ;
@@ -39,48 +39,55 @@ export default function PartnerPage({ students }) {
39
39
< ListItem > < Link href = { `#s-${ s . id } ` } > { s . name } </ Link > </ ListItem >
40
40
) ) }
41
41
</ 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
+ } ,
63
65
} ,
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
+ ) }
80
82
</ Box >
81
83
< Box >
82
84
{ students
83
85
. 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
+ } )
84
91
. map ( ( s ) => {
85
92
const trainingSubmissions = ( s . projects || [ ] ) . flatMap ( ( p ) => p . tags )
86
93
. filter ( ( t ) => t . trainingLink )
@@ -98,6 +105,7 @@ export default function PartnerPage({ students }) {
98
105
< Link name = { `s-${ s . id } ` } href = { `/dash/s/${ s . token } ` } target = "_blank" >
99
106
< Heading as = "h4" fontSize = "2xl" > { s . name } { s . status !== 'ACCEPTED' && `(Status: ${ s . status } )` } </ Heading >
100
107
</ Link >
108
+ < Text > Mentored by { s . projects . flatMap ( ( p ) => p . mentors ) . flatMap ( ( m ) => m . name ) . join ( ', ' ) } </ Text >
101
109
< Accordion allowToggle >
102
110
< AccordionItem >
103
111
< AccordionButton >
@@ -125,7 +133,7 @@ export default function PartnerPage({ students }) {
125
133
126
134
< AccordionItem >
127
135
< 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 ) }
129
137
>
130
138
Project
131
139
< AccordionIcon />
@@ -146,7 +154,7 @@ export default function PartnerPage({ students }) {
146
154
147
155
< AccordionItem >
148
156
< 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 ) ) ) }
150
158
>
151
159
Onboarding Assignments
152
160
< AccordionIcon />
0 commit comments