import { useMemo } from "react"; import { Trans, useTranslation } from "react-i18next"; import { useHistory } from "react-router-dom"; import { useAsync } from "react-use"; import { MetaResponse, getBackendMeta } from "@/backend/accounts/meta"; import { Button } from "@/components/buttons/Button"; import { Icon, Icons } from "@/components/Icon"; import { LargeCard, LargeCardButtons, LargeCardText, } from "@/components/layout/LargeCard"; import { Loading } from "@/components/layout/Loading"; import { useBackendUrl } from "@/hooks/auth/useBackendUrl"; import { conf } from "@/setup/config"; interface TrustBackendPartProps { onNext?: (meta: MetaResponse) => void; } export function TrustBackendPart(props: TrustBackendPartProps) { const history = useHistory(); const backendUrl = useBackendUrl(); const hostname = useMemo(() => new URL(backendUrl).hostname, [backendUrl]); const result = useAsync(() => { return getBackendMeta(conf().BACKEND_URL); }, [backendUrl]); const { t } = useTranslation(); let cardContent = ( <>

{t("auth.trust.failed.title")}

{t("auth.trust.failed.text")}

); if (result.loading) cardContent = ; if (result.value) cardContent = ( <>

{result.value.name}

{result.value.description ?

{result.value.description}

: null} ); return ( } > {{ hostname }}
{cardContent}
); }