From 41372674269468f02d9a6fab0c6603076374cedb Mon Sep 17 00:00:00 2001 From: Abhishek Hegde Date: Fri, 24 Nov 2023 12:41:43 +0530 Subject: [PATCH] error solved at database connection string --- package-lock.json | 128 ++++++++++++++++++++++++ package.json | 1 + prisma/schema.prisma | 7 +- public/next.svg | 1 - public/vercel.svg | 1 - src/app/notes/NavBar.tsx | 46 +++++---- src/app/notes/page.tsx | 14 ++- src/app/sign-in/[[...sign-in]]/page.tsx | 2 +- src/app/sign-up/[[...sign-up]]/page.tsx | 2 +- src/components/ui/loading-button.tsx | 19 ++++ 10 files changed, 191 insertions(+), 30 deletions(-) delete mode 100644 public/next.svg delete mode 100644 public/vercel.svg create mode 100644 src/components/ui/loading-button.tsx diff --git a/package-lock.json b/package-lock.json index af5b243..bec2cec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "clsx": "^2.0.0", "eslint-config-prettier": "^9.0.0", "lucide-react": "^0.290.0", + "mongodb": "^6.3.0", "next": "14.0.0", "next-themes": "^0.2.1", "openai": "^4.14.1", @@ -410,6 +411,14 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@mongodb-js/saslprep": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.1.tgz", + "integrity": "sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==", + "dependencies": { + "sparse-bitfield": "^3.0.3" + } + }, "node_modules/@next/env": { "version": "14.0.0", "resolved": "https://registry.npmjs.org/@next/env/-/env-14.0.0.tgz", @@ -1237,6 +1246,19 @@ "@types/node": "*" } }, + "node_modules/@types/webidl-conversions": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", + "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==" + }, + "node_modules/@types/whatwg-url": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.3.tgz", + "integrity": "sha512-z1ELvMijRL1QmU7QuzDkeYXSF2+dXI0ITKoQsIoVKcNBOiK5RMmWy+pYYxJTHFt8vkpZe7UsvRErQwcxZkjoUw==", + "dependencies": { + "@types/webidl-conversions": "*" + } + }, "node_modules/@typescript-eslint/parser": { "version": "6.9.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.0.tgz", @@ -1934,6 +1956,14 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/bson": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", + "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", + "engines": { + "node": ">=16.20.1" + } + }, "node_modules/busboy": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", @@ -4105,6 +4135,11 @@ "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", "peer": true }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==" + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -4164,6 +4199,91 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/mongodb": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.3.0.tgz", + "integrity": "sha512-tt0KuGjGtLUhLoU263+xvQmPHEGTw5LbcNC73EoFRYgSHwZt5tsoJC110hDyO1kjQzpgNrpdcSza9PknWN4LrA==", + "dependencies": { + "@mongodb-js/saslprep": "^1.1.0", + "bson": "^6.2.0", + "mongodb-connection-string-url": "^3.0.0" + }, + "engines": { + "node": ">=16.20.1" + }, + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.188.0", + "@mongodb-js/zstd": "^1.1.0", + "gcp-metadata": "^5.2.0", + "kerberos": "^2.0.1", + "mongodb-client-encryption": ">=6.0.0 <7", + "snappy": "^7.2.2", + "socks": "^2.7.1" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "gcp-metadata": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + }, + "socks": { + "optional": true + } + } + }, + "node_modules/mongodb-connection-string-url": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.0.tgz", + "integrity": "sha512-t1Vf+m1I5hC2M5RJx/7AtxgABy1cZmIPQRMXw+gEIPn/cZNF3Oiy+l0UIypUwVB5trcWHq3crg2g3uAR9aAwsQ==", + "dependencies": { + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^13.0.0" + } + }, + "node_modules/mongodb-connection-string-url/node_modules/tr46": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz", + "integrity": "sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==", + "dependencies": { + "punycode": "^2.3.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/mongodb-connection-string-url/node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "engines": { + "node": ">=12" + } + }, + "node_modules/mongodb-connection-string-url/node_modules/whatwg-url": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-13.0.0.tgz", + "integrity": "sha512-9WWbymnqj57+XEuqADHrCJ2eSXzn8WXIW/YSGaZtb2WKAInQ6CHfaUUcTyyver0p8BDg5StLQq8h1vtZuwmOig==", + "dependencies": { + "tr46": "^4.1.1", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -5410,6 +5530,14 @@ "node": ">=0.10.0" } }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "dependencies": { + "memory-pager": "^1.0.2" + } + }, "node_modules/sswr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/sswr/-/sswr-2.0.0.tgz", diff --git a/package.json b/package.json index bd46e4b..96682b9 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "clsx": "^2.0.0", "eslint-config-prettier": "^9.0.0", "lucide-react": "^0.290.0", + "mongodb": "^6.3.0", "next": "14.0.0", "next-themes": "^0.2.1", "openai": "^4.14.1", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index fb70760..49835a1 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -10,14 +10,13 @@ datasource db { url = env("DATABASE_URL") } - model Note { - id String @id @default(auto()) @map("_id") @db.ObjectId + id String @id @default(auto()) @map("_id") @db.ObjectId title String content String? userId String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - @@map("notes") -} \ No newline at end of file + @@map("notes") +} diff --git a/public/next.svg b/public/next.svg deleted file mode 100644 index 5174b28..0000000 --- a/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/vercel.svg b/public/vercel.svg deleted file mode 100644 index d2f8422..0000000 --- a/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/app/notes/NavBar.tsx b/src/app/notes/NavBar.tsx index e03843f..4d3181f 100644 --- a/src/app/notes/NavBar.tsx +++ b/src/app/notes/NavBar.tsx @@ -1,32 +1,40 @@ +"use client"; + import logo from "@/assets/logo.png"; +import AddNoteDialog from "@/components/AddNoteDialog"; import { Button } from "@/components/ui/button"; import { UserButton } from "@clerk/nextjs"; import { Plus } from "lucide-react"; import Image from "next/image"; import Link from "next/link"; +import { useState } from "react"; export default function NavBar() { + const [showAddNoteDialog, setShowAddNoteDialog] = useState(false); + return ( -
-
- - FlowBrain logo - FlowBrain - -
- - + <> +
+
+ + FlowBrain logo + FlowBrain + +
+ + +
-
+ + ); } - diff --git a/src/app/notes/page.tsx b/src/app/notes/page.tsx index a7b6a5b..0f2bbaf 100644 --- a/src/app/notes/page.tsx +++ b/src/app/notes/page.tsx @@ -1,9 +1,17 @@ +import prisma from "@/lib/db/prisma"; +import { auth } from "@clerk/nextjs"; import { Metadata } from "next"; export const metadata: Metadata = { - title: "Ai - Notes", + title: "FlowBrain - Notes", }; -export default function NotesPage() { - return
Here will be your notes
; +export default async function NotesPage() { + const { userId } = auth(); + + if (!userId) throw Error("userId undefined"); + + const allNotes = await prisma.note.findMany({ where: { userId } }); + + return
{JSON.stringify(allNotes)}
; } diff --git a/src/app/sign-in/[[...sign-in]]/page.tsx b/src/app/sign-in/[[...sign-in]]/page.tsx index c62b9f9..956e8b8 100644 --- a/src/app/sign-in/[[...sign-in]]/page.tsx +++ b/src/app/sign-in/[[...sign-in]]/page.tsx @@ -2,7 +2,7 @@ import { SignIn } from "@clerk/nextjs"; import { Metadata } from "next"; export const metadata: Metadata = { - title: "AI-noteTaker - Sign In", + title: "FlowBrain - Sign In", }; export default function SignInPage() { diff --git a/src/app/sign-up/[[...sign-up]]/page.tsx b/src/app/sign-up/[[...sign-up]]/page.tsx index b1209c6..4c27209 100644 --- a/src/app/sign-up/[[...sign-up]]/page.tsx +++ b/src/app/sign-up/[[...sign-up]]/page.tsx @@ -2,7 +2,7 @@ import { SignUp } from "@clerk/nextjs"; import { Metadata } from "next"; export const metadata: Metadata = { - title: "AI-noteTaker - Sign Up", + title: "FlowBrain - Sign Up", }; export default function SignUpPage() { diff --git a/src/components/ui/loading-button.tsx b/src/components/ui/loading-button.tsx new file mode 100644 index 0000000..85f9440 --- /dev/null +++ b/src/components/ui/loading-button.tsx @@ -0,0 +1,19 @@ +import { Loader2 } from "lucide-react"; +import { Button, ButtonProps } from "./button"; + +type LoadingButtonProps = { + loading: boolean; +} & ButtonProps; + +export default function LoadingButton({ + children, + loading, + ...props +}: LoadingButtonProps) { + return ( + + ); +}