SPB Git

Repository Public

LeadForm.tsx 3.4 KB 99 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/components/LeadForm.tsx9 * Module           : components10 * Repository       : https://git.spboucher.ai/vrai-prix11 * Created          : 2026-08-0912 * Last Modified    : 2026-08-2513 *14 * Author           : Simon-Pierre Boucher15 * Position         : Professor of Finance16 * Institution      : Université du Québec en Outaouais (UQO)17 * Organization     : SP Boucher18 * Website          : https://spboucher.ai19 * Git              : https://git.spboucher.ai20 *21 * Preferred Contact: contact@spboucher.ai22 * Development      : dev@spboucher.ai23 * Support          : support@spboucher.ai24 * Security/Admin   : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License          : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142"use client";43import { useState } from "react";44import { useLang } from "./LangContext";4546export default function LeadForm({47  unitId,48  estimate,49}: {50  unitId: string | null;51  estimate: number;52}) {53  const { t } = useLang();54  const [email, setEmail] = useState("");55  const [done, setDone] = useState(false);56  const [err, setErr] = useState(false);5758  const submit = async (e: React.FormEvent) => {59    e.preventDefault();60    setErr(false);61    const res = await fetch("/api/lead", {62      method: "POST",63      headers: { "Content-Type": "application/json" },64      body: JSON.stringify({ email, unitId, estimate }),65    });66    if (res.ok) setDone(true);67    else setErr(true);68  };6970  if (done)71    return (72      <p className="vp-mono border-l-2 border-[var(--accent-bright)] py-1 pl-4 text-[12px] font-bold uppercase tracking-[0.05em] text-[var(--paper-on-ink)]">73        ✓ {t("leadOk")}74      </p>75    );76  return (77    <form onSubmit={submit} className="flex flex-col gap-3 sm:flex-row sm:gap-0">78      <input79        type="email"80        required81        value={email}82        onChange={(e) => setEmail(e.target.value)}83        placeholder={t("emailPlaceholder")}84        className={`min-h-[50px] flex-1 border-0 border-b bg-transparent px-1 py-2.5 text-[16px] text-[var(--paper-on-ink)] outline-none transition-colors placeholder:text-[rgba(245,243,238,0.4)] ${85          err86            ? "border-[var(--danger)]"87            : "border-[rgba(245,243,238,0.45)] focus:border-[var(--accent-bright)]"88        }`}89      />90      <button91        type="submit"92        className="vp-display flex min-h-[50px] shrink-0 items-center justify-center gap-2 bg-[var(--accent-bright)] px-6 text-[14px] font-bold text-ink transition-colors hover:bg-[#ff6b63]"93      >94        {t("leadBtn")} →95      </button>96    </form>97  );98}99
Files main
Menu

Theme