From bade0f61081ca84270a2e9223393e62f80b38af9 Mon Sep 17 00:00:00 2001 From: schererleander Date: Fri, 26 Dec 2025 18:08:56 +0100 Subject: refactor(ui): simplify dialog component by removing close button --- src/components/ui/dialog.tsx | 15 +-------------- src/lib/mongodb.ts | 40 ++++++++-------------------------------- 2 files changed, 9 insertions(+), 46 deletions(-) diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx index a6f1cfb..aded03e 100644 --- a/src/components/ui/dialog.tsx +++ b/src/components/ui/dialog.tsx @@ -2,7 +2,6 @@ import * as React from "react" import * as DialogPrimitive from "@radix-ui/react-dialog" -import { XIcon } from "lucide-react" import { cn } from "@/lib/utils" @@ -49,11 +48,8 @@ function DialogOverlay({ function DialogContent({ className, children, - showCloseButton = true, ...props -}: React.ComponentProps & { - showCloseButton?: boolean -}) { +}: React.ComponentProps) { return ( @@ -66,15 +62,6 @@ function DialogContent({ {...props} > {children} - {showCloseButton && ( - - - Close - - )} ) diff --git a/src/lib/mongodb.ts b/src/lib/mongodb.ts index b3cb896..9e7c9bd 100644 --- a/src/lib/mongodb.ts +++ b/src/lib/mongodb.ts @@ -2,43 +2,19 @@ import mongoose from "mongoose"; const MONGODB_URI = process.env.MONGODB_URI; -interface MongooseCache { - conn: typeof mongoose | null; - promise: Promise | null; -} - -declare global { - var mongoose: MongooseCache | undefined; -} - -let cached = global.mongoose; - -if (!cached) { - cached = global.mongoose = { conn: null, promise: null }; -} - async function dbConnect() { if (!MONGODB_URI) { - throw new Error("Please define the MONGODB_URI environment variable inside .env.local"); + throw new Error( + "Please define the MONGODB_URI environment variable inside .env.local" + ); } - if (cached!.conn) return cached!.conn; - - if (!cached!.promise) { - const opts = { bufferCommands: false }; - cached!.promise = mongoose.connect(MONGODB_URI, opts).then((mongoose) => { - return mongoose; - }); + // If the connection is already established, return + if (mongoose.connection.readyState >= 1) { + return; } - - try { - cached!.conn = await cached!.promise; - } catch (e) { - cached!.promise = null; - throw e; - } - - return cached!.conn; + + return mongoose.connect(MONGODB_URI); } export default dbConnect; -- cgit v1.3.1