SPB Git

Repository Public

EstimateForm.tsx 4.6 KB 146 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/components/EstimateForm.tsx9 * Module           : components10 * Repository       : https://git.spboucher.ai/vrai-prix11 * Created          : 2026-08-0912 * Last Modified    : 2026-08-0913 *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 { useRouter } from "next/navigation";45import { useLang } from "./LangContext";4647const TYPES = [48  "unifamilial",49  "plex",50  "condo_ou_multi",51  "chalet",52  "maison_mobile",53  "terrain",54] as const;5556export default function EstimateForm() {57  const { t } = useLang();58  const router = useRouter();59  const [municipality, setMunicipality] = useState("");60  const [typeProp, setTypeProp] = useState<string>("unifamilial");61  const [floorArea, setFloorArea] = useState("");62  const [yearBuilt, setYearBuilt] = useState("");63  const [landArea, setLandArea] = useState("");6465  const submit = (e: React.FormEvent) => {66    e.preventDefault();67    const p = new URLSearchParams({ municipality, typeProp });68    if (floorArea) p.set("floorArea", floorArea);69    if (yearBuilt) p.set("yearBuilt", yearBuilt);70    if (landArea) p.set("landArea", landArea);71    router.push(`/estimation/manuelle?${p.toString()}`);72  };7374  return (75    <form76      onSubmit={submit}77      className="grid grid-cols-2 gap-3 sm:grid-cols-3 sm:gap-4"78    >79      <label className="col-span-2 flex flex-col gap-1.5 sm:col-span-1">80        <span className="klabel pl-0.5">{t("municipality")} *</span>81        <input82          required83          value={municipality}84          onChange={(e) => setMunicipality(e.target.value)}85          className="vp-input"86          placeholder="Montréal, Québec, Lévis…"87        />88      </label>89      <label className="flex flex-col gap-1.5">90        <span className="klabel pl-0.5">{t("propertyType")} *</span>91        <select92          value={typeProp}93          onChange={(e) => setTypeProp(e.target.value)}94          className="vp-input"95        >96          {TYPES.map((ty) => (97            <option key={ty} value={ty}>98              {t(ty)}99            </option>100          ))}101        </select>102      </label>103      <label className="flex flex-col gap-1.5">104        <span className="klabel pl-0.5">{t("floorArea")}</span>105        <input106          type="number"107          min={10}108          max={5000}109          value={floorArea}110          onChange={(e) => setFloorArea(e.target.value)}111          className="vp-input"112          placeholder="120"113        />114      </label>115      <label className="flex flex-col gap-1.5">116        <span className="klabel pl-0.5">{t("yearBuilt")}</span>117        <input118          type="number"119          min={1700}120          max={2026}121          value={yearBuilt}122          onChange={(e) => setYearBuilt(e.target.value)}123          className="vp-input"124          placeholder="1985"125        />126      </label>127      <label className="flex flex-col gap-1.5">128        <span className="klabel pl-0.5">{t("landArea")}</span>129        <input130          type="number"131          min={0}132          value={landArea}133          onChange={(e) => setLandArea(e.target.value)}134          className="vp-input"135          placeholder="500"136        />137      </label>138      <div className="flex items-end">139        <button type="submit" className="btn btn-primary w-full">140          {t("estimateBtn")} →141        </button>142      </div>143    </form>144  );145}146
Files main
Menu

Theme