Check if full thing is a duplicate

This commit is contained in:
Matthew Stanciu 2020-04-27 16:34:08 -04:00
parent 73bb13b31d
commit a5c76dc272

View file

@ -11,7 +11,7 @@ export default async (req, res) => {
if (req.method === 'POST') {
const data = JSON.parse(req.body)
const exists = await recordExists(data.name)
const exists = await isDuplicate(data.name)
const empty = await isEmpty(data)
if (!exists && !empty) {
@ -26,9 +26,9 @@ export default async (req, res) => {
}
}
async function recordExists(name) {
async function isDuplicate(name, email, teen, reason) {
const exists = await joinTable.read({
filterByFormula: `{Full Name} = '${name}'`
filterByFormula: `AND({Full Name} = '${name}', {Email Address} = '${email}', {Studnet} = '${teen}', {Reason} = '${reason}')`
})
return typeof exists[0] !== 'undefined'
}