File size: 899 Bytes
8b105ad
 
 
 
 
 
 
 
 
 
051fc03
 
 
 
8b105ad
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 };