fixed styles, improved PaginatedTableStyling

This commit is contained in:
PxlLoewe
2025-02-22 23:20:46 +01:00
parent 52888787cf
commit cd5c57beba
11 changed files with 87 additions and 69 deletions

View File

@@ -5,16 +5,6 @@ import Link from 'next/link';
export default () => { export default () => {
return ( return (
<> <>
<p className="text-2xl font-semibold text-left flex items-center gap-2 justify-between">
<span className="flex items-center gap-2">
<PartyPopperIcon className="w-5 h-5" /> Events
</span>
<Link href={'/admin/event/new'}>
<button className="btn btn-sm btn-outline btn-primary">
Erstellen
</button>
</Link>
</p>
<PaginatedTable <PaginatedTable
showEditButton showEditButton
prismaModel="event" prismaModel="event"
@@ -28,6 +18,18 @@ export default () => {
accessorKey: 'hidden', accessorKey: 'hidden',
}, },
]} ]}
leftOfSearch={
<span className="flex items-center gap-2">
<PartyPopperIcon className="w-5 h-5" /> Events
</span>
}
rightOfSearch={
<Link href={'/admin/event/new'}>
<button className="btn btn-sm btn-outline btn-primary">
Erstellen
</button>
</Link>
}
/> />
</> </>
); );

View File

@@ -1,42 +1,46 @@
import { DatabaseBackupIcon } from "lucide-react"; import { DatabaseBackupIcon } from 'lucide-react';
import { PaginatedTable } from "../../../_components/PaginatedTable"; import { PaginatedTable } from '../../../_components/PaginatedTable';
import Link from "next/link"; import Link from 'next/link';
export default () => { export default () => {
return ( return (
<> <>
<p className="text-2xl font-semibold text-left flex items-center gap-2 justify-between">
<span className="flex items-center gap-2">
<DatabaseBackupIcon className="w-5 h-5" /> Stationen
</span>
<Link href={"/admin/station/new"}>
<button className="btn btn-sm btn-outline btn-primary">
Erstellen
</button>
</Link>
</p>
<PaginatedTable <PaginatedTable
showEditButton showEditButton
prismaModel="station" prismaModel="station"
searchFields={["bosCallsign", "bosUse", "country", "operator"]} searchFields={['bosCallsign', 'bosUse', 'country', 'operator']}
columns={[ columns={[
{ {
header: "BOS Name", header: 'BOS Name',
accessorKey: "bosCallsign", accessorKey: 'bosCallsign',
}, },
{ {
header: "Bos Use", header: 'Bos Use',
accessorKey: "bosUse", accessorKey: 'bosUse',
}, },
{ {
header: "Country", header: 'Country',
accessorKey: "country", accessorKey: 'country',
}, },
{ {
header: "operator", header: 'operator',
accessorKey: "operator", accessorKey: 'operator',
}, },
]} ]}
leftOfSearch={
<span className="flex items-center gap-2">
<DatabaseBackupIcon className="w-5 h-5" /> Stationen
</span>
}
rightOfSearch={
<p className="text-2xl font-semibold text-left flex items-center gap-2 justify-between">
<Link href={'/admin/station/new'}>
<button className="btn btn-sm btn-outline btn-primary">
Erstellen
</button>
</Link>
</p>
}
/> />
</> </>
); );

View File

@@ -1,34 +1,36 @@
import { User2 } from "lucide-react"; import { User2 } from 'lucide-react';
import { PaginatedTable } from "../../../_components/PaginatedTable"; import { PaginatedTable } from '../../../_components/PaginatedTable';
export default async () => { export default async () => {
return ( return (
<> <>
<p className="text-2xl font-semibold text-left flex items-center gap-2">
<User2 className="w-5 h-5" /> Benutzer
</p>
<PaginatedTable <PaginatedTable
showEditButton showEditButton
prismaModel="user" prismaModel="user"
searchFields={["publicId", "firstname", "lastname", "email"]} searchFields={['publicId', 'firstname', 'lastname', 'email']}
columns={[ columns={[
{ {
header: "ID", header: 'ID',
accessorKey: "publicId", accessorKey: 'publicId',
}, },
{ {
header: "Vorname", header: 'Vorname',
accessorKey: "firstname", accessorKey: 'firstname',
}, },
{ {
header: "Nachname", header: 'Nachname',
accessorKey: "lastname", accessorKey: 'lastname',
}, },
{ {
header: "Email", header: 'Email',
accessorKey: "email", accessorKey: 'email',
}, },
]} ]}
leftOfSearch={
<p className="text-2xl font-semibold text-left flex items-center gap-2">
<User2 className="w-5 h-5" /> Benutzer
</p>
}
/> />
</> </>
); );

View File

@@ -6,6 +6,9 @@ import {
} from '@radix-ui/react-icons'; } from '@radix-ui/react-icons';
import { HorizontalNav, VerticalNav } from '../_components/Nav'; import { HorizontalNav, VerticalNav } from '../_components/Nav';
import { Toaster } from 'react-hot-toast'; import { Toaster } from 'react-hot-toast';
import { redirect } from 'next/navigation';
import { getServerSession } from '../api/auth/[...nextauth]/auth';
import { headers } from 'next/headers';
export const metadata: Metadata = { export const metadata: Metadata = {
title: 'Create Next App', title: 'Create Next App',
@@ -17,6 +20,10 @@ export default async function RootLayout({
}: Readonly<{ }: Readonly<{
children: React.ReactNode; children: React.ReactNode;
}>) { }>) {
const session = await getServerSession();
if (!session) redirect(`/login`);
return ( return (
<div <div
className="hero min-h-screen" className="hero min-h-screen"

View File

@@ -13,10 +13,10 @@ const AuthLayout: NextPage<
'url(https://img.daisyui.com/images/stock/photo-1507358522600-9f71e620c44e.webp)', 'url(https://img.daisyui.com/images/stock/photo-1507358522600-9f71e620c44e.webp)',
}} }}
> >
<div className="hero-overlay bg-opacity-60"></div> <div className="hero-overlay bg-neutral/60"></div>
<div className="hero-content text-neutral-content text-center "> <div className="hero-content text-center ">
<div className="max-w-lg"> <div className="max-w-lg">
<div className="card bg-base-100 w-full min-w-[500px] shadow-2xl max-md:min-w-[400px]"> <div className="card rounded-2xl bg-base-100 w-full min-w-[500px] shadow-2xl max-md:min-w-[400px]">
{children} {children}
</div> </div>
</div> </div>

View File

@@ -50,14 +50,14 @@ export const Login = () => {
<div> <div>
<Toaster position="top-center" reverseOrder={false} /> <Toaster position="top-center" reverseOrder={false} />
</div> </div>
<h1 className="text-3xl font-bold">Login</h1> <h1 className="text-3xl font-bold ">Login</h1>
<span className="text-sm font-medium"> <span className="text-sm font-medium">
Noch keinen Account? Zur{' '} Noch keinen Account? Zur{' '}
<Link href="/register" className="link link-accent link-hover"> <Link href="/register" className="link link-accent link-hover">
Registrierung Registrierung
</Link> </Link>
</span> </span>
<label className="input input-bordered flex items-center gap-2"> <label className="input input-bordered flex items-center gap-2 w-full">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16" viewBox="0 0 16 16"
@@ -79,7 +79,7 @@ export const Login = () => {
? form.formState.errors.email.message ? form.formState.errors.email.message
: ''} : ''}
</p> </p>
<label className="input input-bordered flex items-center gap-2 mt-2"> <label className="input input-bordered flex items-center gap-2 mt-2 w-full">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16" viewBox="0 0 16 16"
@@ -100,12 +100,8 @@ export const Login = () => {
className="grow" className="grow"
/> />
</label> </label>
<div className="form-control mt-6"> <div className="card-actions mt-6">
<button <button className="btn btn-primary btn-block" disabled={isLoading}>
className="btn btn-primary"
name="loginBtn"
disabled={isLoading}
>
{isLoading && ( {isLoading && (
<span className="loading loading-spinner loading-sm"></span> <span className="loading loading-spinner loading-sm"></span>
)} )}

View File

@@ -71,7 +71,7 @@ export const Register = () => {
</Link> </Link>
</span> </span>
<div className="mt-5 mb-2"> <div className="mt-5 mb-2">
<label className="input input-bordered flex items-center gap-2 mt-2"> <label className="input input-bordered flex items-center gap-2 mt-2 w-full">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16" viewBox="0 0 16 16"
@@ -92,7 +92,7 @@ export const Register = () => {
? form.formState.errors.firstname.message ? form.formState.errors.firstname.message
: ''} : ''}
</p> </p>
<label className="input input-bordered flex items-center gap-2 mt-2"> <label className="input input-bordered flex items-center gap-2 mt-2 w-full">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16" viewBox="0 0 16 16"
@@ -113,8 +113,8 @@ export const Register = () => {
? form.formState.errors.lastname.message ? form.formState.errors.lastname.message
: ''} : ''}
</p> </p>
<div className="divider divider-neutral">Account</div> <div className="divider">Account</div>
<label className="input input-bordered flex items-center gap-2"> <label className="input input-bordered flex items-center gap-2 w-full">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16" viewBox="0 0 16 16"
@@ -137,7 +137,7 @@ export const Register = () => {
? form.formState.errors.email.message ? form.formState.errors.email.message
: ''} : ''}
</p> </p>
<label className="input input-bordered flex items-center gap-2 mt-2"> <label className="input input-bordered flex items-center gap-2 mt-2 w-full">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16" viewBox="0 0 16 16"
@@ -163,7 +163,7 @@ export const Register = () => {
? form.formState.errors.password.message ? form.formState.errors.password.message
: ''} : ''}
</p> </p>
<label className="input input-bordered flex items-center gap-2 mt-2"> <label className="input input-bordered flex items-center gap-2 mt-2 w-full">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16" viewBox="0 0 16 16"
@@ -189,9 +189,9 @@ export const Register = () => {
? form.formState.errors.passwordConfirm.message ? form.formState.errors.passwordConfirm.message
: ''} : ''}
</p> </p>
<div className="form-control mt-6"> <div className="card-actions mt-6">
<button <button
className="btn btn-primary" className="btn btn-primary btn-block"
name="registerBtn" name="registerBtn"
disabled={isLoading} disabled={isLoading}
> >

View File

@@ -67,7 +67,7 @@ export const HorizontalNav = () => (
</li> </li>
<li> <li>
<Link href="/logout"> <Link href="/logout">
<button className="btn btn-sm"> <button className="btn btn-sm btn-ghost">
<ExitIcon /> Logout <ExitIcon /> Logout
</button> </button>
</Link> </Link>

View File

@@ -22,6 +22,8 @@ interface PaginatedTableProps<TData>
showEditButton?: boolean; showEditButton?: boolean;
searchFields?: string[]; searchFields?: string[];
include?: Record<string, boolean>; include?: Record<string, boolean>;
leftOfSearch?: React.ReactNode;
rightOfSearch?: React.ReactNode;
ref?: Ref<PaginatedTableRef>; ref?: Ref<PaginatedTableRef>;
} }
@@ -33,6 +35,8 @@ export function PaginatedTable<TData>({
filter, filter,
include, include,
ref, ref,
leftOfSearch,
rightOfSearch,
...restProps ...restProps
}: PaginatedTableProps<TData>) { }: PaginatedTableProps<TData>) {
const [data, setData] = useState<TData[]>([]); const [data, setData] = useState<TData[]>([]);
@@ -87,7 +91,8 @@ export function PaginatedTable<TData>({
return ( return (
<div className="space-y-4 m-4"> <div className="space-y-4 m-4">
{searchFields.length > 0 && ( {searchFields.length > 0 && (
<div className="flex justify-end"> <div className="flex items-center gap-2">
<div className="flex-1">{leftOfSearch}</div>
<input <input
type="text" type="text"
placeholder="Suchen..." placeholder="Suchen..."
@@ -98,6 +103,7 @@ export function PaginatedTable<TData>({
}} }}
className="input input-bordered w-full max-w-xs justify-end" className="input input-bordered w-full max-w-xs justify-end"
/> />
<div className="flex justify-center">{rightOfSearch}</div>
</div> </div>
)} )}
<SortableTable <SortableTable

View File

@@ -116,7 +116,7 @@ export const Pagination = ({
<ArrowLeft size={16} /> <ArrowLeft size={16} />
</button> </button>
<select <select
className="select join-item" className="select join-item w-16"
value={page} value={page}
onChange={(e) => setPage(Number(e.target.value))} onChange={(e) => setPage(Number(e.target.value))}
> >

View File

@@ -23,4 +23,5 @@
--background: #ffffff; --background: #ffffff;
--foreground: #171717; --foreground: #171717;
/* --p: 47.67% 0.2484 267.02; */ /* --p: 47.67% 0.2484 267.02; */
--nc: #a6adbb;
} }