import React, { HTMLProps, useEffect } from 'react'; import { Link, Route, Switch } from "react-router-dom" import { processMiddlewares, route, routes } from "@/routing"; import { useSelector } from "react-redux"; import { AppState } from "@/state/reducer"; 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 { SettingActions } from "@/state/actions/settings"; import { useDispatch, UserActions } from "@/state/actions"; import { getLocale, Locale } from "@/state/reducer/settings"; import i18n from "@/i18n"; import moment from "moment-timezone"; 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 handleUserLogout = () => { dispatch({ type: UserActions.Logout }) } return { student ? <> logged in as { { name: `${ student.name } ${ student.surname }` } } { ' ' } ({ t('logout') }) > : <> { t('login') } > } ; } 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 { t } = useTranslation(); const locale = useSelector(state => getLocale(state.settings)); useEffect(() => { i18n.changeLanguage(locale); document.documentElement.lang = locale; moment.locale(locale) }, [ locale ]) return <> { t("pages.my-internship.header") } Regulamin { { routes.map(({ name, content, middlewares = [], ...route }) => { processMiddlewares([ ...middlewares, content ]) } ) } } >; } export default App;