"use client" import { useState, Suspense } from "react" import { useRouter, useSearchParams } from "next/navigation" import Link from "next/link" const PLAN_INFO: Record = { free: { name: "Free", price: "$0/mo", apps: "5 apps" }, starter: { name: "Starter", price: "$29/mo", apps: "20 apps" }, pro: { name: "Pro", price: "$69/mo", apps: "100 apps" }, ultra: { name: "Ultra", price: "$149/mo", apps: "200 apps" }, unlimited: { name: "Unlimited", price: "$199/mo", apps: "Unlimited" }, agency_starter: { name: "Agency Starter", price: "$555/mo", apps: "1,000 submissions" }, agency_growth: { name: "Agency Growth", price: "$999/mo", apps: "3,000 submissions" }, agency_scale: { name: "Agency Scale", price: "$1,499/mo", apps: "5,000 submissions" }, agency_pro: { name: "Agency Pro", price: "$3,699/mo", apps: "10,000 submissions" }, agency_enterprise: { name: "Enterprise", price: "Contact Us", apps: "Unlimited" }, } function SignupForm() { const router = useRouter() const searchParams = useSearchParams() const planId = searchParams.get("plan") || "free" const userType = searchParams.get("type") || "private" const plan = PLAN_INFO[planId] || PLAN_INFO.free const [form, setForm] = useState({ name: "", email: "", password: "", confirmPassword: "" }) const [loading, setLoading] = useState(false) const [error, setError] = useState("") const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (form.password !== form.confirmPassword) { setError("Passwords don't match") return } setLoading(true) setError("") try { const res = await fetch("/autojobs/api/users", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name: form.name, email: form.email, password: form.password, user_type: userType, plan: planId }) }) if (res.ok) { const data = await res.json() if (planId === "free" || planId === "agency_enterprise") { router.push("/autojobs/dashboard") return } const checkoutRes = await fetch("https://hostpioneers.com/autojobs/api/create-checkout", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ user_id: data.user_id, plan_id: planId, user_type: userType }) }) if (checkoutRes.ok) { const checkoutData = await checkoutRes.json() if (checkoutData.checkout_url) { window.location.href = checkoutData.checkout_url return } } router.push("/autojobs/dashboard") } else { const data = await res.json() setError(data.error || "Signup failed") } } catch { setError("Network error") } setLoading(false) } return (
AutoJobs

Create your account

Selected Plan
{plan.name}
{plan.apps}/month
{plan.price}
{planId !== "free" && planId !== "agency_enterprise" && (
billed monthly
)}
{error && (
{error}
)}
setForm({...form, name: e.target.value})} className="w-full px-4 py-3 bg-slate-700 border border-slate-600 rounded-xl text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 text-sm" placeholder="John Smith" />
setForm({...form, email: e.target.value})} className="w-full px-4 py-3 bg-slate-700 border border-slate-600 rounded-xl text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 text-sm" placeholder="you@example.com" />
setForm({...form, password: e.target.value})} className="w-full px-4 py-3 bg-slate-700 border border-slate-600 rounded-xl text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 text-sm" placeholder="••••••••" />
setForm({...form, confirmPassword: e.target.value})} className="w-full px-4 py-3 bg-slate-700 border border-slate-600 rounded-xl text-white placeholder-slate-500 focus:outline-none focus:border-blue-500 text-sm" placeholder="••••••••" />

Already have an account? Sign in

By signing up, you agree to our Terms and Privacy Policy.

) } export default function SignupPage() { return (
Loading...
}>
) }