diff --git a/src/app/feedback-form/page.tsx b/src/app/feedback-form/page.tsx deleted file mode 100644 index 96c1213..0000000 --- a/src/app/feedback-form/page.tsx +++ /dev/null @@ -1,80 +0,0 @@ -"use client"; -import { useEffect } from "react"; -import { useRouter } from "next/navigation"; -import Loading from "@/ui/Loading"; -import { Container } from "@mui/material"; - -const fetchLocation = async (router: any) => { - try { - const res = await fetch(`${process.env.NEXT_PUBLIC_RESTDB_URL!}/location`, { - method: "GET", - headers: { - "cache-control": "no-cache", - "Content-Type": "application/json", - "x-apikey": process.env.NEXT_PUBLIC_RESTDB_KEY! - } - }); - const data = await res.json(); - await getClientLocation(); - if (data.length <= 2) { - router.push("/?feedback=true"); - } else { - window.location.href = process.env.NEXT_PUBLIC_FEEDBACK_FORM_URL!; - } - } catch (error) { - window.location.href = process.env.NEXT_PUBLIC_FEEDBACK_FORM_URL!; - } -}; - -const getClientLocation = async () => { - try { - const res = await fetch(`https://ipinfo.io/json?token=${process.env.NEXT_PUBLIC_IP_TOKEN}`); - const locationData = await res.json(); - - await fetch(`${process.env.NEXT_PUBLIC_RESTDB_URL!}/location`, { - method: "POST", - headers: { - "cache-control": "no-cache", - "Content-Type": "application/json", - "x-apikey": "673d7d6e126911526217aacb" - }, - body: JSON.stringify(locationData) - }); - } catch (error) { - await fetch(`${process.env.NEXT_PUBLIC_RESTDB_URL!}/location`, { - method: "POST", - headers: { - "cache-control": "no-cache", - "Content-Type": "application/json", - "x-apikey": "673d7d6e126911526217aacb" - }, - body: JSON.stringify(error) - }); - console.error(error); - } -}; - -export default function RedirectToHome() { - const router = useRouter(); - - useEffect(() => { - fetchLocation(router); - }, [router]); - - return ( - - - - ); -} diff --git a/src/app/page.tsx b/src/app/page.tsx index 7e08a80..fc5fb08 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,23 +1,9 @@ -"use client"; import { Box, Divider, Grid, IconButton, Link, Stack, Tooltip, Typography } from "@mui/material"; import { links } from "@/utils/links"; import Image from "next/image"; import AnimatedTextComponent from "@/ui/HomePageCaption"; -type Params = Promise<{ slug: string }>; -type SearchParams = Promise<{ [key: string]: string | string[] | undefined }>; - -// eslint-disable-next-line @next/next/no-async-client-component -export default async function Home(props: { params: Params; searchParams: SearchParams }) { - const params = await props.params; - const searchParams = await props.searchParams; - - if (searchParams && searchParams["feedback"]) { - setTimeout(() => { - window.location.href = process.env.NEXT_PUBLIC_FEEDBACK_FORM_URL!; - }, 5000); - } - +export default function Home() { const iconLink = (link: any) => { return (