import { NextPageContext } from 'next' import { useTranslation } from 'next-i18next' import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { useState } from 'react'; import { LoginContext } from '../contexts/login'; import { useDefinedContext } from '../utils/definedContext'; import { ApiError } from '../types/api'; import { TelegramLoginButton } from "../components/TelegramLoginButton" import { useTelegramToFestaCallback } from '../hooks/useTelegramToFestaCallback'; export async function getStaticProps(context: NextPageContext) { return { props: { ...(await serverSideTranslations(context.locale ?? "it-IT", ["common"])) } } } export default function PageIndex() { const { t } = useTranslation("common") const [login, setLogin] = useDefinedContext(LoginContext) const [working, setWorking] = useState(false) const [error, setError] = useState(null) const onLogin = useTelegramToFestaCallback(setLogin, setError, setWorking) if(!login) return (

{t("siteTitle")}

{t("siteSubtitle")}

{error ?

{t("telegramLoginError")}

{JSON.stringify(error)}

: working ?

{t("telegramLoginWorking")}

:

{t("telegramLoginDescription")}

}
) return (

{t("siteTitle")}

{t("eventsSubtitleFirst")}

) }