SPB Git

Repository Public

MobileTabBar.tsx 4.0 KB 122 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/components/MobileTabBar.tsx9 * Module           : components10 * Repository       : https://git.spboucher.ai/vrai-prix11 * Created          : 2026-08-2512 * Last Modified    : 2026-10-2013 *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/**43 * Barre de navigation mobile :44 * Estimer · À vendre · Marché · Coût · Méthode, accent rouge signature, bilingue.45 * Estimer mène immédiatement à la recherche d'adresse (focus du champ héros) ;46 * À vendre ouvre les propriétés réellement en vente (atelier d'évaluation) ;47 * Coût ouvre l'atelier de la méthode du coût. Le flux « dernières ventes »48 * reste accessible depuis l'accueil (#ventes).49 */50"use client";51import { useEffect, useState } from "react";52import { usePathname } from "next/navigation";53import TabBar from "./nav/TabBar";54import { useLang } from "./LangContext";5556/** focus du champ d'adresse (réessaie le temps que l'accueil se monte) */57function focusAdresse(tries = 10) {58  const el = document.getElementById("vp-adresse") as HTMLInputElement | null;59  if (el) {60    el.scrollIntoView({ block: "center", behavior: "smooth" });61    el.focus({ preventScroll: true });62  } else if (tries > 0) {63    window.setTimeout(() => focusAdresse(tries - 1), 100);64  }65}6667export default function MobileTabBar() {68  const path = usePathname();69  const { lang } = useLang();70  const fr = lang === "fr";71  const [hash, setHash] = useState("");7273  useEffect(() => {74    const sync = () => setHash(window.location.hash);75    sync();76    window.addEventListener("hashchange", sync);77    return () => window.removeEventListener("hashchange", sync);78  }, [path]);7980  const ventes = path === "/" && hash === "#ventes";81  return (82    <TabBar83      tabs={[84        {85          label: fr ? "Estimer" : "Estimate",86          icon: "target",87          to: "/",88          onClick: () => {89            setHash("");90            focusAdresse();91          },92          active: (path === "/" && !ventes) || path.startsWith("/estimation"),93        },94        {95          label: fr ? "À vendre" : "For sale",96          icon: "tag",97          to: "/a-vendre",98          active: path.startsWith("/a-vendre"),99        },100        {101          label: fr ? "Marché" : "Market",102          icon: "trendup",103          to: "/stats",104          active: path.startsWith("/stats") || path.startsWith("/municipalite") || path.startsWith("/ventes"),105        },106        {107          label: fr ? "Coût" : "Cost",108          icon: "home",109          to: "/cout",110          active: path.startsWith("/cout"),111        },112        {113          label: fr ? "Méthode" : "Method",114          icon: "book",115          to: "/methodologie",116          active: path.startsWith("/methodologie"),117        },118      ]}119    />120  );121}122
Files main
Menu

Theme