-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Demo-feature): 'Added Request A Demo Feature'
- Loading branch information
Abhishek Mishra
authored and
Abhishek Mishra
committed
Jun 12, 2022
1 parent
b15f78c
commit 9734316
Showing
16 changed files
with
628 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,3 +121,22 @@ exports.verificationMailer = function(mailType, teamName, teamManagerEmail, user | |
sendMail(userEmail, message[0], message[1]); | ||
}); | ||
}; | ||
/** | ||
* Description | ||
* @param {any} mailType | ||
* @param {any} userName | ||
* @param {any} userEmail | ||
* @param {any} userContact | ||
* @param {any} userOrg | ||
*/ | ||
exports.demoRequestMailer = function(mailType, userName, userEmail, userContact, userOrg) { | ||
const valueArray = []; | ||
valueArray.push(userName); | ||
valueArray.push(userEmail); | ||
valueArray.push(userContact); | ||
valueArray.push(userOrg); | ||
generateTemplate(mailType, valueArray).then((data) => { | ||
const message = data; | ||
sendMail("[email protected]", message[0], message[1]); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<!-- | ||
* Copyright (C) 2022 | ||
* Worktez | ||
* Author: Twinkle Chatterjee <[email protected]> | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the MIT License | ||
* | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the MIT License for more details. --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
<div style="background-color:#E9ECEF;margin:auto;width:80%;padding-top: 30px;height:100%;"> | ||
<table style="background-color:#ffffff;height:80%;width:80%;margin:auto;"> | ||
<tr> | ||
<td style="padding-top: 15px;"><img src="https://worktez.com/assets/logo.png" | ||
style="height:50%;width:50%;display:block;margin:auto;" alt="worktez logo"></td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<h2 style="text-align:center;">Welcome to Worktez</h2> | ||
</td> | ||
</tr> | ||
<tr style="text-align: center;"> | ||
<td style="width: 40%;"> | ||
<h4>Hi Admin, you've got a new Demo Request</h4> | ||
</td> | ||
</tr> | ||
</table> | ||
<table style="background-color:#ffffff;height:80%;width:80%;margin:auto; padding-left: 25%;" > | ||
|
||
<tr style="text-align: left;"> | ||
<td style="width: 200px;"> Person Name: </td> | ||
<td >$userName$</td> | ||
</tr> | ||
<tr style="text-align: left;"> | ||
<td > Email: </td> | ||
<td>$userEmail$</td> | ||
</tr> | ||
<tr style="text-align: left;"> | ||
<td> Contact: </td> | ||
<td>$userContact$</td> | ||
</tr> | ||
<tr style="text-align: left;"> | ||
<td>Organisation/Project Name: </td> | ||
<td>$orgName$</td> | ||
</tr> | ||
|
||
</table> | ||
<div style="text-align:center;padding:20px;"> | ||
<p style="color:#666;">Show us some love. Like & Follow us. Spread the word about Worktez.</p><a | ||
href="https://www.linkedin.com/company/worktez/" target="_blank"><svg | ||
xmlns="http://www.w3.org/2000/svg" width="16" height="16" class="bi bi-linkedin" viewBox="0 | ||
0 16 16" style="margin-left:10px;cursor:pointer;"> | ||
<path d="M0 1.146C0 .513.526 0 1.175 0h13.65C15.474 0 16 .513 16 1.146v13.708c0 .633-.526 | ||
1.146-1.175 1.146H1.175C.526 16 0 15.487 0 14.854V1.146zm4.943 | ||
12.248V6.169H2.542v7.225h2.401zm-1.2-8.212c.837 0 1.358-.554 | ||
1.358-1.248-.015-.709-.52-1.248-1.342-1.248-.822 0-1.359.54-1.359 1.248 0 .694.521 1.248 1.327 | ||
1.248h.016zm4.908 8.212V9.359c0-.216.016-.432.08-.586.173-.431.568-.878 1.232-.878.869 0 | ||
1.216.662 1.216 1.634v3.865h2.401V9.25c0-2.22-1.184-3.252-2.764-3.252-1.274 0-1.845.7-2.165 | ||
1.193v.025h-.016a5.54 5.54 0 0 1 .016-.025V6.169h-2.4c.03.678 0 7.225 0 7.225h2.4z"/> | ||
</svg></a><a href="https://github.com/Worktez/worktez" target="_blank"><svg | ||
xmlns="http://www.w3.org/2000/svg" width="16" height="16" class="bi bi-github" viewBox="0 0 | ||
16 16" style="margin-left:10px;cursor:pointer;"> | ||
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 | ||
0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 | ||
1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 | ||
0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 | ||
1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 | ||
3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 | ||
16 8c0-4.42-3.58-8-8-8z" /> | ||
</svg></a> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable linebreak-style */ | ||
/* eslint-disable object-curly-spacing */ | ||
/* eslint-disable eol-last */ | ||
/* eslint-disable indent */ | ||
/* eslint-disable max-len */ | ||
// eslint-disable-next-line no-dupe-else-if | ||
/** ********************************************************* | ||
* Copyright (C) 2022 | ||
* Worktez | ||
* Author : Abhishek Mishra <[email protected]> | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the MIT License | ||
* | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the MIT License for more details. | ||
***********************************************************/ | ||
|
||
const { db } = require("../application/lib"); | ||
|
||
/** | ||
* Description | ||
* @param {any} personName | ||
* @param {any} emailAddress | ||
* @param {any} requestId | ||
* @param {any} contactNumber | ||
* @param {any} orgName | ||
* @param {any} date | ||
* @param {any} time | ||
* @return {any} | ||
*/ | ||
exports.setRequest = function(personName, emailAddress, requestId, contactNumber, orgName, date, time) { | ||
const addRequestPromise = db.collection("DemoRequests").doc(requestId).set({ | ||
PersonName: personName, | ||
EmailAddress: emailAddress, | ||
ContactNumber: contactNumber, | ||
OrganisationOrProjectName: orgName, | ||
CreationDate: date, | ||
CreationTime: time, | ||
}); | ||
return Promise.resolve(addRequestPromise); | ||
}; | ||
|
||
/** | ||
* Description | ||
* @return {any} | ||
*/ | ||
exports.setDemoRequestData = function() { | ||
const P1 = db.collection("DemoRequests").doc("RawData").set({ | ||
DemoRequestCounter: 0, | ||
}); | ||
return Promise.resolve(P1); | ||
}; | ||
|
||
|
||
exports.getDemoRequestData = function() { | ||
const promise = db.collection("DemoRequests").doc("RawData").get().then((doc) => { | ||
if (doc.exists) { | ||
return doc.data(); | ||
} else { | ||
console.log("else triggered"); | ||
return; | ||
} | ||
}); | ||
return Promise.resolve(promise); | ||
}; | ||
|
||
/** | ||
* Description | ||
* @param {any} inputJson | ||
* @return {any} | ||
*/ | ||
exports.updateDemoRequestData = function(inputJson) { | ||
const P1 = db.collection("DemoRequests").doc("RawData").update(inputJson); | ||
return Promise.resolve(P1); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable linebreak-style */ | ||
/* eslint-disable object-curly-spacing */ | ||
/* eslint-disable eol-last */ | ||
/* eslint-disable indent */ | ||
/* eslint-disable max-len */ | ||
// eslint-disable-next-line no-dupe-else-if | ||
/** ********************************************************* | ||
* Copyright (C) 2022 | ||
* Worktez | ||
* Author : Abhishek Mishra <[email protected]> | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the MIT License | ||
* | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the MIT License for more details. | ||
***********************************************************/ | ||
const {functions, cors, fastify, requestHandler} = require("../application/lib"); | ||
const {addRequest} = require("./tark/addRequest"); | ||
/** | ||
* Description | ||
* @param {any} "/addRequest" | ||
* @param {any} req | ||
* @param {any} res | ||
* @returns {any} | ||
*/ | ||
fastify.post("/addRequest", (req, res) => { | ||
console.log("requestDemo triggered"); | ||
addRequest(req, res); | ||
}); | ||
|
||
exports.requestDemo = functions.https.onRequest((req, res) => { | ||
cors(req, res, () => { | ||
fastify.ready((err) => { | ||
if (err) throw err; | ||
requestHandler(req, res); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* eslint-disable linebreak-style */ | ||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable object-curly-spacing */ | ||
/* eslint-disable no-undef */ | ||
/* eslint-disable eol-last */ | ||
/* eslint-disable indent */ | ||
/* eslint-disable max-len */ | ||
// eslint-disable-next-line no-dupe-else-if | ||
|
||
/** ********************************************************* | ||
* Copyright (C) 2022 | ||
* Worktez | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the MIT License | ||
* | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the MIT License for more details. | ||
***********************************************************/ | ||
|
||
const { setRequest, getDemoRequestData, setDemoRequestData, updateDemoRequestData} = require("../lib"); | ||
const { demoRequestMailer } = require("../../mailer/lib"); | ||
|
||
exports.addRequest = function(request, response) { | ||
const personName = request.body.data.PersonName; | ||
const emailAddress = request.body.data.EmailAddress; | ||
const contactNumber = request.body.data.ContactNumber; | ||
const orgName = request.body.data.OrgName; | ||
const date = request.body.data.CreationDate; | ||
const time = request.body.data.CreationTime; | ||
|
||
// console.log(personName, emailAddress, contactNumber, orgName, date, time); | ||
let result; | ||
let status = 200; | ||
|
||
let demoRequestCounter = 0; | ||
const promise1 = getDemoRequestData().then((rawData) => { | ||
if (rawData==undefined) { | ||
setDemoRequestData().then(() => { | ||
demoRequestCounter = 1; | ||
const requestId = "R" + demoRequestCounter; | ||
|
||
setRequest(personName, emailAddress, requestId, contactNumber, orgName, date, time).then((postData) => { | ||
}).catch((error) => { | ||
result = { data: error }; | ||
status = 500; | ||
console.error("Error", error); | ||
}); | ||
}); | ||
} else { | ||
demoRequestCounter = rawData.DemoRequestCounter; | ||
demoRequestCounter = demoRequestCounter + 1; | ||
const requestId = "R" + demoRequestCounter; | ||
|
||
setRequest(personName, emailAddress, requestId, contactNumber, orgName, date, time).then((postData) => { | ||
}).catch((error) => { | ||
result = { data: error }; | ||
status = 500; | ||
console.error("Error", error); | ||
}); | ||
} | ||
const inputJson = { | ||
DemoRequestCounter: demoRequestCounter, | ||
}; | ||
updateDemoRequestData(inputJson); | ||
}); | ||
|
||
const Promises = [promise1]; | ||
return Promise.all(Promises).then(() => { | ||
result = { data: "Request Added successfully" }; | ||
demoRequestMailer("Demo_Request", personName, emailAddress, contactNumber, orgName); | ||
return response.status(status).send(result); | ||
}).catch((error) => { | ||
result = { data: error }; | ||
console.error("Error adding Post", error); | ||
return response.status(status).send(result); | ||
}); | ||
}; |
Oops, something went wrong.