Skip to content

Commit

Permalink
Merge pull request #415 from Open-Earth-Foundation/fix/page-navigatio…
Browse files Browse the repository at this point in the history
…n-and-routing

Fix/page navigation and routing
  • Loading branch information
cephaschapa authored Apr 3, 2024
2 parents b60f89a + dbbdcb2 commit 017540b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
41 changes: 41 additions & 0 deletions app/src/app/[lng]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"use client";
import { api } from "@/services/api";
import { Box, Spinner, Text } from "@chakra-ui/react";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import { useTranslation } from "@/i18n/client";

export default function HomePage({
params: { lng },
}: {
params: { lng: string };
}) {
const { t } = useTranslation(lng, "root-page");
const router = useRouter();
const { data: userInfo, isLoading: isUserInfoLoading } =
api.useGetUserInfoQuery();

useEffect(() => {
const defaultInventoryAvailable = !!userInfo?.defaultInventoryId;
const defaultInventoryPath = `/${userInfo?.defaultInventoryId}`;
if (defaultInventoryAvailable) {
router.push(defaultInventoryPath);
} else {
router.push("/onboarding");
}
}, [router, userInfo]);
return (
<Box
h="100vh"
w="full"
display="flex"
alignItems="center"
justifyContent="center"
gap="8px"
>
<Spinner />
{/* TODO: add right loading format */}
<Text>{t("loading-dashboard")}</Text>
</Box>
);
}
3 changes: 3 additions & 0 deletions app/src/i18n/locales/de/root-page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"loading-dashboard": "Lade Dashboard..."
}
3 changes: 3 additions & 0 deletions app/src/i18n/locales/en/root-page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"loading-dashboard": "Loading dashboard..."
}
3 changes: 3 additions & 0 deletions app/src/i18n/locales/es/root-page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"loading-dashboard": "Loading dashboard..."
}

0 comments on commit 017540b

Please sign in to comment.