AeThex-OS/temp-forge-extract/aethex-forge-main/client/components/wix/LeadForm.tsx
MrPiglr b3c308b2c8 Add functional marketplace modules, bottom nav bar, root terminal, arcade games
- ModuleManager: Central tracking for installed marketplace modules
- DataAnalyzerWidget: Real-time CPU/RAM/Battery/Storage widget (unlocked by Data Analyzer module)
- BottomNavBar: Navigation bar for Projects/Chat/Marketplace/Settings
- RootShell: Real root command execution utility
- TerminalActivity: Full root shell with neofetch, sysinfo, real Linux commands
- Terminal Pro module: Adds aliases (ll, la, h), command history
- ArcadeActivity + SnakeGame: Pixel Arcade module unlocks retro games
- fade_in/fade_out animations for smooth transitions
2026-02-18 22:03:50 -07:00

171 lines
5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useEffect, useMemo, useState } from "react";
const API_BASE = import.meta.env.VITE_API_BASE || "";
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { useAuth } from "@/contexts/AuthContext";
import { useToast } from "@/components/ui/use-toast";
export default function LeadForm() {
const { user, profile } = useAuth();
const { toast } = useToast();
const [loading, setLoading] = useState(false);
const [form, setForm] = useState({
name: "",
email: "",
company: "",
website: "",
budget: "",
timeline: "",
message: "",
source: "wix",
});
const inferred = useMemo(() => {
const full = (profile?.full_name || "").trim();
const email = (user?.email || profile?.email || "").trim();
return { full, email };
}, [user, profile]);
useEffect(() => {
setForm((f) => ({
...f,
name: f.name || inferred.full,
email: f.email || inferred.email,
}));
}, [inferred.full, inferred.email]);
const update = (k: keyof typeof form) => (e: any) =>
setForm({ ...form, [k]: e.target.value });
const submit = async () => {
if (!form.email) {
toast({
title: "Email required",
description: "Please provide a valid email.",
});
return;
}
setLoading(true);
try {
const r = await fetch(`${API_BASE}/api/leads`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(form),
});
const ok = r.ok;
const data = await r.json().catch(() => ({}));
if (!ok) throw new Error(data?.error || `Request failed (${r.status})`);
toast({
title: "Thanks!",
description: "Well follow up shortly with next steps.",
});
setForm({ ...form, message: "" });
} catch (e: any) {
toast({
title: "Submission failed",
description: e?.message || "Try again later.",
variant: "destructive" as any,
});
} finally {
setLoading(false);
}
};
return (
<section id="start" className="container mx-auto px-4 py-12">
<Card className="border-border/40 bg-card/60 backdrop-blur">
<CardHeader>
<CardTitle>Start a Wix project</CardTitle>
<CardDescription>
Tell us a bit about your goals. Well get back within 1 business
day.
</CardDescription>
</CardHeader>
<CardContent className="grid gap-4 md:grid-cols-2">
<div className="space-y-2">
<Label htmlFor="name">Name</Label>
<Input
id="name"
value={form.name}
onChange={update("name")}
placeholder="Your name"
/>
</div>
<div className="space-y-2">
<Label htmlFor="email">Email</Label>
<Input
id="email"
value={form.email}
onChange={update("email")}
placeholder="you@company.com"
/>
</div>
<div className="space-y-2">
<Label htmlFor="company">Company</Label>
<Input
id="company"
value={form.company}
onChange={update("company")}
placeholder="Company Inc."
/>
</div>
<div className="space-y-2">
<Label htmlFor="website">Website</Label>
<Input
id="website"
value={form.website}
onChange={update("website")}
placeholder="https://example.com"
/>
</div>
<div className="space-y-2">
<Label htmlFor="budget">Budget</Label>
<Input
id="budget"
value={form.budget}
onChange={update("budget")}
placeholder="e.g. $5k$10k"
/>
</div>
<div className="space-y-2">
<Label htmlFor="timeline">Timeline</Label>
<Input
id="timeline"
value={form.timeline}
onChange={update("timeline")}
placeholder="e.g. 46 weeks"
/>
</div>
<div className="space-y-2 md:col-span-2">
<Label htmlFor="message">Project overview</Label>
<Textarea
id="message"
value={form.message}
onChange={update("message")}
placeholder="What are you building? Who is it for? What does success look like?"
/>
</div>
<div className="md:col-span-2">
<Button
onClick={submit}
disabled={loading}
className="w-full md:w-auto"
>
{loading ? "Submitting…" : "Submit"}
</Button>
</div>
</CardContent>
</Card>
</section>
);
}