-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from amankrokx/email
added email feature
- Loading branch information
Showing
4 changed files
with
83 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,47 @@ | ||
{ | ||
"database": { | ||
"rules": "database.rules.json" | ||
"database": { | ||
"rules": "database.rules.json" | ||
}, | ||
"hosting": { | ||
"public": "public", | ||
"ignore": [ | ||
"firebase.json", | ||
"**/.*", | ||
"**/node_modules/**", | ||
"**/src/**" | ||
], | ||
"rewrites": [ | ||
{ | ||
"source": "mail", | ||
"function": "mail" | ||
} | ||
] | ||
}, | ||
"storage": { | ||
"rules": "storage.rules" | ||
}, | ||
"functions": [ | ||
{ | ||
"source": "functions", | ||
"codebase": "default", | ||
"ignore": [ | ||
"node_modules", | ||
".git", | ||
"firebase-debug.log", | ||
"firebase-debug.*.log" | ||
], | ||
"predeploy": [ | ||
"npm --prefix \"$RESOURCE_DIR\" run lint" | ||
] | ||
} | ||
], | ||
"emulators": { | ||
"functions": { | ||
"port": 5001 | ||
}, | ||
"hosting": { | ||
"public": "public", | ||
"ignore": ["firebase.json", "**/.*", "**/node_modules/**", "**/src/**"] | ||
"ui": { | ||
"enabled": true | ||
}, | ||
"storage": { | ||
"rules": "storage.rules" | ||
} | ||
"singleProjectMode": true | ||
} | ||
} |
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
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,33 @@ | ||
/** | ||
* | ||
* @param {string?} name user's name | ||
* @param {string?} message | ||
// * @param {string} email Email address of the Admin | ||
*/ | ||
function sendMail(name = "RNSHalls User", message = "", email = "[email protected]") { | ||
// send email | ||
if (message === "") { | ||
message = `${new Date()}\nNew Hall Booking request for RNS Halls by ${name}\nVisit at https://rnshalls.web.app or https://halls.rnsit.ac.in\n\n RNS Halls` | ||
} | ||
fetch("/mail", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
redirect: "follow", | ||
body: JSON.stringify({ | ||
name, | ||
email, | ||
message, | ||
}), | ||
}).then((response) => { | ||
if (response.ok) { | ||
console.log("Email sent successfully") | ||
} else { | ||
console.error("Error sending email") | ||
alert("Warn: Admin not notified. Please inform them manually if urgent.") | ||
} | ||
}) | ||
} | ||
|
||
export default sendMail |