Skip to content

Commit

Permalink
remove isExistingRecord check
Browse files Browse the repository at this point in the history
  • Loading branch information
elvisduru committed Apr 19, 2024
1 parent b30ec13 commit 5012788
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/mail/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,31 +307,31 @@ export const sendContactMail = async (form: Record<string, any>) => {
// const tableSlug = form?.eventType ? COURSE_CONFIGURATOR_TABLE_SLUG : BAMBOO_TABLE_SLUG;
const tableSlug = BAMBOO_TABLE_SLUG;
try {
const findRecordQuery = `
query{
${tableSlug}(filtersSet: {conjunction: and, filtersSet: [{field: _timestampId, operator: "contains", value: ["${form.timestampId}"]}]}){
records{
result{
id
}
}
}
}
`;
// const findRecordQuery = `
// query{
// ${tableSlug}(filtersSet: {conjunction: and, filtersSet: [{field: _timestampId, operator: "contains", value: ["${form.timestampId}"]}]}){
// records{
// result{
// id
// }
// }
// }
// }
// `;

console.debug("FINDING RECORD", findRecordQuery, tableSlug);
// console.debug("FINDING RECORD", findRecordQuery, tableSlug);

const res = await request(`${BAMBOO_SERVER_HOST}/${BAMBOO_SERVER_APP_ID}`, findRecordQuery);
console.debug("FIND_RECORD_RESPONSE", res);
// const res = await request(`${BAMBOO_SERVER_HOST}/${BAMBOO_SERVER_APP_ID}`, findRecordQuery);
// console.debug("FIND_RECORD_RESPONSE", res);

const isExistingRecord = res[tableSlug].records.result[0]?.id;
// const isExistingRecord = res[tableSlug].records.result[0]?.id;

console.debug("RECORD FOUND", isExistingRecord);
// console.debug("RECORD FOUND", isExistingRecord);

const { postId, ...formData } = form;

await sendDataToBambooTable(formData, tableSlug);
if (!isExistingRecord) await sendMail(formData);
await sendMail(formData);

// Create or Update post in leads channel
const postIdRes = await createOrUpdatePostInLeadsChannel({ ...formData, postId });
Expand Down

0 comments on commit 5012788

Please sign in to comment.