i-darrshan's picture
update
051fc03
raw
history blame
899 Bytes
const {runQuery, runSelectQuery} = require('./queries');
// Check existing contact request
async function checkExistingContactRequest(name, email, subject) {
const checkQuery = `SELECT * FROM contact_requests WHERE name = ? AND email = ? AND subject = ?;`;
const results = await runSelectQuery(checkQuery, [name, email, subject]);
return results.length > 0;
}
// Insert contact request
async function insertContactRequest(name, email, phone, subject, message, consent, policyVersion) {
const insertQuery = `INSERT INTO contact_requests (date, time, name, email, phone, subject, message, consent, policyVersion) VALUES (DATE("now"), TIME("now"), ?, ?, ?, ?, ?, ?, ?);`;
const boolConsent = consent?1:0;
await runQuery(insertQuery, [name, email, phone, subject, message, boolConsent, policyVersion]);
}
module.exports = { checkExistingContactRequest, insertContactRequest };