diff --git a/app/api/projects/route.ts b/app/api/projects/[id]/.temp similarity index 100% rename from app/api/projects/route.ts rename to app/api/projects/[id]/.temp diff --git a/app/api/services/[id]/route.ts b/app/api/services/[id]/route.ts index 49402bb..7a0914c 100644 --- a/app/api/services/[id]/route.ts +++ b/app/api/services/[id]/route.ts @@ -1,6 +1,9 @@ const BACKEND_URL = process.env.BACKEND_URL; -export async function GET({ params }: { params: Promise<{ id: string }> }) { +export async function GET( + _request: Request, + { params }: { params: Promise<{ id: string }> }, +) { const { id } = await params; const response = await fetch(`${BACKEND_URL}/services/${id}`); @@ -15,7 +18,10 @@ export async function GET({ params }: { params: Promise<{ id: string }> }) { return Response.json(data); } -export async function DELETE({ params }: { params: Promise<{ id: string }> }) { +export async function DELETE( + _request: Request, + { params }: { params: Promise<{ id: string }> }, +) { const { id } = await params; const response = await fetch(`${BACKEND_URL}/services/${id}`, { method: "DELETE", diff --git a/app/api/services/route.ts b/app/api/services/route.ts index 7c2920f..6c2c440 100644 --- a/app/api/services/route.ts +++ b/app/api/services/route.ts @@ -1,8 +1,6 @@ const BACKEND_URL = process.env.BACKEND_URL; export async function GET() { - console.log("Made it to the GET SERVICES ROUTE!"); - const response = await fetch(`${BACKEND_URL}/services/all`); if (!response.ok) { diff --git a/app/api/users/[id]/route.ts b/app/api/users/[id]/.temp similarity index 100% rename from app/api/users/[id]/route.ts rename to app/api/users/[id]/.temp diff --git a/components/layout/Header.tsx b/components/layout/Header.tsx index 19eeb69..3da5a84 100644 --- a/components/layout/Header.tsx +++ b/components/layout/Header.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { useEffect, useState } from "react"; + import Hyperlink from "@/components/ui/Hyperlink"; import { getServices } from "@/lib/api/helpers/services"; import { Service } from "@/lib/api/types"; @@ -40,11 +44,19 @@ const defaultServices: Service[] = [ }, ]; -export default async function Header() { - let services = await getServices(); - if (services.length < 1) { - services = defaultServices; - } +export default function Header() { + const [services, setServices] = useState(defaultServices); + useEffect(() => { + getServices() + .then((services) => { + if (services.length > 0) { + setServices(services); + } + }) + .catch(() => { + // Keep default services if the backend is not reached :C + }); + }, []); return (