-
diff --git a/components/LatestScripts.tsx b/components/LatestScripts.tsx
index 032b1a4..d7f0bc8 100644
--- a/components/LatestScripts.tsx
+++ b/components/LatestScripts.tsx
@@ -36,7 +36,7 @@ function LatestScripts() {
{latestScripts.map((item) => (
diff --git a/components/Navbar.tsx b/components/Navbar.tsx
index 5ec9ebf..53d2471 100644
--- a/components/Navbar.tsx
+++ b/components/Navbar.tsx
@@ -28,9 +28,13 @@ import {
} from "@/components/ui/accordion";
import { Input } from "@/components/ui/input";
import { Category } from "@/lib/types";
+import { pb } from "@/lib/pocketbase";
function Navbar() {
const [isScrolled, setIsScrolled] = useState(false);
+ const [links, setLinks] = useState([]);
+ const [searchTerm, setSearchTerm] = useState("");
+ const inputRef = useRef(null);
useEffect(() => {
const handleScroll = () => {
@@ -44,10 +48,6 @@ function Navbar() {
};
}, []);
- const [links, setLinks] = useState([]);
- const [searchTerm, setSearchTerm] = useState("");
- const inputRef = useRef(null);
-
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === "/") {
@@ -62,33 +62,33 @@ function Navbar() {
};
}, []);
- const fetchLinks = async () => {
- try {
- const res = await fetch(
- `${process.env.NEXT_PUBLIC_POCKETBASE_URL}/api/collections/proxmox_items/records`,
- );
- const data = await res.json();
- setLinks(data.items as Category[]);
- } catch (error) {
- console.error("Error fetching links:", error);
- }
- };
+ const fetchLinks = async () => {
+ try {
+ // you can also fetch all records at once via getFullList
+ const res = await pb.collection("categories").getFullList({
+ expand: "items",
+ });
+ setLinks(res as unknown as Category[]);
+ } catch (error) {
+ console.error("Error fetching links:", error);
+ }
+ };
- useEffect(() => {
- fetchLinks();
- }, []);
+ useEffect(() => {
+ fetchLinks();
+ }, []);
- const handleSearch = (value: string) => {
- setSearchTerm(value);
- };
+ const handleSearch = (value: string) => {
+ setSearchTerm(value);
+ };
- const filteredLinks = useMemo(() => {
- return links.filter((category) =>
- category.Items.some((script) =>
- script.title.toLowerCase().includes(searchTerm.toLowerCase()),
- ),
- );
- }, [links, searchTerm]);
+ const filteredLinks = useMemo(() => {
+ return links.filter((category) =>
+ category.expand.items.some((script) =>
+ script.title.toLowerCase().includes(searchTerm.toLowerCase()),
+ ),
+ );
+ }, [links, searchTerm]);
return (
<>
@@ -129,33 +129,33 @@ function Navbar() {
>
{filteredLinks.map((category) => (
- {category.Catagory_Title}
+ {category.catagoryName}
- {category.Items.filter((script) =>
- script.title
- .toLowerCase()
- .includes(searchTerm.toLowerCase()),
- ).map((script, index) => (
-
-
+ {category.expand.items
+ .filter((script) =>
+ script.title
+ .toLowerCase()
+ .includes(searchTerm.toLowerCase()),
+ )
+ .map((script, index) => (
+
- {script.title}
+ {script.title} {script.item_type}
-
-
- ))}
+
+ ))}
))}