diff --git a/Websites/jefes-nextjs/package.json b/Websites/jefes-nextjs/package.json index be0599c..e88f32b 100644 --- a/Websites/jefes-nextjs/package.json +++ b/Websites/jefes-nextjs/package.json @@ -32,5 +32,8 @@ "postcss": "^8", "tailwindcss": "^3", "typescript": "^5" + }, + "prisma": { + "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts" } } diff --git a/Websites/jefes-nextjs/prisma/seed.ts b/Websites/jefes-nextjs/prisma/seed.ts new file mode 100644 index 0000000..06b3bc8 --- /dev/null +++ b/Websites/jefes-nextjs/prisma/seed.ts @@ -0,0 +1,51 @@ +import { PrismaClient } from "@prisma/client"; +const prisma = new PrismaClient(); +async function main() { + const alice = await prisma.user.upsert({ + where: { email: "alice@prisma.io" }, + update: {}, + create: { + email: "alice@prisma.io", + name: "Alice", + posts: { + create: { + title: "Check out Prisma with Next.js", + content: "https://www.prisma.io/nextjs", + published: true, + }, + }, + }, + }); + const bob = await prisma.user.upsert({ + where: { email: "bob@prisma.io" }, + update: {}, + create: { + email: "bob@prisma.io", + name: "Bob", + posts: { + create: [ + { + title: "Follow Prisma on Twitter", + content: "https://twitter.com/prisma", + published: true, + }, + { + title: "Follow Nexus on Twitter", + content: "https://twitter.com/nexusgql", + published: true, + }, + ], + }, + }, + }); + console.log({ alice, bob }); +} +main() + .then(async () => { + await prisma.$disconnect(); + }) + .catch(async (e) => { + console.error(e); + await prisma.$disconnect(); + process.exit(1); + }); diff --git a/Websites/nextjs-dashboard/app/ui/dashboard/nav-links.tsx b/Websites/nextjs-dashboard/app/ui/dashboard/nav-links.tsx index f2a67eb..6bc4ae2 100644 --- a/Websites/nextjs-dashboard/app/ui/dashboard/nav-links.tsx +++ b/Websites/nextjs-dashboard/app/ui/dashboard/nav-links.tsx @@ -1,9 +1,13 @@ +"use client"; + import { UserGroupIcon, HomeIcon, DocumentDuplicateIcon, } from '@heroicons/react/24/outline'; import clsx from 'clsx'; +import Link from 'next/link'; +import { usePathname } from 'next/navigation'; // Map of links to display in the side navigation. // Depending on the size of the application, this would be stored in a database. @@ -18,21 +22,26 @@ const links = [ ]; export default function NavLinks() { + const pathname = usePathname(); + return ( <> {links.map((link) => { const LinkIcon = link.icon; return ( -

{link.name}

-
+ ); })} diff --git a/Websites/nextjs-dashboard/bun.lockb b/Websites/nextjs-dashboard/bun.lockb index 08d6fc2..9ae4cff 100755 Binary files a/Websites/nextjs-dashboard/bun.lockb and b/Websites/nextjs-dashboard/bun.lockb differ diff --git a/Websites/nextjs-dashboard/package.json b/Websites/nextjs-dashboard/package.json index 1704905..a1bfd46 100644 --- a/Websites/nextjs-dashboard/package.json +++ b/Websites/nextjs-dashboard/package.json @@ -8,29 +8,35 @@ "dependencies": { "@heroicons/react": "^2.0.18", "@tailwindcss/forms": "^0.5.6", - "@types/node": "20.5.7", + "@types/node": "^20.8.9", "@vercel/postgres": "^0.5.0", "autoprefixer": "10.4.15", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", + "drizzle-orm": "^0.28.6", "lucide-react": "^0.290.0", "next": "^14.0.0", "postcss": "8.4.31", + "postgres": "^3.4.2", + "prisma": "^5.5.2", "react": "18.2.0", "react-dom": "18.2.0", "shadcn-ui": "latest", "tailwind-merge": "^1.14.0", "tailwindcss": "3.3.3", "tailwindcss-animate": "^1.0.7", - "typescript": "5.2.2", - "zod": "^3.22.2" + "typescript": "^5.2.2", + "zod": "^3.22.2", + "dotenv":"16.3.1" }, "devDependencies": { "@types/bcrypt": "^5.0.1", "@types/react": "18.2.21", "@types/react-dom": "18.2.14", "dotenv": "^16.3.1", - "prettier": "^3.0.3" + "drizzle-kit": "^0.19.13", + "prettier": "^3.0.3", + "ts-node": "^10.9.1" }, "engines": { "node": ">=18" diff --git a/Websites/nextjs-dashboard/prisma/schema.prisma b/Websites/nextjs-dashboard/prisma/schema.prisma new file mode 100644 index 0000000..d205f42 --- /dev/null +++ b/Websites/nextjs-dashboard/prisma/schema.prisma @@ -0,0 +1,11 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} diff --git a/Websites/nextjs-dashboard/schema.ts b/Websites/nextjs-dashboard/schema.ts new file mode 100644 index 0000000..8d0924b --- /dev/null +++ b/Websites/nextjs-dashboard/schema.ts @@ -0,0 +1,21 @@ +import { integer, serial, text, pgTable } from 'drizzle-orm/pg-core'; +import { relations } from 'drizzle-orm'; + +export const users = pgTable('users', { + id: serial('id').primaryKey(), + name: text('name').notNull(), +}); + +export const usersRelations = relations(users, ({ many }) => ({ + posts: many(posts), +})); + +export const posts = pgTable('posts', { + id: serial('id').primaryKey(), + content: text('content').notNull(), + authorId: integer('author_id').notNull(), +}); + +export const postsRelations = relations(posts, ({ one }) => ({ + author: one(users, { fields: [posts.authorId], references: [users.id] }), +})); \ No newline at end of file