Files
element-call/src/home/HomePage.tsx

36 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-08-19 17:49:45 -07:00
/*
Copyright 2021-2024 New Vector Ltd.
2021-08-19 17:49:45 -07:00
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
2021-08-19 17:49:45 -07:00
*/
2022-10-10 09:19:10 -04:00
import { useTranslation } from "react-i18next";
import { type FC } from "react";
2022-07-28 00:17:09 +02:00
import { useClientState } from "../ClientContext";
import { ErrorPage, LoadingPage } from "../FullScreenView";
2022-01-04 17:09:27 -08:00
import { UnauthenticatedView } from "./UnauthenticatedView";
import { RegisteredView } from "./RegisteredView";
2022-02-02 15:02:40 -08:00
import { usePageTitle } from "../usePageTitle";
import { widget } from "../widget.ts";
2021-12-09 12:58:30 -08:00
export const HomePage: FC = () => {
2022-10-10 09:19:10 -04:00
const { t } = useTranslation();
usePageTitle(t("common.home"));
2022-02-02 15:02:40 -08:00
const clientState = useClientState();
2021-12-17 15:01:59 -08:00
if (!clientState) {
return <LoadingPage />;
} else if (clientState.state === "error") {
return <ErrorPage widget={widget} error={clientState.error} />;
2021-12-10 10:54:18 -08:00
} else {
return clientState.authenticated ? (
2023-09-18 11:06:06 -04:00
<RegisteredView client={clientState.authenticated.client} />
2022-01-04 16:00:13 -08:00
) : (
<UnauthenticatedView />
2021-12-10 10:54:18 -08:00
);
}
};