feat: Implement core admin panel functionalities including appointment, contact, and pricing management with associated models, controllers, views, and routes.

This commit is contained in:
LNHA
2026-02-03 14:58:00 +07:00
parent d1b931d547
commit df8e1f9665
25 changed files with 4574 additions and 659 deletions

View File

@@ -14,7 +14,7 @@ async function migrate() {
await connectDB();
// Read contact-data.json file
const contactJsonPath = path.join(__dirname, "../data/contact-data.json");
const contactJsonPath = path.join(__dirname, "../data/contact.json");
const contactData = JSON.parse(await fs.readFile(contactJsonPath, "utf8"));
// Migrate data using the model's static method

View File

@@ -0,0 +1,71 @@
/**
* Migration script for Appointment data
* Imports data from appointment.json to MongoDB
*
* Run: node scripts/2026_02_03_appointment.js
*/
require("dotenv").config();
const mongoose = require("mongoose");
const fs = require("fs");
const path = require("path");
// Connect to MongoDB
const connectDB = async () => {
try {
await mongoose.connect(process.env.MONGODB_URI);
console.log("MongoDB connected successfully");
} catch (error) {
console.error("MongoDB connection error:", error);
process.exit(1);
}
};
const runMigration = async () => {
try {
await connectDB();
// Load Appointment model
const Appointment = require("../models/appointment");
// Load JSON data
const jsonPath = path.join(__dirname, "../data/appointment.json");
if (!fs.existsSync(jsonPath)) {
console.log("appointment.json not found, creating default data...");
const defaultData = {
hero: {
title: "Make Appointment",
backgroundImage: "",
subtitle: "",
heading: "",
description: "",
},
visaOptions: [],
form: {
heading: "Request Appointment",
fields: [],
submitButton: {
text: "Request Appointment",
icon: "fa-solid fa-arrow-right",
buttonClass: "theme-btn",
},
},
};
await Appointment.migrateFromJson(defaultData);
} else {
const jsonData = JSON.parse(fs.readFileSync(jsonPath, "utf8"));
console.log("Loaded appointment.json data");
await Appointment.migrateFromJson(jsonData);
}
console.log("✅ Appointment migration completed successfully!");
} catch (error) {
console.error("❌ Migration failed:", error);
} finally {
await mongoose.connection.close();
console.log("MongoDB connection closed");
}
};
runMigration();