const {runQuery, runSelectQuery} = require('./queries'); // Check existing job application async function checkExistingJobApplication(name, email, role) { const checkQuery = `SELECT * FROM applicants WHERE name = ? AND email = ? AND role = ?;`; const results = await runSelectQuery(checkQuery, [name, email, role]); console.log(results); return results.length > 0; } // Insert job application async function insertJobApplication(name, email, phone, experience, role, linkedin, resume, filename, consent, policyVersion) { const insertQuery = `INSERT INTO applicants (date, time, name, email, phone, experience, role, linkedin, resume, filename, consent, policyVersion) VALUES (DATE("now"), TIME("now"), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`; const boolConsent = Number(consent === "true"); console.log(typeof(boolConsent)); await runQuery(insertQuery, [name, email, phone, experience, role, linkedin, resume, filename, boolConsent, policyVersion]); } module.exports = { checkExistingJobApplication, insertJobApplication };