Merge branch 'main' of https://github.com/VAR-Virtual-Air-Rescue/var-monorepo
This commit is contained in:
@@ -1,19 +1,54 @@
|
||||
"use client";
|
||||
|
||||
import { MessageSquareWarning } from "lucide-react";
|
||||
import { MessageForm } from "./_components/messageForm";
|
||||
import { PaginatedTable } from "_components/PaginatedTable";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
import { Notam } from "@repo/db";
|
||||
|
||||
export default function MessagePage() {
|
||||
return (
|
||||
<div className="grid grid-cols-6 gap-4">
|
||||
<div className="col-span-full">
|
||||
<p className="text-2xl font-semibold text-left flex items-center gap-2">
|
||||
<MessageSquareWarning className="w-5 h-5" /> Service Nachrichten
|
||||
</p>
|
||||
</div>
|
||||
<div className="card bg-base-200 shadow-xl mb-4 col-span-6">
|
||||
<div className="card-body">
|
||||
<MessageForm />
|
||||
<>
|
||||
<div className="grid grid-cols-6 gap-4">
|
||||
<div className="col-span-full">
|
||||
<p className="text-2xl font-semibold text-left flex items-center gap-2">
|
||||
<MessageSquareWarning className="w-5 h-5" /> Service Nachrichten
|
||||
</p>
|
||||
</div>
|
||||
<div className="card bg-base-200 shadow-xl mb-4 col-span-6">
|
||||
<div className="card-body">
|
||||
<MessageForm />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<PaginatedTable
|
||||
prismaModel="notam"
|
||||
columns={
|
||||
[
|
||||
{
|
||||
accessorKey: "message",
|
||||
header: "Nachricht",
|
||||
},
|
||||
{
|
||||
accessorKey: "color",
|
||||
header: "Status",
|
||||
cell: ({ row }) => {
|
||||
const color = row.getValue("color");
|
||||
return color;
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "createdAt",
|
||||
header: "Erstellt am",
|
||||
sortDescFirst: false,
|
||||
cell: ({ cell }) => {
|
||||
const date = new Date(cell.getValue() as string);
|
||||
return date.toLocaleDateString();
|
||||
},
|
||||
},
|
||||
] as ColumnDef<Notam>[]
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,15 @@ import {
|
||||
} from "@radix-ui/react-icons";
|
||||
import Link from "next/link";
|
||||
import { WarningAlert } from "./ui/PageAlert";
|
||||
import { getServerSession } from "api/auth/[...nextauth]/auth";
|
||||
import { Error } from "./Error";
|
||||
|
||||
export const VerticalNav = () => {
|
||||
export const VerticalNav = async () => {
|
||||
const session = await getServerSession();
|
||||
if (!session?.user) return <Error statusCode={401} title="Benutzer nicht authentifiziert!" />;
|
||||
const viewAdminMenu = session.user.permissions.some((p) => {
|
||||
return p.startsWith("ADMIN");
|
||||
});
|
||||
return (
|
||||
<ul className="menu w-64 bg-base-300 p-3 rounded-lg shadow-md font-semibold">
|
||||
<li>
|
||||
@@ -35,34 +42,48 @@ export const VerticalNav = () => {
|
||||
Einstellungen
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary>
|
||||
<LockClosedIcon />
|
||||
Admin
|
||||
</summary>
|
||||
<ul>
|
||||
<li>
|
||||
<Link href="/admin/user">Benutzer</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/admin/station">Stationen</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/admin/keyword">Stichworte</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/admin/event">Events</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/admin/message">Service Nachrichten</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/admin/report">Reports</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
{viewAdminMenu && (
|
||||
<li>
|
||||
<details open>
|
||||
<summary>
|
||||
<LockClosedIcon />
|
||||
Admin
|
||||
</summary>
|
||||
<ul>
|
||||
{session.user.permissions.includes("ADMIN_USER") && (
|
||||
<li>
|
||||
<Link href="/admin/user">Benutzer</Link>
|
||||
</li>
|
||||
)}
|
||||
{session.user.permissions.includes("ADMIN_STATION") && (
|
||||
<li>
|
||||
<Link href="/admin/station">Stationen</Link>
|
||||
</li>
|
||||
)}
|
||||
{session.user.permissions.includes("ADMIN_KEYWORD") && (
|
||||
<li>
|
||||
<Link href="/admin/keyword">Stichworte</Link>
|
||||
</li>
|
||||
)}
|
||||
{session.user.permissions.includes("ADMIN_EVENT") && (
|
||||
<li>
|
||||
<Link href="/admin/event">Events</Link>
|
||||
</li>
|
||||
)}
|
||||
{session.user.permissions.includes("ADMIN_MESSAGE") && (
|
||||
<li>
|
||||
<Link href="/admin/message">Service Nachrichten</Link>
|
||||
</li>
|
||||
)}
|
||||
{session.user.permissions.includes("ADMIN_USER") && (
|
||||
<li>
|
||||
<Link href="/admin/report">Reports</Link>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@ enum PERMISSION {
|
||||
AUDIO_ADMIN
|
||||
ADMIN_STATION
|
||||
ADMIN_KEYWORD
|
||||
ADMIN_MESSAGE
|
||||
AUDIO
|
||||
PILOT
|
||||
DISPO
|
||||
|
||||
Reference in New Issue
Block a user