aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/ui/dialog.tsx15
-rw-r--r--src/lib/mongodb.ts40
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<typeof DialogPrimitive.Content> & {
- showCloseButton?: boolean
-}) {
+}: React.ComponentProps<typeof DialogPrimitive.Content>) {
return (
<DialogPortal data-slot="dialog-portal">
<DialogOverlay />
@@ -66,15 +62,6 @@ function DialogContent({
{...props}
>
{children}
- {showCloseButton && (
- <DialogPrimitive.Close
- data-slot="dialog-close"
- className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
- >
- <XIcon />
- <span className="sr-only">Close</span>
- </DialogPrimitive.Close>
- )}
</DialogPrimitive.Content>
</DialogPortal>
)
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<typeof mongoose> | 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;