Skip to content

Commit cbef8c5

Browse files
committed
refactor(auth): streamline signup form to email only
1 parent 0165c57 commit cbef8c5

1 file changed

Lines changed: 43 additions & 121 deletions

File tree

app/signup/page.tsx

Lines changed: 43 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,23 @@ import { Input } from "@/components/ui/input"
88
import { Label } from "@/components/ui/label"
99
import Link from "next/link"
1010
import { motion, AnimatePresence } from "framer-motion"
11-
import { signUp } from "@/lib/features/auth"
11+
import { signInWithEmail } from "@/lib/features/auth"
1212
import { getTranslations, getUserLanguage } from "@/lib/config"
1313
import { LanguageSwitcher } from "@/components/language-switcher"
14-
import {
15-
EyeIcon,
16-
EyeSlashIcon,
17-
UserIcon,
18-
EnvelopeIcon,
19-
LockClosedIcon,
20-
ShieldCheckIcon,
21-
SparklesIcon,
22-
ArrowRightIcon,
23-
BoltIcon,
24-
CheckCircleIcon
14+
import {
15+
EnvelopeIcon,
16+
SparklesIcon,
17+
ArrowRightIcon,
18+
BoltIcon,
19+
CheckCircleIcon,
20+
ShieldCheckIcon
2521
} from "@heroicons/react/24/outline"
2622

2723
export default function SignUpPage() {
2824
const router = useRouter()
29-
const [name, setName] = useState("")
3025
const [email, setEmail] = useState("")
31-
const [password, setPassword] = useState("")
32-
const [confirmPassword, setConfirmPassword] = useState("")
3326
const [error, setError] = useState("")
34-
const [showPassword, setShowPassword] = useState(false)
35-
const [showConfirmPassword, setShowConfirmPassword] = useState(false)
27+
const [message, setMessage] = useState("")
3628
const [t, setT] = useState(getTranslations("en"))
3729

3830
useEffect(() => {
@@ -42,26 +34,17 @@ export default function SignUpPage() {
4234
const handleSignUp = async (e: React.FormEvent) => {
4335
e.preventDefault()
4436
setError("")
37+
setMessage("")
4538

46-
if (!name || !email || !password || !confirmPassword) {
47-
setError("All fields are required")
39+
if (!email) {
40+
setError("Email is required")
4841
return
4942
}
5043

51-
if (password !== confirmPassword) {
52-
setError("Passwords do not match")
53-
return
54-
}
55-
56-
if (password.length < 6) {
57-
setError("Password must be at least 6 characters")
58-
return
59-
}
60-
61-
const result = await signUp(email, password, name)
44+
const result = await signInWithEmail(email)
6245

6346
if (result.success) {
64-
router.push("/dashboard")
47+
setMessage("Check your email for the magic link to complete sign up!")
6548
} else {
6649
setError(result.error || "Sign up failed")
6750
}
@@ -77,12 +60,12 @@ export default function SignUpPage() {
7760
<div className="absolute bottom-[-10%] left-[-10%] w-[70%] h-[70%] bg-purple-600/20 rounded-full blur-[120px] animate-pulse delay-700"></div>
7861
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[50%] h-[50%] bg-pink-600/10 rounded-full blur-[120px] animate-pulse delay-1000"></div>
7962
</div>
80-
63+
8164
{/* Static noise texture */}
8265
<div className="absolute inset-0 opacity-20 pointer-events-none mix-blend-overlay bg-[url('https://grainy-gradients.vercel.app/noise.svg')]"></div>
8366

8467
<div className="relative z-10 flex flex-col justify-center items-center text-white p-20 w-full">
85-
<motion.div
68+
<motion.div
8669
initial={{ opacity: 0, x: -50 }}
8770
animate={{ opacity: 1, x: 0 }}
8871
transition={{ duration: 0.8, ease: "easeOut" }}
@@ -99,7 +82,7 @@ export default function SignUpPage() {
9982
<p className="text-xs font-bold uppercase tracking-[0.4em] text-primary/80">Innovation Lab</p>
10083
</div>
10184
</div>
102-
85+
10386
<div className="space-y-6">
10487
<h2 className="text-5xl font-bold leading-tight tracking-tight text-balance">
10588
Join the <br />
@@ -116,11 +99,11 @@ export default function SignUpPage() {
11699
{ icon: CheckCircleIcon, title: "Reliability", desc: "Built on secure infrastructure" },
117100
{ icon: ShieldCheckIcon, title: "Data Control", desc: "You are in full control of your code" }
118101
].map((item, idx) => (
119-
<motion.div
102+
<motion.div
120103
initial={{ opacity: 0, y: 10 }}
121104
animate={{ opacity: 1, y: 0 }}
122105
transition={{ delay: 0.5 + idx * 0.1 }}
123-
key={idx}
106+
key={idx}
124107
className="flex items-start gap-5 p-4 rounded-2xl hover:bg-white/5 transition-colors border border-transparent hover:border-white/5 group"
125108
>
126109
<div className="rounded-xl bg-primary/10 border border-primary/20 p-3 mt-1 group-hover:bg-primary/20 transition-all">
@@ -141,12 +124,12 @@ export default function SignUpPage() {
141124
<div className="flex-1 flex items-center justify-center p-8 bg-slate-950 relative overflow-hidden">
142125
{/* Background glow for mobile */}
143126
<div className="lg:hidden absolute top-[-20%] left-[-20%] w-full h-full bg-primary/5 rounded-full blur-[100px] pointer-events-none"></div>
144-
127+
145128
<div className="absolute top-8 right-8 z-20">
146129
<LanguageSwitcher />
147130
</div>
148131

149-
<motion.div
132+
<motion.div
150133
initial={{ opacity: 0, y: 20 }}
151134
animate={{ opacity: 1, y: 0 }}
152135
transition={{ duration: 0.8 }}
@@ -170,7 +153,7 @@ export default function SignUpPage() {
170153
<form onSubmit={handleSignUp} className="space-y-6">
171154
<AnimatePresence>
172155
{error && (
173-
<motion.div
156+
<motion.div
174157
initial={{ opacity: 0, height: 0 }}
175158
animate={{ opacity: 1, height: "auto" }}
176159
exit={{ opacity: 0, height: 0 }}
@@ -182,29 +165,22 @@ export default function SignUpPage() {
182165
</div>
183166
</motion.div>
184167
)}
168+
{message && (
169+
<motion.div
170+
initial={{ opacity: 0, height: 0 }}
171+
animate={{ opacity: 1, height: "auto" }}
172+
exit={{ opacity: 0, height: 0 }}
173+
className="rounded-2xl border border-green-500/50 bg-green-500/5 p-4 text-sm text-green-400 overflow-hidden"
174+
>
175+
<div className="flex items-center gap-3">
176+
<div className="w-1.5 h-6 bg-green-500 rounded-full"></div>
177+
<p className="font-medium">{message}</p>
178+
</div>
179+
</motion.div>
180+
)}
185181
</AnimatePresence>
186182

187183
<div className="space-y-5">
188-
<div className="space-y-2">
189-
<Label htmlFor="name" className="text-xs font-bold uppercase tracking-widest text-slate-500 ml-1">
190-
{t.auth.name}
191-
</Label>
192-
<div className="relative group">
193-
<div className="absolute left-4 top-1/2 -translate-y-1/2 flex items-center justify-center">
194-
<UserIcon className="h-5 w-5 text-slate-500 group-focus-within:text-primary transition-colors" />
195-
</div>
196-
<Input
197-
id="name"
198-
type="text"
199-
placeholder="Your Name"
200-
value={name}
201-
onChange={(e) => setName(e.target.value)}
202-
className="pl-12 h-14 bg-white/[0.03] border-white/5 hover:border-white/10 focus:border-primary/50 transition-all rounded-2xl text-lg placeholder:text-slate-600 focus:ring-0 focus:bg-white/[0.05]"
203-
required
204-
/>
205-
</div>
206-
</div>
207-
208184
<div className="space-y-2">
209185
<Label htmlFor="email" className="text-xs font-bold uppercase tracking-widest text-slate-500 ml-1">
210186
{t.auth.email}
@@ -224,60 +200,6 @@ export default function SignUpPage() {
224200
/>
225201
</div>
226202
</div>
227-
228-
<div className="space-y-2">
229-
<Label htmlFor="password" className="text-xs font-bold uppercase tracking-widest text-slate-500 ml-1">
230-
{t.auth.password}
231-
</Label>
232-
<div className="relative group">
233-
<div className="absolute left-4 top-1/2 -translate-y-1/2 flex items-center justify-center">
234-
<LockClosedIcon className="h-5 w-5 text-slate-500 group-focus-within:text-primary transition-colors" />
235-
</div>
236-
<Input
237-
id="password"
238-
type={showPassword ? "text" : "password"}
239-
placeholder="Min. 8 characters"
240-
value={password}
241-
onChange={(e) => setPassword(e.target.value)}
242-
className="pl-12 pr-12 h-14 bg-white/[0.03] border-white/5 hover:border-white/10 focus:border-primary/50 transition-all rounded-2xl text-lg placeholder:text-slate-600 focus:ring-0 focus:bg-white/[0.05]"
243-
required
244-
/>
245-
<button
246-
type="button"
247-
onClick={() => setShowPassword(!showPassword)}
248-
className="absolute right-4 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white transition-colors"
249-
>
250-
{showPassword ? <EyeSlashIcon className="h-5 w-5" /> : <EyeIcon className="h-5 w-5" />}
251-
</button>
252-
</div>
253-
</div>
254-
255-
<div className="space-y-2">
256-
<Label htmlFor="confirmPassword" className="text-xs font-bold uppercase tracking-widest text-slate-500 ml-1">
257-
Verification
258-
</Label>
259-
<div className="relative group">
260-
<div className="absolute left-4 top-1/2 -translate-y-1/2 flex items-center justify-center">
261-
<ShieldCheckIcon className="h-5 w-5 text-slate-500 group-focus-within:text-primary transition-colors" />
262-
</div>
263-
<Input
264-
id="confirmPassword"
265-
type={showConfirmPassword ? "text" : "password"}
266-
placeholder="Confirm password"
267-
value={confirmPassword}
268-
onChange={(e) => setConfirmPassword(e.target.value)}
269-
className="pl-12 pr-12 h-14 bg-white/[0.03] border-white/5 hover:border-white/10 focus:border-primary/50 transition-all rounded-2xl text-lg placeholder:text-slate-600 focus:ring-0 focus:bg-white/[0.05]"
270-
required
271-
/>
272-
<button
273-
type="button"
274-
onClick={() => setShowConfirmPassword(!showConfirmPassword)}
275-
className="absolute right-4 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white transition-colors"
276-
>
277-
{showConfirmPassword ? <EyeSlashIcon className="h-5 w-5" /> : <EyeIcon className="h-5 w-5" />}
278-
</button>
279-
</div>
280-
</div>
281203
</div>
282204

283205
<div className="text-sm text-slate-500 font-medium px-1">
@@ -287,28 +209,28 @@ export default function SignUpPage() {
287209
<Link href="/privacy" className="text-primary hover:text-white transition-all font-bold">Privacy Policy</Link>.
288210
</div>
289211

290-
<Button
291-
type="submit"
212+
<Button
213+
type="submit"
292214
className="w-full h-14 text-lg font-black uppercase tracking-widest bg-primary hover:bg-primary/90 text-slate-950 shadow-[0_0_20px_rgba(var(--primary-rgb),0.3)] hover:shadow-[0_0_30px_rgba(var(--primary-rgb),0.5)] transition-all group rounded-2xl"
293215
>
294-
Sign Up
216+
Send Magic Link
295217
<ArrowRightIcon className="ml-3 h-5 w-5 group-hover:translate-x-1.5 transition-transform" />
296218
</Button>
297219
</form>
298220

299221
<footer className="pt-6 space-y-6 text-center border-t border-white/5">
300222
<p className="text-slate-500 font-medium">
301223
Already have an account?{" "}
302-
<Link
303-
href="/login"
224+
<Link
225+
href="/login"
304226
className="text-white hover:text-primary font-bold underline decoration-primary/30 underline-offset-4 decoration-2 transition-all"
305227
>
306228
Sign In
307229
</Link>
308230
</p>
309-
310-
<Link
311-
href="/"
231+
232+
<Link
233+
href="/"
312234
className="inline-flex items-center gap-2 text-sm font-bold uppercase tracking-widest text-slate-600 hover:text-primary transition-all"
313235
>
314236
<span>← Back to Home</span>

0 commit comments

Comments
 (0)