chore: file formatting

This commit is contained in:
Kailasdevdas
2026-05-26 15:48:01 +05:30
parent 8a21e0bf38
commit 78e2618a29
117 changed files with 12775 additions and 14638 deletions
+23 -35
View File
@@ -1,22 +1,12 @@
import { PrismaClient } from "@prisma/client";
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export const bulkImportExcelData = async (req, res) => {
try {
const {
departments,
doctors,
timings,
careers,
inquiries,
academics,
appointments,
candidates,
news,
} = req.body;
const { departments, doctors, timings, careers, inquiries, academics, appointments, candidates, news } = req.body;
console.log("🚀 Starting Robust Data Import...");
console.log('🚀 Starting Robust Data Import...');
// 1. DEPARTMENTS
if (departments) {
@@ -54,14 +44,14 @@ export const bulkImportExcelData = async (req, res) => {
update: {
name: row.Name?.toString(),
designation: row.Designation?.toString() || null,
workingStatus: row["Working Status"]?.toString() || null,
workingStatus: row['Working Status']?.toString() || null,
qualification: row.Qualification?.toString() || null,
},
create: {
doctorId: row.GG_ID.toString(),
name: row.Name?.toString(),
designation: row.Designation?.toString() || null,
workingStatus: row["Working Status"]?.toString() || null,
workingStatus: row['Working Status']?.toString() || null,
qualification: row.Qualification?.toString() || null,
},
});
@@ -100,8 +90,8 @@ export const bulkImportExcelData = async (req, res) => {
if (doctor && doctor.departments.length > 0) {
const doctorDeptId = doctor.departments[0].id;
const rawAdd = row.Additional?.toString() || "";
const rawMon = row.Monday?.toString() || "";
const rawAdd = row.Additional?.toString() || '';
const rawMon = row.Monday?.toString() || '';
const isAppt = (val) => /appointment|basis|on call/i.test(val);
let finalAdd = rawAdd;
@@ -147,7 +137,7 @@ export const bulkImportExcelData = async (req, res) => {
experienceNeed: row.ExperienceNeed?.toString() || null,
email: row.HiringEmail?.toString() || null,
number: row.Number?.toString() || null,
status: row.Status?.toString() || "new",
status: row.Status?.toString() || 'new',
};
if (cId) {
await prisma.career.upsert({
@@ -168,7 +158,7 @@ export const bulkImportExcelData = async (req, res) => {
await prisma.inquiry.create({
data: {
fullName: row.FullName.toString(),
number: row.Number?.toString() || "",
number: row.Number?.toString() || '',
emailId: row.EmailId?.toString() || null,
subject: row.Subject?.toString() || null,
message: row.Message?.toString() || null,
@@ -185,10 +175,10 @@ export const bulkImportExcelData = async (req, res) => {
await prisma.academicsResearch.create({
data: {
fullName: row.FullName.toString(),
number: row.Number?.toString() || "",
number: row.Number?.toString() || '',
emailId: row.EmailId?.toString() || null,
subject: row.Subject?.toString() || null, // Force String
courseName: row["Course Name"]?.toString() || null,
courseName: row['Course Name']?.toString() || null,
message: row.Message?.toString() || null,
createdAt: row.Date ? new Date(row.Date) : new Date(),
},
@@ -201,7 +191,7 @@ export const bulkImportExcelData = async (req, res) => {
for (const row of appointments) {
if (!row.FullName) continue;
const doctorName = row.Doctor?.toString();
const departmentName = row["Department Id"]?.toString();
const departmentName = row['Department Id']?.toString();
const doctor = await prisma.doctor.findFirst({
where: { name: doctorName },
@@ -214,11 +204,11 @@ export const bulkImportExcelData = async (req, res) => {
if (!value) return new Date();
// Excel numeric date
if (typeof value === "number") {
if (typeof value === 'number') {
return new Date((value - 25569) * 86400 * 1000);
}
if (typeof value === "string") {
if (typeof value === 'string') {
const v = value.trim();
// Handle DD/MM/YYYY
@@ -238,15 +228,15 @@ export const bulkImportExcelData = async (req, res) => {
}
}
console.warn("⚠️ Invalid date, using current date:", value);
console.warn('⚠️ Invalid date, using current date:', value);
return new Date();
};
if (doctor && department) {
await prisma.appointment.create({
data: {
name: row.FullName.toString(),
mobileNumber: row.Number?.toString() || "",
email: row["Email Id"]?.toString() || null,
mobileNumber: row.Number?.toString() || '',
email: row['Email Id']?.toString() || null,
message: row.Message?.toString() || null,
date: parseDate(row.Date),
doctorId: doctor.doctorId,
@@ -265,10 +255,10 @@ export const bulkImportExcelData = async (req, res) => {
.create({
data: {
fullName: row.FullName.toString(),
mobile: row.Number?.toString() || "",
email: row.EmailId?.toString() || "",
subject: row.Subject?.toString() || "",
coverLetter: row["Cover Letter"]?.toString() || "",
mobile: row.Number?.toString() || '',
email: row.EmailId?.toString() || '',
subject: row.Subject?.toString() || '',
coverLetter: row['Cover Letter']?.toString() || '',
careerId: parseInt(row.CareerId),
createdAt: row.Date ? new Date(row.Date) : new Date(),
},
@@ -294,11 +284,9 @@ export const bulkImportExcelData = async (req, res) => {
}
}
res
.status(200)
.json({ success: true, message: "✅ Import completed successfully!" });
res.status(200).json({ success: true, message: '✅ Import completed successfully!' });
} catch (error) {
console.error("❌ Bulk Import Error:", error);
console.error('❌ Bulk Import Error:', error);
res.status(500).json({ success: false, error: error.message });
}
};