diff --git a/app/(private)/drive/page.tsx b/app/(private)/drive/page.tsx index b42847e..30ea782 100644 --- a/app/(private)/drive/page.tsx +++ b/app/(private)/drive/page.tsx @@ -24,7 +24,7 @@ import { IconFolderSymlink, IconTrash, } from '@tabler/icons-react'; -import { useParams, useRouter, useSearchParams } from 'next/navigation'; +import { useRouter, useSearchParams } from 'next/navigation'; import { useEffect, useRef, useState } from 'react'; import Breadcrumbs from '@/components/Breadcrumbs'; import FileTable from '@/components/Drive/FileTable'; @@ -33,9 +33,9 @@ import { apiCall, failure, openModal } from '@/lib/client_functions'; const DrivePage = () => { const searchParams = useSearchParams(); - const params = useParams(); + const currentFolder = searchParams.get('_id') ?? ''; const { data, refetch } = useFetchData( - `/api/drive/files${searchParams.get('_id') ? `?parent=${searchParams.get('_id')}` : ''}` + `/api/drive/files${currentFolder ? `?parent=${currentFolder}` : ''}` ); const [openMoveDialog, setOpenMoveDialog] = useState(false); @@ -49,7 +49,7 @@ const DrivePage = () => { const ref = useRef(null); const handleNewFolder = async () => { - await apiCall('/api/drive/files', { name: folderName, parent: params.path }, 'POST'); + await apiCall('/api/drive/files', { name: folderName, parent: currentFolder }, 'POST'); close(); setFolderName('Untitled folder'); refetch(); @@ -77,12 +77,8 @@ const DrivePage = () => { try { const formData = new FormData(); value.forEach((file) => formData.append('file', file, file.name)); - formData.append('parent', ''); + formData.append('parent', currentFolder ?? ''); await apiCall('/api/drive/files/upload', formData, 'POST'); - } catch (err) { - failure('Error uploading file'); - } finally { - setValue([]); refetch(); notifications.update({ id, @@ -92,6 +88,10 @@ const DrivePage = () => { loading: false, autoClose: 2000, }); + } catch (err) { + failure('Error uploading file'); + } finally { + setValue([]); } }; diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts index 5516294..305b067 100644 --- a/app/api/auth/[...nextauth]/route.ts +++ b/app/api/auth/[...nextauth]/route.ts @@ -1,6 +1,9 @@ import NextAuth from 'next-auth/next'; import { authOptions } from './authOptions'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + const authHandler = NextAuth(authOptions); export { authHandler as GET, authHandler as POST }; diff --git a/app/api/documents/route.ts b/app/api/documents/route.ts index ceb5df8..3c3db0d 100644 --- a/app/api/documents/route.ts +++ b/app/api/documents/route.ts @@ -5,6 +5,9 @@ import Document from '@/models/Document'; import { authOptions } from '../auth/[...nextauth]/authOptions'; import { UserDataTypes } from '../auth/[...nextauth]/next-auth.interfaces'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function GET(req: NextRequest) { try { const session: UserDataTypes | null = await getServerSession(authOptions); diff --git a/app/api/drive/files/route.ts b/app/api/drive/files/route.ts index 0ad27aa..9be5cb0 100644 --- a/app/api/drive/files/route.ts +++ b/app/api/drive/files/route.ts @@ -7,6 +7,9 @@ import File from '@/models/File'; import { authOptions } from '../../auth/[...nextauth]/authOptions'; import { UserDataTypes } from '../../auth/[...nextauth]/next-auth.interfaces'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + const s3Client = new S3Client({ region: process.env.AWS_REGION as string, credentials: { @@ -52,8 +55,8 @@ export async function GET(req: NextRequest) { let test: Types.ObjectId | null = currentFile?.parent; let path = [currentFile]; - while (test !== null) { - const parentFile: any = await File.findById(parent).select('name parent'); + while (test) { + const parentFile: any = await File.findById(test).select('name parent'); test = parentFile?.parent; path = [parentFile, ...path]; } @@ -101,7 +104,7 @@ export async function PUT(req: NextRequest) { await s3Client.send(new CopyObjectCommand(input)); await s3Client.send(new DeleteObjectCommand({ Bucket: 'dream-by-vishal', Key: fl.link })); } - const input = { parent: body?.parent || null, link: Key }; + const input = { parent: body?.parent || null, link: fl?.link ? Key : undefined }; await fl?.updateOne(input); response = [...response, fl]; }) diff --git a/app/api/drive/get-path/route.ts b/app/api/drive/get-path/route.ts index adf0d92..5d6359c 100644 --- a/app/api/drive/get-path/route.ts +++ b/app/api/drive/get-path/route.ts @@ -6,6 +6,9 @@ import File from '@/models/File'; import { authOptions } from '../../auth/[...nextauth]/authOptions'; import { UserDataTypes } from '../../auth/[...nextauth]/next-auth.interfaces'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function GET(req: NextRequest) { try { const session: UserDataTypes | null = await getServerSession(authOptions); diff --git a/app/api/list/route.ts b/app/api/list/route.ts index 0672ee7..d8c3db4 100644 --- a/app/api/list/route.ts +++ b/app/api/list/route.ts @@ -5,6 +5,9 @@ import TodoList from '@/models/TodoList'; import { authOptions } from '../auth/[...nextauth]/authOptions'; import { UserDataTypes } from '../auth/[...nextauth]/next-auth.interfaces'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function GET(req: NextRequest) { try { const session: UserDataTypes | null = await getServerSession(authOptions); diff --git a/app/api/notes/archived/route.ts b/app/api/notes/archived/route.ts index 42fddea..9da1d4e 100644 --- a/app/api/notes/archived/route.ts +++ b/app/api/notes/archived/route.ts @@ -5,6 +5,9 @@ import Note from '@/models/Note'; import { authOptions } from '../../auth/[...nextauth]/authOptions'; import { UserDataTypes } from '../../auth/[...nextauth]/next-auth.interfaces'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function GET() { try { const session: UserDataTypes | null = await getServerSession(authOptions); diff --git a/app/api/notes/route.ts b/app/api/notes/route.ts index b25c03c..d8bc90d 100644 --- a/app/api/notes/route.ts +++ b/app/api/notes/route.ts @@ -5,6 +5,9 @@ import Note from '@/models/Note'; import { authOptions } from '../auth/[...nextauth]/authOptions'; import { UserDataTypes } from '../auth/[...nextauth]/next-auth.interfaces'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function GET() { try { const session: UserDataTypes | null = await getServerSession(authOptions); diff --git a/app/api/notes/trashed/route.ts b/app/api/notes/trashed/route.ts index b68f94f..784d9ea 100644 --- a/app/api/notes/trashed/route.ts +++ b/app/api/notes/trashed/route.ts @@ -5,6 +5,9 @@ import Note from '@/models/Note'; import { authOptions } from '../../auth/[...nextauth]/authOptions'; import { UserDataTypes } from '../../auth/[...nextauth]/next-auth.interfaces'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function GET() { try { const session: UserDataTypes | null = await getServerSession(authOptions); diff --git a/app/api/spotlight/route.ts b/app/api/spotlight/route.ts index 5dbdf79..2024bc2 100644 --- a/app/api/spotlight/route.ts +++ b/app/api/spotlight/route.ts @@ -7,6 +7,9 @@ import { authOptions } from '../auth/[...nextauth]/authOptions'; import { UserDataTypes } from '../auth/[...nextauth]/next-auth.interfaces'; import Document from '@/models/Document'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function GET() { try { const session: UserDataTypes | null = await getServerSession(authOptions); diff --git a/app/api/todos/route.ts b/app/api/todos/route.ts index 9fb0a02..045e211 100644 --- a/app/api/todos/route.ts +++ b/app/api/todos/route.ts @@ -15,6 +15,9 @@ import { } from '@/lib/functions'; import '@/models/TodoList'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function GET(req: NextRequest) { try { const session: UserDataTypes | null = await getServerSession(authOptions); diff --git a/app/api/todos/todo-list/route.ts b/app/api/todos/todo-list/route.ts index eccd007..3b04cc9 100644 --- a/app/api/todos/todo-list/route.ts +++ b/app/api/todos/todo-list/route.ts @@ -6,6 +6,9 @@ import { authOptions } from '../../auth/[...nextauth]/authOptions'; import { UserDataTypes } from '../../auth/[...nextauth]/next-auth.interfaces'; import Todo from '@/models/Todo'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function GET() { try { const session: UserDataTypes | null = await getServerSession(authOptions); diff --git a/app/api/users/register/route.ts b/app/api/users/register/route.ts index 0e1d159..fdd3b8f 100644 --- a/app/api/users/register/route.ts +++ b/app/api/users/register/route.ts @@ -3,6 +3,9 @@ import startDb from '@/lib/db'; import User from '@/models/User'; import { sendMail, verificationMessage } from '@/lib/functions'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function POST(req: Request) { try { const body = await req.json(); diff --git a/app/verify/[secret]/route.ts b/app/verify/[secret]/route.ts index baaf324..ba96d4f 100644 --- a/app/verify/[secret]/route.ts +++ b/app/verify/[secret]/route.ts @@ -3,6 +3,9 @@ import startDb from '@/lib/db'; import User from '@/models/User'; import { sendMail } from '@/lib/functions'; +export const maxDuration = 60; +export const dynamic = 'force-dynamic'; + export async function GET(req: Request, { params }: { params: { secret: string } }) { try { await startDb(); diff --git a/components/Layout/Layout.tsx b/components/Layout/Layout.tsx index 35ce902..23fb16d 100644 --- a/components/Layout/Layout.tsx +++ b/components/Layout/Layout.tsx @@ -130,7 +130,7 @@ export default function Layout({ children }: { children: React.ReactNode }) { {isLoggedIn && ( - + {/* */}