Spaces:
Running
Running
Ig0tU commited on
Commit ·
67fe0fc
1
Parent(s): bac09d2
Route form submissions to specific Google Sheet tabs based on origin URL
Browse files
server.js
CHANGED
|
@@ -103,9 +103,16 @@ app.post('/api/submit', async (req, res) => {
|
|
| 103 |
// We are going to append to Columns A to G (Timestamp, Name, Email, Message, Phone, Subject, Origin).
|
| 104 |
const TIMESTAMP = new Date().toISOString();
|
| 105 |
|
| 106 |
-
// The range specifies where to append.
|
| 107 |
-
//
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
const response = await sheets.spreadsheets.values.append({
|
| 111 |
spreadsheetId,
|
|
|
|
| 103 |
// We are going to append to Columns A to G (Timestamp, Name, Email, Message, Phone, Subject, Origin).
|
| 104 |
const TIMESTAMP = new Date().toISOString();
|
| 105 |
|
| 106 |
+
// The range specifies where to append.
|
| 107 |
+
// Dynamically sort into different tabs based on the origin URL!
|
| 108 |
+
let range = 'Sheet1';
|
| 109 |
+
if (origin) {
|
| 110 |
+
const lowerOrigin = origin.toLowerCase();
|
| 111 |
+
if (lowerOrigin.includes('contact')) range = 'Contact';
|
| 112 |
+
else if (lowerOrigin.includes('tours')) range = 'Tours';
|
| 113 |
+
else if (lowerOrigin.includes('escort')) range = 'Escort';
|
| 114 |
+
else if (lowerOrigin.includes('honor')) range = 'Honor';
|
| 115 |
+
}
|
| 116 |
|
| 117 |
const response = await sheets.spreadsheets.values.append({
|
| 118 |
spreadsheetId,
|