diff --git a/src/app/(calculators)/calculators/page.tsx b/src/app/(calculators)/calculators/page.tsx index dcca6e2..7b28516 100644 --- a/src/app/(calculators)/calculators/page.tsx +++ b/src/app/(calculators)/calculators/page.tsx @@ -1,44 +1,72 @@ "use client" -import { pastUsed } from "@/app/utils/calculators/types"; +import { Calculator, pastUsed } from "@/app/utils/calculators/types"; import Result from "@/app/utils/Result"; import { useEffect, useState } from "react"; - +import GetQuote from "@/app/utils/getQuote"; +import { CalculatorRegistry } from "@/app/utils/calculators/registry"; +import Bookmark from "@/app/utils/Bookmark"; export default function Calculators(){ const [pastUsedObj, setPastUsedObj] = useState([]); + const [bookmarks, setBookmarks] = useState<{id:string, section:string}[]>(); const [index, setIndex] = useState(0) useEffect(() => { - const pastUsed : string = localStorage.getItem("pastUsed") || "[]"; - setPastUsedObj(JSON.parse(pastUsed)); + const load = () => { + const stored:string = localStorage.getItem("pastUsed") || "[]"; + const parsed = JSON.parse(stored); + setPastUsedObj([...parsed]); + const rawBookmark = localStorage.getItem("bookmarks") || "[]"; + const bookmarkarr: { id: string; section: string }[] = JSON.parse(rawBookmark); + setBookmarks(bookmarkarr) + }; + load(); }, []) - - return( + return( <> -
- { - pastUsedObj.length !== 0 ? + + {pastUsedObj.length !== 0 ?
+
+

Past Results:

+
- :

Empty

- } -
- - - + +

Empty

-
- +
+
+ + + +
+
+
+
:

No past results were found

} + +
+
+

Bookmarks:

+
+ {bookmarks?.length !== 0 ? bookmarks?.map(e => { + console.log(e.id); + const calc = CalculatorRegistry[e.section].calculators.find(c => c.id === e.id) + return + }) :

empty

} +
+
+
+ ); } \ No newline at end of file diff --git a/src/app/favicon.ico b/src/app/favicon.ico index 718d6fe..d4ea296 100644 Binary files a/src/app/favicon.ico and b/src/app/favicon.ico differ diff --git a/src/app/globals.css b/src/app/globals.css index 574394d..e92c70a 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -9,6 +9,7 @@ grid-area: navbar; background: #ed1b24; color: #FFFFFF; + position:sticky; } #logo{ transform: translateY(1px); diff --git a/src/app/utils/Bookmark.tsx b/src/app/utils/Bookmark.tsx new file mode 100644 index 0000000..d39d8a6 --- /dev/null +++ b/src/app/utils/Bookmark.tsx @@ -0,0 +1,15 @@ +import Link from "next/link"; + +export default function Bookmark({id, section, name, desc}:{id:string, section:string, name:string, desc:string}){ + return( +
+
+

{name}

+

{desc}

+
+ +
+
+
+ ); +} \ No newline at end of file diff --git a/src/app/utils/Navbar.tsx b/src/app/utils/Navbar.tsx index ad0558a..8bc18ad 100644 --- a/src/app/utils/Navbar.tsx +++ b/src/app/utils/Navbar.tsx @@ -6,8 +6,8 @@ type Props = { export default function Navbar({navbarToggle}: Props){ return( -
-
+
+