Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import { Typography } from "@mui/material"; import Button from "components/Button"; import TOSLink from "components/TOSLink"; import { Trans, useTranslation } from "i18n"; import { AUTH, GLOBAL } from "i18n/namespaces"; import { useState } from "react"; import { service } from "service"; interface TOSSectionProps { updateJailed: () => void; className?: string; } export default function TOSSection({ updateJailed, className, }: TOSSectionProps) { const { t } = useTranslation([AUTH, GLOBAL]); const [completed, setCompleted] = useState(false); const [loading, setLoading] = useState(false); const accept = async () => { setLoading(true); const info = await service.jail.acceptTOS(); if (!info.isJailed) { updateJailed(); } else { //if user is no longer jailed, this component will be unmounted anyway setLoading(false); setCompleted(true); } }; return ( <div className={className}> <Typography variant="body1"> <Trans t={t} i18nKey="auth:jail.terms_of_service_section.description"> We've update our Terms of Service. To continue, please read and accept the new <TOSLink /> </Trans> </Typography> <Button loading={loading} onClick={accept} disabled={completed}> {completed ? t("global:thanks") : t("global:accept")} </Button> </div> ); } |