feat: hotel technology landing page per owner brief
- new copy and sections for the five hotel services - form fields: name, work email, phone, company, service - reject free email providers on page and server - second form in the final CTA, mobile WhatsApp/call bar - schema: industry and message replaced by service Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
This commit is contained in:
1 parent
e73444e156
commit
c2ebee08df
5 files changed
+493
-257
No files matched your search
@@ -5,9 +5,13 @@ const { DatabaseSync } = require('node:sqlite');
|
||||
|
||||
const MAX_BODY = 10 * 1024;
|
||||
const REQUIRED = ['name', 'email', 'phone', 'company'];
|
||||
const OPTIONAL = ['industry', 'message', 'referrer', 'utm_source', 'utm_medium', 'utm_campaign'];
|
||||
const MAX_LEN = { message: 2000, referrer: 500 };
|
||||
const OPTIONAL = ['service', 'referrer', 'utm_source', 'utm_medium', 'utm_campaign'];
|
||||
const MAX_LEN = { referrer: 500 };
|
||||
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
const SERVICES = ['WiFi Managed Services', 'Cloud IP PABX', 'GRE IPTV', 'Digital Signage', 'QR Door Locks', 'Not sure yet'];
|
||||
// matches the domain's first label, so yahoo.com.my, hotmail.co.uk etc. are covered.
|
||||
// ponytail: fixed list of the common providers; extend if sales sees others slip through.
|
||||
const FREE_EMAIL = /@(gmail|googlemail|yahoo|ymail|rocketmail|hotmail|outlook|live|msn|icloud|me|mac|aol|protonmail|proton|gmx|yandex|zoho)\.[a-z.]+$/i;
|
||||
const PAGES = { '/': ['index.html', 'text/html; charset=utf-8'], '/logo.png': ['logo.png', 'image/png'] };
|
||||
|
||||
function openDb(dbPath) {
|
||||
@@ -20,7 +24,7 @@ function openDb(dbPath) {
|
||||
id INTEGER PRIMARY KEY,
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
name TEXT NOT NULL, email TEXT NOT NULL, phone TEXT NOT NULL, company TEXT NOT NULL,
|
||||
industry TEXT, message TEXT, referrer TEXT,
|
||||
service TEXT, referrer TEXT,
|
||||
utm_source TEXT, utm_medium TEXT, utm_campaign TEXT
|
||||
)`);
|
||||
return db;
|
||||
@@ -36,6 +40,8 @@ function validate(lead) {
|
||||
if (v && v.length > (MAX_LEN[f] || 200)) return `${f} is too long`;
|
||||
}
|
||||
if (!EMAIL.test(lead.email.trim())) return 'email is invalid';
|
||||
if (FREE_EMAIL.test(lead.email.trim())) return 'Please use your work email address';
|
||||
if (lead.service && !SERVICES.includes(lead.service)) return 'service is invalid';
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -67,8 +73,8 @@ function createServer(dbPath) {
|
||||
}
|
||||
const db = openDb(dbPath);
|
||||
const insert = db.prepare(`INSERT INTO leads
|
||||
(name, email, phone, company, industry, message, referrer, utm_source, utm_medium, utm_campaign)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
|
||||
(name, email, phone, company, service, referrer, utm_source, utm_medium, utm_campaign)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`);
|
||||
|
||||
const server = http.createServer(async (req, res) => {
|
||||
const url = req.url.split('?')[0];
|
||||
@@ -90,7 +96,7 @@ function createServer(dbPath) {
|
||||
if (error) return send(res, 400, { error });
|
||||
try {
|
||||
const t = (f) => (lead[f] ? lead[f].trim() : null);
|
||||
insert.run(t('name'), t('email'), t('phone'), t('company'), t('industry'), t('message'),
|
||||
insert.run(t('name'), t('email'), t('phone'), t('company'), t('service'),
|
||||
t('referrer'), t('utm_source'), t('utm_medium'), t('utm_campaign'));
|
||||
} catch (e) {
|
||||
console.error('lead insert failed:', e.message);
|
||||
|
||||
Reference in new issue
Block a user