2021-08-19 17:49:45 -07:00
|
|
|
/*
|
|
|
|
|
Copyright 2021 New Vector Ltd
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-10-10 09:19:10 -04:00
|
|
|
import { useTranslation } from "react-i18next";
|
2023-09-22 18:05:13 -04:00
|
|
|
import { FC } from "react";
|
2022-07-28 00:17:09 +02:00
|
|
|
|
2023-06-30 16:43:28 +01:00
|
|
|
import { useClientState } from "../ClientContext";
|
2022-01-04 17:09:27 -08:00
|
|
|
import { ErrorView, LoadingView } from "../FullScreenView";
|
|
|
|
|
import { UnauthenticatedView } from "./UnauthenticatedView";
|
|
|
|
|
import { RegisteredView } from "./RegisteredView";
|
2022-02-02 15:02:40 -08:00
|
|
|
import { usePageTitle } from "../usePageTitle";
|
2021-12-09 12:58:30 -08:00
|
|
|
|
2023-09-22 18:05:13 -04:00
|
|
|
export const HomePage: FC = () => {
|
2022-10-10 09:19:10 -04:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
usePageTitle(t("Home"));
|
2022-02-02 15:02:40 -08:00
|
|
|
|
2023-06-30 16:43:28 +01:00
|
|
|
const clientState = useClientState();
|
2021-12-17 15:01:59 -08:00
|
|
|
|
2023-06-30 16:43:28 +01:00
|
|
|
if (!clientState) {
|
2021-12-10 16:42:18 -08:00
|
|
|
return <LoadingView />;
|
2023-06-30 16:43:28 +01:00
|
|
|
} else if (clientState.state === "error") {
|
|
|
|
|
return <ErrorView error={clientState.error} />;
|
2021-12-10 10:54:18 -08:00
|
|
|
} else {
|
2023-06-30 16:43:28 +01:00
|
|
|
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
|
|
|
);
|
|
|
|
|
}
|
2023-09-22 18:05:13 -04:00
|
|
|
};
|