diff --git a/app/api/memories/createMemories/route.ts b/app/api/memories/createMemories/route.ts new file mode 100644 index 0000000..e208b0a --- /dev/null +++ b/app/api/memories/createMemories/route.ts @@ -0,0 +1,13 @@ +import { NextRequest, NextResponse } from "next/server"; + +export async function POST(req:NextRequest){ + try{ + const {title,description,memoryCoverPic,memoryParticipants}=await req.json() + if(!title || memoryParticipants.length===0) return NextResponse.json({success:false,message:'One or more fields are missing!'},{status:422}) + + } + catch(err){ + console.log(err) + return NextResponse.json({success:false,message:"Could not create memory, try again!"},{status:500}) + } +} \ No newline at end of file diff --git a/app/api/sample/route.ts b/app/api/sample/route.ts new file mode 100644 index 0000000..0172fed --- /dev/null +++ b/app/api/sample/route.ts @@ -0,0 +1,14 @@ +import { NextRequest, NextResponse } from "next/server"; + +export async function POST(req:NextRequest){ + + try{ + const {imagePath}=await req.json() + console.log(await req.json()) + + return NextResponse.json({success:true},{status:200}) + } + catch(err){ + console.log(err) + } +} \ No newline at end of file diff --git a/app/models/fileSchema.ts b/app/models/fileSchema.ts new file mode 100644 index 0000000..04e07d7 --- /dev/null +++ b/app/models/fileSchema.ts @@ -0,0 +1,26 @@ +import mongoose from "mongoose"; +const {ObjectId}=mongoose.Schema.Types +const fileSchema=new mongoose.Schema({ + fileName:{ + type:String, + required:true + }, + fileUrl:{ + type:String, + required:true + }, + createdBy:{ + type:ObjectId, + ref:'USER' + }, + memoryName:{ + type:ObjectId, + ref:'MEMORY' + } +},{ + timestamps:true +}) + +const FILE=mongoose.models.FILE || mongoose.model('FILE',fileSchema) + +export default FILE; \ No newline at end of file diff --git a/app/ui/Navbar.tsx b/app/ui/Navbar.tsx index 6d194b6..c68e2a4 100644 --- a/app/ui/Navbar.tsx +++ b/app/ui/Navbar.tsx @@ -1,16 +1,20 @@ 'use client' -import { Fragment } from 'react' +import { Fragment, useEffect, useRef, useState } from 'react' import { Disclosure, Menu, Transition } from '@headlessui/react' import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline' import Image from 'next/image' import { useRouter } from "next/navigation"; import toast from 'react-hot-toast' +import { CldUploadWidget } from 'next-cloudinary' function classNames(...classes:string[]) { return classes.filter(Boolean).join(' ') } + export default function Navbar() { const router=useRouter() + const [imageUrl,setImageUrl]=useState([]) + async function logout(){ const response=await fetch('/api/auth/logout',{ method:'POST', @@ -24,6 +28,9 @@ export default function Navbar() { router.push('/login') } } + useEffect(()=>{ + console.log(imageUrl) + },[imageUrl]) return ( {({ open }) => ( @@ -64,12 +71,29 @@ export default function Navbar() { View notifications - +: + +} + ); + }} + {/* Profile dropdown */}
diff --git a/package-lock.json b/package-lock.json index 8d0b9e4..c2f0d62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "lucide-react": "^0.378.0", "mongoose": "^8.4.0", "next": "14.2.3", + "next-cloudinary": "^6.5.2", "react": "^18", "react-dom": "^18", "react-hot-toast": "^2.4.1" @@ -54,6 +55,42 @@ "node": ">=6.9.0" } }, + "node_modules/@cloudinary-util/types": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@cloudinary-util/types/-/types-1.0.3.tgz", + "integrity": "sha512-j7TcghSVC7Hwu6yijumWjImnWD7T1HPDsdE4eaaP4ykOUUuZoBg1ErAg6T89RHG9uR7lZGa++QwYAZxIvos9SA==" + }, + "node_modules/@cloudinary-util/url-loader": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/@cloudinary-util/url-loader/-/url-loader-5.2.2.tgz", + "integrity": "sha512-gwoBuyoJBriUvmX3jk6Q1k5NdziloEhIp/4InLB6yBNe88K7bVbR/V8dJRhba0ZvlYDOOPjIiJLAa5J7xAnUlw==", + "dependencies": { + "@cloudinary-util/util": "3.0.0", + "@cloudinary/url-gen": "1.15.0", + "zod": "^3.22.4" + } + }, + "node_modules/@cloudinary-util/util": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@cloudinary-util/util/-/util-3.0.0.tgz", + "integrity": "sha512-o6cJsN49OIelLcSkqUf4WzgefpePDFsAaeQfJbpcKhVdtvmWv71K0oZwMXuX62IY1OolqIg0etMiHtWZPhvPNA==" + }, + "node_modules/@cloudinary/transformation-builder-sdk": { + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/@cloudinary/transformation-builder-sdk/-/transformation-builder-sdk-1.13.3.tgz", + "integrity": "sha512-tBMpjcwBjUgINGm2lKodb1fe32yBeq2KTSD7TrrFPm2/dQOb7lKmVuDaDe89IPcV+QZbb1JY/ZWL9pZjUV4aKw==", + "dependencies": { + "@cloudinary/url-gen": "^1.7.0" + } + }, + "node_modules/@cloudinary/url-gen": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/@cloudinary/url-gen/-/url-gen-1.15.0.tgz", + "integrity": "sha512-bjU67eZxLUgoRy/Plli4TQio7q6P31OYqnEgXxeN9TKXrzr6h0DeEdIUhKI9gy3HkEBWXWWJIPh7j7gkOJPnyA==", + "dependencies": { + "@cloudinary/transformation-builder-sdk": "^1.10.0" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -652,6 +689,11 @@ "url": "https://github.com/sponsors/tannerlinsley" } }, + "node_modules/@tsconfig/recommended": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@tsconfig/recommended/-/recommended-1.0.6.tgz", + "integrity": "sha512-0IKu9GHYF1NGTJiYgfWwqnOQSlnE9V9R7YohHNNf0/fj/SyOZWzdd06JFr0fLpg1Mqw0kGbYg8w5xdkSqLKM9g==" + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -3848,6 +3890,21 @@ } } }, + "node_modules/next-cloudinary": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/next-cloudinary/-/next-cloudinary-6.5.2.tgz", + "integrity": "sha512-uY+isu853KY29Y8PNd07iTth0hlLayDZmR+O8GLUYBOOgj0ew/VCqW/lL9AoaBwIq5S8kASjk3wkbYNyg4tf4w==", + "dependencies": { + "@cloudinary-util/types": "1.0.3", + "@cloudinary-util/url-loader": "5.2.2", + "@cloudinary-util/util": "^3.0.0", + "@tsconfig/recommended": "^1.0.3" + }, + "peerDependencies": { + "next": "^12 || ^13 || ^14", + "react": "^17 || ^18" + } + }, "node_modules/next/node_modules/postcss": { "version": "8.4.31", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", @@ -5684,6 +5741,14 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zod": { + "version": "3.23.8", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", + "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/package.json b/package.json index 668bb5d..9e63fef 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "lucide-react": "^0.378.0", "mongoose": "^8.4.0", "next": "14.2.3", + "next-cloudinary": "^6.5.2", "react": "^18", "react-dom": "^18", "react-hot-toast": "^2.4.1"