1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150import type { FC } from 'hono/jsx';
import type { Context } from 'hono';
import { Layout } from '#src/components/Layout';
import { getCurrentUser } from '#src/utils/auth';
import { addToWaitlist } from '#src/utils/db';
const styles = `
.container {
max-width: 700px;
margin: 0 auto;
padding: 32px 20px;
}
h1 { margin: 0 0 8px 0; font-size: 28px; color: #1f2937; }
.subtitle { color: #6b7280; margin: 0 0 32px 0; }
.alert {
padding: 12px 16px;
border-radius: 6px;
margin-bottom: 24px;
font-size: 14px;
}
.alert-error { background: #fef2f2; border: 1px solid #C8102E; color: #C8102E; }
.alert-success { background: #f0fdf4; border: 1px solid #059669; color: #059669; }
.signup-form {
background: #f8f9fa;
border: 1px solid #d1d5db;
border-radius: 8px;
padding: 20px;
margin-bottom: 32px;
}
.signup-form h2 { margin: 0 0 16px 0; font-size: 16px; color: #1f2937; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: #6b7280; margin-bottom: 6px; }
.form-group input {
width: 100%;
padding: 10px 12px;
background: #ffffff;
border: 1px solid #d1d5db;
border-radius: 6px;
color: #1f2937;
font-size: 14px;
font-family: inherit;
box-sizing: border-box;
}
.form-group input:focus {
outline: none;
border-color: #C8102E;
}
.submit-btn {
background: #C8102E;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 6px;
font-size: 14px;
cursor: pointer;
font-weight: 600;
}
.submit-btn:hover { background: #a00d25; }
.success-box {
background: #f0fdf4;
border: 1px solid #059669;
border-radius: 8px;
padding: 32px;
text-align: center;
}
.success-box h2 {
margin: 0 0 8px 0;
font-size: 24px;
color: #059669;
}
.success-box p {
margin: 0;
color: #6b7280;
font-size: 15px;
}
`;
const SignupForm: FC<{ error?: string }> = ({ error }) => {
return (
<div class="signup-form">
<h2>Request Access</h2>
{error && <div class="alert alert-error">{error}</div>}
<form method="post" action="/signup/submit">
<div class="form-group">
<label>Name</label>
<input type="text" name="name" placeholder="Your name" required maxlength={100} />
</div>
<div class="form-group">
<label>Email</label>
<input type="email" name="email" placeholder="you@example.com" required maxlength={200} />
</div>
<button type="submit" class="submit-btn">Join the Waitlist</button>
</form>
</div>
);
};
const SignupPage: FC<{ onList: boolean; error?: string }> = ({ onList, error }) => {
const user = getCurrentUser();
return (
<Layout title="Sign Up - Equalify Hub" styles={styles} user={user}>
<div class="container">
<h1>Sign Up for Equalify</h1>
<p class="subtitle">Request early access to Equalify. We'll reach out when your spot is ready.</p>
{onList ? (
<div class="success-box">
<h2>๐ You're on the list!</h2>
<p>We'll be in touch soon. Thanks for your interest in Equalify!</p>
</div>
) : (
<SignupForm error={error} />
)}
</div>
</Layout>
);
};
export async function signupHandler(c: Context) {
const onList = c.req.query('success') === '1';
const error = c.req.query('error') || undefined;
return c.html(<SignupPage onList={onList} error={error} />);
}
export async function signupSubmitHandler(c: Context) {
const body = await c.req.parseBody();
const name = String(body.name || '').trim();
const email = String(body.email || '').trim();
const ip = c.req.header('x-forwarded-for')?.split(',')[0]?.trim()
|| c.req.header('cloudfront-viewer-address')?.split(':')[0]
|| 'Unknown';
if (!name) {
return c.redirect('/signup?error=Name+is+required');
}
if (!email) {
return c.redirect('/signup?error=Email+is+required');
}
const result = await addToWaitlist(name, email, ip);
if (!result) {
return c.redirect('/signup?error=Something+went+wrong.+Please+try+again.');
}
// Render the success page directly โ no redirect needed
return c.html(<SignupPage onList={true} />);
}