Skip to content

Commit

Permalink
Merge pull request #1146 from Open-Earth-Foundation/fix/404-after-login
Browse files Browse the repository at this point in the history
fix(ui): redirect to /onboarding when inventory is missing
  • Loading branch information
lemilonkh authored Feb 21, 2025
2 parents e6a950a + 8793c21 commit dcb294f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions app/src/app/[...not_found]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";
import { Button } from "@/components/ui/button";
import { useTranslation } from "@/i18n/client";
import { api } from "@/services/api";

import { Text, Box, Icon } from "@chakra-ui/react";
import Image from "next/image";
Expand All @@ -10,8 +9,6 @@ import React from "react";
import { MdArrowForward } from "react-icons/md";

const NotFound = ({ params: { lng } }: { params: { lng: string } }) => {
const { data: userInfo, isLoading: isUserInfoLoading } =
api.useGetUserInfoQuery();
const router = useRouter();
const { t } = useTranslation(lng, "not-found");

Expand Down Expand Up @@ -54,12 +51,11 @@ const NotFound = ({ params: { lng } }: { params: { lng: string } }) => {
{t("not-found-description")}
</Text>
<Button
onClick={() => router.push(`/${userInfo?.defaultInventoryId}`)}
onClick={() => router.push("/")}
gap="8px"
h="48px"
px="24px"
fontSize="body.md"
loading={isUserInfoLoading}
>
{t("goto-dashboard")}
<Icon as={MdArrowForward} />
Expand Down
6 changes: 3 additions & 3 deletions app/src/components/missing-inventory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const MissingInventory = ({ lng }: { lng: string }) => {
const router = useRouter();
useEffect(() => {
if (!isUserInfoLoading && !userInfo?.defaultInventoryId) {
router.push("onboarding");
router.push("/onboarding");
}
}, [isUserInfoLoading, userInfo, router]);

Expand Down Expand Up @@ -66,7 +66,7 @@ const MissingInventory = ({ lng }: { lng: string }) => {
className="underline text-nowrap"
fontWeight="semibold"
color="content.link"
href="mailto:greta@openearth.com, ux@openearth.com"
href={"mailto://" + process.env.NEXT_PUBLIC_SUPPORT_EMAILS}
>
{t("please_contact_us")}
</Link>{" "}
Expand All @@ -76,7 +76,7 @@ const MissingInventory = ({ lng }: { lng: string }) => {
router.push(
userInfo?.defaultInventoryId
? `/${userInfo?.defaultInventoryId}`
: "onboarding",
: "/onboarding",
)
}
gap="8px"
Expand Down

0 comments on commit dcb294f

Please sign in to comment.