finally building
This commit is contained in:
36
apps/admin/app/(main)/layout.tsx
Normal file
36
apps/admin/app/(main)/layout.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
NavigationMenu,
|
||||
NavigationMenuContent,
|
||||
NavigationMenuItem,
|
||||
NavigationMenuLink,
|
||||
NavigationMenuList,
|
||||
NavigationMenuTrigger,
|
||||
navigationMenuTriggerStyle,
|
||||
} from '@workspace/ui/components/navigation-menu';
|
||||
import Link from 'next/link';
|
||||
|
||||
export default function MainLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div>
|
||||
<header className="flex h-16 items-center justify-between border-b bg-background px-4 md:px-6">
|
||||
<nav>
|
||||
<NavigationMenu>
|
||||
<NavigationMenuList>
|
||||
<NavigationMenuItem>
|
||||
<NavigationMenuLink asChild>
|
||||
<Link href="/">Home</Link>
|
||||
</NavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
<NavigationMenuItem>
|
||||
<NavigationMenuLink asChild>
|
||||
<Link href="/students">Students</Link>
|
||||
</NavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
</NavigationMenuList>
|
||||
</NavigationMenu>
|
||||
</nav>
|
||||
</header>
|
||||
<main>{children}</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import Login from '@/components/login';
|
||||
import Studs from '@/components/studs';
|
||||
import { db, admins } from '@workspace/db';
|
||||
import { auth, signIn, signOut } from '@workspace/auth';
|
||||
import { auth, signIn, signOut } from '@/auth';
|
||||
|
||||
async function getStudents() {
|
||||
'use server';
|
||||
25
apps/admin/app/(main)/students/columns.tsx
Normal file
25
apps/admin/app/(main)/students/columns.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { ColumnDef } from '@tanstack/react-table';
|
||||
import { createSelectSchema, students } from '@workspace/db';
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
const studentSelectSchema = createSelectSchema(students);
|
||||
export type Student = z.infer<typeof studentSelectSchema>;
|
||||
|
||||
export const columns: ColumnDef<Student>[] = [
|
||||
{
|
||||
accessorKey: 'id',
|
||||
header: 'ID',
|
||||
},
|
||||
{
|
||||
accessorKey: 'firstName',
|
||||
header: 'First Name',
|
||||
},
|
||||
{
|
||||
accessorKey: 'lastName',
|
||||
header: 'Last Name',
|
||||
},
|
||||
{
|
||||
accessorKey: 'email',
|
||||
header: 'Email',
|
||||
},
|
||||
];
|
||||
66
apps/admin/app/(main)/students/data-table.tsx
Normal file
66
apps/admin/app/(main)/students/data-table.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
'use client';
|
||||
|
||||
import { ColumnDef, flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table';
|
||||
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from '@workspace/ui/components/table';
|
||||
|
||||
interface DataTableProps<TData, TValue> {
|
||||
columns: ColumnDef<TData, TValue>[];
|
||||
data: TData[];
|
||||
}
|
||||
|
||||
export function DataTable<TData, TValue>({ columns, data }: DataTableProps<TData, TValue>) {
|
||||
const table = useReactTable({
|
||||
data,
|
||||
columns,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="rounded-md border">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
{table.getHeaderGroups().map((headerGroup) => (
|
||||
<TableRow key={headerGroup.id}>
|
||||
{headerGroup.headers.map((header) => {
|
||||
return (
|
||||
<TableHead key={header.id}>
|
||||
{header.isPlaceholder
|
||||
? null
|
||||
: flexRender(header.column.columnDef.header, header.getContext())}
|
||||
</TableHead>
|
||||
);
|
||||
})}
|
||||
</TableRow>
|
||||
))}
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{table.getRowModel().rows?.length ? (
|
||||
table.getRowModel().rows.map((row) => (
|
||||
<TableRow key={row.id} data-state={row.getIsSelected() && 'selected'}>
|
||||
{row.getVisibleCells().map((cell) => (
|
||||
<TableCell key={cell.id}>
|
||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
))
|
||||
) : (
|
||||
<TableRow>
|
||||
<TableCell colSpan={columns.length} className="h-24 text-center">
|
||||
No results.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
18
apps/admin/app/(main)/students/page.tsx
Normal file
18
apps/admin/app/(main)/students/page.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import { columns, Student } from './columns';
|
||||
import { DataTable } from './data-table';
|
||||
import { db, students } from '@workspace/db';
|
||||
|
||||
async function getData(): Promise<Student[]> {
|
||||
const data = db.select().from(students);
|
||||
return data;
|
||||
}
|
||||
|
||||
export default async function DemoPage() {
|
||||
const data = await getData();
|
||||
|
||||
return (
|
||||
<div className="container mx-auto py-10">
|
||||
<DataTable columns={columns} data={data} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
import { handlers } from '@workspace/auth';
|
||||
import { handlers } from '@/auth';
|
||||
export const { GET, POST } = handlers;
|
||||
|
||||
29
apps/admin/app/login/page.tsx
Normal file
29
apps/admin/app/login/page.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Button } from '@workspace/ui/components/button';
|
||||
import { signIn } from '@/auth';
|
||||
|
||||
async function logIn() {
|
||||
'use server';
|
||||
await signIn('google', { redirectTo: '/' });
|
||||
}
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-svh">
|
||||
<div className="flex flex-col items-center justify-center gap-4">
|
||||
<form action={logIn}>
|
||||
<Button type="submit" variant="outline" className="w-full h-12">
|
||||
<div className="absolute inset-0 bg-gradient-to-r from-primary/0 via-primary/10 to-primary/0 translate-x-[-100%] group-hover:translate-x-[100%] transition-transform duration-700 ease-out pointer-events-none" />
|
||||
<img
|
||||
src="https://static.cdnlogo.com/logos/g/35/google-icon.svg"
|
||||
alt="Google logo"
|
||||
className="w-5 h-5 transition-transform duration-200"
|
||||
/>
|
||||
<span className="relative z-10 font-medium transition-colors duration-200 group-hover:text-foreground">
|
||||
Sign in with Google
|
||||
</span>
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user