config/db.js
import mongoose from 'mongoose';
const connectDB = async () => {
if (mongoose.connections[0].readyState) return;
try {
await mongoose.connect(process.env.MONGODB_URI);
console.log("MongoDB Connected Successfully");
} catch (error) {
console.error("MongoDB connection error:", error);
}
};
export default connectDB;
"use client";
import { useState } from 'react';
export default function BookingModal({ service, price, onClose }) {
const [date, setDate] = useState('');
const [slot, setSlot] = useState('');
const [loading, setLoading] = useState(false);
const handleBooking = async () => {
if (!date || !slot) return alert("Please fill all details");
setLoading(true);
// Simulate API connection & Success flow
setTimeout(() => {
alert(`Booking confirmed for ${service} on ${date} @ ${slot}!`);
setLoading(false);
onClose();
}, 1500);
};
return (
);
}
Reserve Your Spot
{service} — ₹{price}/hr
setDate(e.target.value)} className="w-full bg-brand-navy text-white p-3 rounded-lg border border-gray-700 outline-none focus:border-brand-orange" />