import { useMemo } from "react"; import { useHistory } from "react-router-dom"; import { useAsync } from "react-use"; import { MetaResponse, getBackendMeta } from "@/backend/accounts/meta"; import { Button } from "@/components/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 backendHostname = useMemo( () => new URL(backendUrl).hostname, [backendUrl] ); const result = useAsync(() => { return getBackendMeta(conf().BACKEND_URL); }, [backendUrl]); let cardContent = ( <>

Failed to reach backend

Did you configure it correctly?

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

{result.value.name}

{result.value.description ?

{result.value.description}

: null} ); return ( } > Do you trust {backendHostname}?
{cardContent}
); }