Updated navbar

This commit is contained in:
brian 2023-11-18 00:39:05 -05:00
parent 81886c79ee
commit 53c9365d81
5 changed files with 82 additions and 41 deletions

View file

@ -3,7 +3,7 @@ import { Inter } from 'next/font/google'
import './globals.css' import './globals.css'
import { ThemeProvider } from '@/components/theme-provider' import { ThemeProvider } from '@/components/theme-provider'
import { Toaster } from '@/components/ui/toaster' import { Toaster } from '@/components/ui/toaster'
import Navbar from '@/components/Navbar' import { Navbar } from '@/components/Navbar'
const inter = Inter({ subsets: ['latin'] }) const inter = Inter({ subsets: ['latin'] })

View file

@ -4,6 +4,8 @@ import { CardTitle, Card, CardDescription, CardHeader, CardContent, CardFooter }
import RouteCards from '@/components/RouteCards'; import RouteCards from '@/components/RouteCards';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { useRoutes } from '@/lib/clientActions'; import { useRoutes } from '@/lib/clientActions';
import Image from 'next/image';
import Loading from '@/components/Loading';
export default function Home() { export default function Home() {
@ -13,14 +15,12 @@ export default function Home() {
if (error) return <div>Error loading routes</div> if (error) return <div>Error loading routes</div>
if(isLoading) return ( if(isLoading) return (
<div className='justify-center'> <Loading />
Loading...
</div>
) )
return ( return (
<main> <main>
<div className='flex items-center justify-center p-2'> <div className='flex items-center justify-center p-6'>
<Card className='flex'> <Card className='flex'>
<CardHeader> <CardHeader>
<CardTitle>Active Routes</CardTitle> <CardTitle>Active Routes</CardTitle>

View file

@ -1,7 +1,52 @@
export default function Navbar() { "use client"
import * as React from "react"
import Link from "next/link"
import { cn } from "@/lib/utils"
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
navigationMenuTriggerStyle,
} from "@/components/ui/navigation-menu"
import ListItem from "./ListItem"
import { Avatar, AvatarFallback } from "./ui/avatar"
export function Navbar() {
return ( return (
<div className='bg-red-500 flex items-center justify-center h-12'> <div className="flex justify-center h-12 translate-y-2">
<p>Navbar</p> <NavigationMenu className="border rounded p-4 h-14">
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuTrigger>Caddy</NavigationMenuTrigger>
<NavigationMenuContent>
<ul className="grid w-[400px] gap-3 p-4 md:w-[500px] md:grid-cols-2 lg:w-[600px] ">
<ListItem
title="Route Manager"
href={'/'}>
Easy add, edit, and delete routes all from one place.
</ListItem>
</ul>
</NavigationMenuContent>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuTrigger>Panel</NavigationMenuTrigger>
<NavigationMenuContent>
<ul className="grid w-[400px] gap-3 p-4 md:w-[500px] md:grid-cols-2 lg:w-[600px] ">
<ListItem
title="Route Manager"
href={'/'}>
Easy add, edit, and delete routes all from one place.
</ListItem>
</ul>
</NavigationMenuContent>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
</div> </div>
) )
} }

View file

@ -21,21 +21,15 @@
return server; return server;
} }
export async function deleteRoute(route: Route, index: number = 0) { export async function deleteRoute(url: any, { arg }: { arg: Route }) {
let res = await fetch("http://localhost:3000/api/caddy/routes", { return fetch(url, {
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
cache: 'no-cache', cache: 'no-cache',
body: JSON.stringify(route) body: JSON.stringify(arg)
}).then((res) => res.json());
}).catch((e) => {
console.log(e)
throw new Error('Failed to remove route. Please check the network and try again.');
});
return res.json();
} }
export async function getUpstreamRequests(route: Route) { export async function getUpstreamRequests(route: Route) {

View file

@ -9,7 +9,9 @@
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5", "@radix-ui/react-toast": "^1.1.5",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",