import React, { ChangeEvent, useContext, useRef, useState } from 'react'; import './PartyPage.css'; import { APIEndPoint, PartyContext } from './PartyContext'; // import MatrixBackground from './MatrixBackground'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faAngleDown, faCalendarDays, faLocationDot } from '@fortawesome/free-solid-svg-icons'; import { modifySelfRequest, parseURI } from './partyApi'; const myDear = { "m": "lieber", "f": "liebe", "d": "liebes", }; export const PartyPage: React.FC = () => { const partyContext = useContext(PartyContext); const dear = myDear[partyContext.self.grammatical_gender]; const name = partyContext.self.name; const party = partyContext.party; const wannUndWoRef = useRef(null) const executeScroll = () => { wannUndWoRef.current!.scrollIntoView({ behavior: 'smooth' }) } const [comingState, setComingState] = useState(partyContext.self.coming); // SAFETY: If this is undefined, the contextProvider already fails // eslint-disable-next-line no-restricted-globals const endpoint = parseURI(location.href) as APIEndPoint; const handleSelect = async (e: ChangeEvent) => { const value = (e.target as HTMLInputElement).value; if (value !== "yes" && value !== "no" && value !== "maybe") { throw new Error("received invalid value?"); } const status = await modifySelfRequest(endpoint, { coming: value }); setComingState(status.coming); } let coming: string; if (party.maybe_coming === 0) { // exact number if (party.definitely_coming === 0) { coming = "Bisher hat noch niemand zugesagt." } else if (party.definitely_coming === 1) { coming = "Bisher hat ein Gast zugesagt." } else { coming = `Es haben schon ${party.definitely_coming} Gäste zugesagt.` } } else { // inexact if (party.definitely_coming === 0 && party.maybe_coming === 1) { coming = "Bisher hat ein Gast vorläufig zugesagt." } else if (party.definitely_coming === 0) { coming = `Bisher haben ${party.maybe_coming} Gäste vorläufig zugesagt.` } else { // eslint-disable-next-line coming = `Nach den bisherigen Zusagen kommen ${party.definitely_coming} bis ${party.definitely_coming + party.maybe_coming} Gäste.` } } return

Hallo {dear} {name},

am 16. Dezember wird die Heizung der Universität das letzte Mal angeschaltet... Diese Chance, Energie zu schnorren, wollen wir noch einmal nutzen.

Daher veranstalten wir ab 18:00 eine Weihnachtsparty! Wir rechnen mit ca. 20 Teilnehmern.

Wir würden uns sehr freuen, wenn auch du, {dear} {name}, dabei wärst :)

Mehr Infos

Wann und Wo?

16. Dezember, ab 18:00. Bitte komme nach Möglichkeit pünktlich.

Gebäude E1 1, Raum 407

Was ist geplant?

Wir werden gemeinsam einen weihnachtlichen Abend verbringen. Dazu gibt es natürlich Glühwein, Kinderpunsch, und weitere Getränke.

Was gibt es zu Essen?

Potluck, etc. Bitte uns schreiben was mitgebracht wird.

Noch Programmpunkte

Willst du etwas anbieten? Gerne!

};