chore: file formatting
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
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 CANDIDATE
|
||||
|
||||
export const createCandidate = async (req, res) => {
|
||||
try {
|
||||
const { fullName, mobile, email, subject, coverLetter, careerId } =
|
||||
req.body;
|
||||
const { fullName, mobile, email, subject, coverLetter, careerId } = req.body;
|
||||
|
||||
if (!fullName || !mobile || !email || !careerId) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: "Required fields missing",
|
||||
message: 'Required fields missing',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,12 +31,12 @@ export const createCandidate = async (req, res) => {
|
||||
});
|
||||
|
||||
try {
|
||||
const emailList = await getEmailsByType("CANDIDATE");
|
||||
const emailList = await getEmailsByType('CANDIDATE');
|
||||
|
||||
if (emailList && emailList.length > 0) {
|
||||
await sendEmail({
|
||||
to: emailList,
|
||||
subject: "New Job Application Received",
|
||||
subject: 'New Job Application Received',
|
||||
html: `
|
||||
<div style="font-family: Arial, sans-serif; background-color: #f4f6f8; padding: 20px;">
|
||||
|
||||
@@ -76,15 +75,15 @@ export const createCandidate = async (req, res) => {
|
||||
<table style="width: 100%; border-collapse: collapse;">
|
||||
<tr>
|
||||
<td style="padding: 8px 0;"><b>Applied For:</b></td>
|
||||
<td style="padding: 8px 0;">${candidate.career?.post || "-"}</td>
|
||||
<td style="padding: 8px 0;">${candidate.career?.post || '-'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 8px 0;"><b>Designation:</b></td>
|
||||
<td style="padding: 8px 0;">${candidate.career?.designation || "-"}</td>
|
||||
<td style="padding: 8px 0;">${candidate.career?.designation || '-'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 8px 0;"><b>Subject:</b></td>
|
||||
<td style="padding: 8px 0;">${subject || "-"}</td>
|
||||
<td style="padding: 8px 0;">${subject || '-'}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -100,7 +99,7 @@ export const createCandidate = async (req, res) => {
|
||||
word-break: break-word;
|
||||
overflow-wrap: anywhere;
|
||||
">
|
||||
${coverLetter ? coverLetter.replace(/\n/g, "<br/>") : "-"}
|
||||
${coverLetter ? coverLetter.replace(/\n/g, '<br/>') : '-'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -118,19 +117,19 @@ export const createCandidate = async (req, res) => {
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Candidate email failed:", err);
|
||||
console.error('Candidate email failed:', err);
|
||||
}
|
||||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
message: "Application submitted successfully",
|
||||
message: 'Application submitted successfully',
|
||||
data: candidate,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "Failed to create candidate",
|
||||
message: 'Failed to create candidate',
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -144,7 +143,7 @@ export const getCandidates = async (req, res) => {
|
||||
career: true,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
createdAt: 'desc',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -156,7 +155,7 @@ export const getCandidates = async (req, res) => {
|
||||
console.error(error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "Failed to fetch candidates",
|
||||
message: 'Failed to fetch candidates',
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -179,7 +178,7 @@ export const getCandidate = async (req, res) => {
|
||||
if (!candidate) {
|
||||
return res.status(404).json({
|
||||
success: false,
|
||||
message: "Candidate not found",
|
||||
message: 'Candidate not found',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -191,7 +190,7 @@ export const getCandidate = async (req, res) => {
|
||||
console.error(error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "Failed to fetch candidate",
|
||||
message: 'Failed to fetch candidate',
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -210,7 +209,7 @@ export const getCandidatesByCareer = async (req, res) => {
|
||||
career: true,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
createdAt: 'desc',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -222,7 +221,7 @@ export const getCandidatesByCareer = async (req, res) => {
|
||||
console.error(error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "Failed to fetch candidates",
|
||||
message: 'Failed to fetch candidates',
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -242,14 +241,14 @@ export const updateCandidate = async (req, res) => {
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
message: "Candidate updated successfully",
|
||||
message: 'Candidate updated successfully',
|
||||
data: candidate,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "Failed to update candidate",
|
||||
message: 'Failed to update candidate',
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -268,13 +267,13 @@ export const deleteCandidate = async (req, res) => {
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
message: "Candidate deleted successfully",
|
||||
message: 'Candidate deleted successfully',
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
message: "Failed to delete candidate",
|
||||
message: 'Failed to delete candidate',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user