import React, { HTMLProps, useEffect } from 'react'; import { Link, Route, Switch } from "react-router-dom" import { route, routes } from "@/routing"; import { useSelector } from "react-redux"; import { AppState, isReady } from "@/state/reducer"; import { StudentActions } from "@/state/actions/student"; import { sampleStudent } from "@/provider/dummy/student"; import { Trans, useTranslation } from "react-i18next"; import { Student } from "@/data"; import '@/styles/overrides.scss' import '@/styles/header.scss' import '@/styles/footer.scss' import classNames from "classnames"; import { EditionActions } from "@/state/actions/edition"; import { sampleEdition } from "@/provider/dummy/edition"; import { Edition } from "@/data/edition"; import { SettingActions } from "@/state/actions/settings"; import { useDispatch } from "@/state/actions"; import { getLocale, Locale } from "@/state/reducer/settings"; import i18n from "@/i18n"; import moment from "moment"; import { Container } from "@material-ui/core"; const UserMenu = (props: HTMLProps) => { const student = useSelector(state => state.student as Student); const dispatch = useDispatch(); const { t } = useTranslation(); const handleUserLogin = () => { dispatch({ type: StudentActions.Login, student: sampleStudent, }) } const handleUserLogout = () => { dispatch({ type: StudentActions.Logout }) } return ; } const LanguageSwitcher = ({ className, ...props }: HTMLProps) => { const { i18n } = useTranslation(); const dispatch = useDispatch(); const handleLanguageChange = (language: Locale) => () => { dispatch({ type: SettingActions.SetLocale, locale: language }) } const isActive = (language: string) => language.toLowerCase() === i18n.language.toLowerCase(); return
    { ['pl', 'en'].map(language =>
  • { language }
  • ) }
} function App() { const dispatch = useDispatch(); const edition = useSelector(state => state.edition); const { t } = useTranslation(); const locale = useSelector(state => getLocale(state.settings)); useEffect(() => { if (!edition) { dispatch({ type: EditionActions.Set, edition: sampleEdition }); } }) useEffect(() => { i18n.changeLanguage(locale); document.documentElement.lang = locale; moment.locale(locale) }, [ locale ]) const ready = useSelector(isReady); return <>
{ ready && { routes.map(({ name, content, ...route }) => { content() }) } }
; } export default App;