-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #415 from Open-Earth-Foundation/fix/page-navigatio…
…n-and-routing Fix/page navigation and routing
- Loading branch information
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"loading-dashboard": "Lade Dashboard..." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"loading-dashboard": "Loading dashboard..." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"loading-dashboard": "Loading dashboard..." | ||
} |