@@ -5,10 +5,11 @@ import 'reveal.js/dist/reset.css'
55import 'reveal.js/dist/reveal.css'
66import 'reveal.js/dist/theme/white.css'
77import './index.css'
8- import { IntroEvalsSummary } from "../../API/Types" ;
8+ import { Batch , IntroEvalsSummary } from "../../API/Types" ;
99import { getJSON , toastError } from "../../API/API" ;
10- import { Container } from "reactstrap" ;
10+ import { Col , Container , Row } from "reactstrap" ;
1111import BatchSlide from "./BatchSlide" ;
12+ import NumberBox from "./NumberBox" ;
1213
1314const IntroEvalsSlideshow = ( ) => {
1415
@@ -20,38 +21,68 @@ const IntroEvalsSlideshow = () => {
2021 slides . initialize ( ) ;
2122 }
2223
24+ const [ removedMembers , setRemovedMembers ] = useState < string [ ] > ( [ ] ) ;
25+
2326 const [ frosh , setFrosh ] = useState < IntroEvalsSummary [ ] > ( [ ] ) ;
2427
2528 useEffect ( ( ) => {
2629 getJSON < IntroEvalsSummary [ ] > ( "/api/evals/intro" )
27- . then ( setFrosh ) . then ( initSlides )
30+ . then ( setFrosh )
31+ . then ( initSlides )
2832 . catch ( toastError ( "Unable to fetch Intro Evals data" ) ) ;
2933 } , [ ] )
3034
31- interface Batch {
32- name : string ,
33- names : string [ ] ,
34- }
35+ const [ batches , setBatches ] = useState < Batch [ ] > ( [ ] ) ;
36+
37+ useEffect ( ( ) => {
38+ getJSON < Batch [ ] > ( "/api/batch" )
39+ . then ( e => setBatches ( e . map ( b => ( {
40+ ...b ,
41+ members : b . members . map ( m => m . split ( "," ) [ 0 ] ) ,
42+ } ) ) ) )
43+ . catch ( toastError ( "Unable to fetch Batches" ) )
44+ } , [ ] ) ;
3545
36- const batches : Batch [ ] = [ ] ;
46+ const passFailBatch = ( batch : Batch ) => ( pass : boolean ) => {
47+ setRemovedMembers ( [ ...removedMembers , ...batch . members ] )
48+ }
3749
3850 return (
3951 < div className = "reveal vh-100 vw-100" >
4052 < div className = "slides w-100" data-transition = "slide" >
53+ { /* placeholder, because slideshow doesn't work unless at least one slide is present from the beginning*/ }
4154 < section data-transition = "slide" className = "vw-100" >
42- < Container className = "d-flex flex-column vh-100 px-0 d-xl-flex w-100" >
43- < h2 > Intro Evals Slideshow</ h2 >
44- { /* placeholder, because slideshow doesn't work unless at least one slide is present from the beginning*/ }
45- </ Container >
55+ < section data-transition = "slide" className = "vw-100" >
56+ < Container className = "d-flex flex-column vh-100 px-0 d-xl-flex w-100" >
57+ < h2 > Intro Evals Slideshow</ h2 >
58+ < Row className = "text-center align-self-center w-100 justify-content-center py-3" >
59+ < Col className = "col-3" >
60+ < NumberBox text = { `${ frosh . length } ` } subtext = "Intro Members" success = { true } />
61+ </ Col >
62+ < Col className = "col-3" >
63+ < NumberBox text = { `${ batches . length } ` } subtext = "Batches" success = { true } />
64+ </ Col >
65+ </ Row >
66+ </ Container >
67+ </ section >
68+ < section data-transition = "slide" className = "vw-100" >
69+ < Container className = "d-flex flex-column vh-100 px-0 d-xl-flex w-100" >
70+ < p > Hi :)</ p >
71+ </ Container >
72+ </ section >
4673 </ section >
4774 {
4875 batches . map ( ( b , i ) =>
49- < BatchSlide key = { i } name = { b . name } names = { b . names } onPassFail = { ( pass ) => setFrosh ( frosh . filter ( f => ! b . names . includes ( f . name ) ) ) } />
76+ < BatchSlide
77+ key = { i }
78+ batch = { b }
79+ onPassFail = { passFailBatch ( b ) }
80+ />
5081 )
5182 }
5283
5384 {
54- frosh . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) . map ( ( f , i ) =>
85+ frosh . filter ( f => ! removedMembers . includes ( f . name ) ) . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) . map ( ( f , i ) =>
5586 < Slide
5687 key = { i }
5788 uid = { f . uid }
0 commit comments