From 857c528369473a66518407dee6f6cac89bbc538c Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Wed, 15 Nov 2023 19:29:24 +0100 Subject: Initial commit, v1.0.0 --- src/Router.tsx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/Router.tsx (limited to 'src/Router.tsx') diff --git a/src/Router.tsx b/src/Router.tsx new file mode 100644 index 0000000..eb4cf21 --- /dev/null +++ b/src/Router.tsx @@ -0,0 +1,30 @@ +import { useEffect, useState } from "react"; +import Search from "./Search"; +import Table from "./Table"; + +const startPath = + location.pathname.at(-1) === "/" + ? location.pathname + : location.pathname + "/"; +export default function Router() { + const [path, setPath] = useState(""); + useEffect(() => { + setPath(location.pathname); + }, []); + window.addEventListener("popstate", () => { + setPath(location.pathname); + }); + + function updatePath(newPath: string) { + console.log({ newPath, startPath }); + const path = startPath + newPath; + history.pushState({}, "", path); + setPath(path); + } + + if (path.includes("/nagrody/")) { + return ; + } else { + return ; + } +} -- cgit v1.3.1