|
| 1 | +import { useEffect, useReducer, useState } from "react" |
| 2 | +import Reveal from "reveal.js"; |
| 3 | +import Slide from "./Slide" |
| 4 | +import 'reveal.js/dist/reset.css' |
| 5 | +import 'reveal.js/dist/reveal.css' |
| 6 | +import 'reveal.js/dist/theme/white.css' |
| 7 | +import './index.css' |
| 8 | +import { IntroEvalsSummary } from "../../API/Types"; |
| 9 | +import { getJSON, toastError } from "../../API/API"; |
| 10 | +import { Container } from "reactstrap"; |
| 11 | +import BatchSlide from "./BatchSlide"; |
| 12 | + |
| 13 | +const IntroEvalsSlideshow = () => { |
| 14 | + |
| 15 | + const initSlides = () => { |
| 16 | + let slides = new Reveal({ |
| 17 | + backgroundTransition: 'slide', |
| 18 | + transition: 'slide' |
| 19 | + }); |
| 20 | + slides.initialize(); |
| 21 | + } |
| 22 | + |
| 23 | + const [frosh, setFrosh] = useState<IntroEvalsSummary[]>([]); |
| 24 | + |
| 25 | + useEffect(() => { |
| 26 | + getJSON<IntroEvalsSummary[]>("/api/evals/intro") |
| 27 | + .then(setFrosh).then(initSlides) |
| 28 | + .catch(toastError("Unable to fetch Intro Evals data")); |
| 29 | + }, []) |
| 30 | + |
| 31 | + interface Batch { |
| 32 | + name: string, |
| 33 | + names: string[], |
| 34 | + } |
| 35 | + |
| 36 | + const batches: Batch[] = []; |
| 37 | + |
| 38 | + return ( |
| 39 | + <div className="reveal vh-100 vw-100"> |
| 40 | + <div className="slides w-100" data-transition="slide"> |
| 41 | + <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> |
| 46 | + </section> |
| 47 | + { |
| 48 | + 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)))} /> |
| 50 | + ) |
| 51 | + } |
| 52 | + |
| 53 | + { |
| 54 | + frosh.sort((a, b) => a.name.localeCompare(b.name)).map((f, i) => |
| 55 | + <Slide |
| 56 | + key={i} |
| 57 | + uid={f.uid} |
| 58 | + name={f.name} |
| 59 | + packet={Math.trunc(100 * f.signatures / f.max_signatures)} |
| 60 | + hm_absences={f.missed_hms} |
| 61 | + directorships={f.directorships} |
| 62 | + seminars={f.seminars} />) |
| 63 | + } |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + |
| 67 | + ) |
| 68 | +} |
| 69 | + |
| 70 | +export default IntroEvalsSlideshow |
0 commit comments