chore: file formatting
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import prisma from "../prisma/client.js";
|
||||
import prisma from '../prisma/client.js';
|
||||
|
||||
import {sendEmail} from "../utils/sendEmail.js";
|
||||
import {getEmailsByType} from "../utils/getEmailByTypes.js";
|
||||
import { sendEmail } from '../utils/sendEmail.js';
|
||||
import { getEmailsByType } from '../utils/getEmailByTypes.js';
|
||||
|
||||
/* CREATE INQUIRY */
|
||||
export const createInquiry = async (req, res) => {
|
||||
try {
|
||||
const {fullName, number, emailId, subject, message} = req.body;
|
||||
const { fullName, number, emailId, subject, message } = req.body;
|
||||
|
||||
if (!fullName || !number) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: "Full name and number are required",
|
||||
message: 'Full name and number are required',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ export const createInquiry = async (req, res) => {
|
||||
},
|
||||
});
|
||||
try {
|
||||
const emailList = await getEmailsByType("INQUIRY");
|
||||
const emailList = await getEmailsByType('INQUIRY');
|
||||
|
||||
if (emailList && emailList.length > 0) {
|
||||
await sendEmail({
|
||||
to: emailList,
|
||||
subject: "New Inquiry Received",
|
||||
subject: 'New Inquiry Received',
|
||||
html: `
|
||||
<div style="font-family: Arial, sans-serif; background-color: #f4f6f8; padding: 20px;">
|
||||
|
||||
@@ -78,7 +78,7 @@ export const createInquiry = async (req, res) => {
|
||||
word-break: break-word;
|
||||
overflow-wrap: anywhere;
|
||||
">
|
||||
${message ? message.replace(/\n/g, "<br/>") : "-"}
|
||||
${message ? message.replace(/\n/g, '<br/>') : '-'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -96,20 +96,20 @@ export const createInquiry = async (req, res) => {
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Inquiry email failed:", err);
|
||||
console.error('Inquiry email failed:', err);
|
||||
}
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
status: 200,
|
||||
data: inquiry,
|
||||
message: "Inquiry added successfully",
|
||||
message: 'Inquiry added successfully',
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "Failed to add inquiry",
|
||||
message: 'Failed to add inquiry',
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -119,7 +119,7 @@ export const getInquiries = async (req, res) => {
|
||||
try {
|
||||
const inquiries = await prisma.inquiry.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
createdAt: 'desc',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -130,7 +130,7 @@ export const getInquiries = async (req, res) => {
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "Failed to fetch inquiries",
|
||||
message: 'Failed to fetch inquiries',
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -138,16 +138,16 @@ export const getInquiries = async (req, res) => {
|
||||
/* GET SINGLE */
|
||||
export const getInquiry = async (req, res) => {
|
||||
try {
|
||||
const {id} = req.params;
|
||||
const { id } = req.params;
|
||||
|
||||
const inquiry = await prisma.inquiry.findUnique({
|
||||
where: {id: Number(id)},
|
||||
where: { id: Number(id) },
|
||||
});
|
||||
|
||||
if (!inquiry) {
|
||||
return res.status(404).json({
|
||||
success: false,
|
||||
message: "Inquiry not found",
|
||||
message: 'Inquiry not found',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ export const getInquiry = async (req, res) => {
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "Failed to fetch inquiry",
|
||||
message: 'Failed to fetch inquiry',
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -166,20 +166,20 @@ export const getInquiry = async (req, res) => {
|
||||
/* DELETE */
|
||||
export const deleteInquiry = async (req, res) => {
|
||||
try {
|
||||
const {id} = req.params;
|
||||
const { id } = req.params;
|
||||
|
||||
await prisma.inquiry.delete({
|
||||
where: {id: Number(id)},
|
||||
where: { id: Number(id) },
|
||||
});
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
message: "Inquiry deleted successfully",
|
||||
message: 'Inquiry deleted successfully',
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "Failed to delete inquiry",
|
||||
message: 'Failed to delete inquiry',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user