Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : Vrai-Prix8 * File : src/lib/listing-types.ts9 * Module : lib10 * Repository : https://git.spboucher.ai/vrai-prix11 * Created : 2026-09-0812 * Last Modified : 2026-09-0813 *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// Vrai-Prix — groupes de types d'annonces Immo-Ka (module PUR : importable côté client).43export type TypeGroupKey =44 | "maison"45 | "condo"46 | "plex"47 | "terrain"48 | "chalet"49 | "fermette"50 | "mobile"51 | "commercial"52 | "autre";5354export const TYPE_GROUPS: { key: TypeGroupKey; fr: string; en: string }[] = [55 { key: "maison", fr: "Maison", en: "House" },56 { key: "condo", fr: "Condo", en: "Condo" },57 { key: "plex", fr: "Plex", en: "Plex" },58 { key: "terrain", fr: "Terrain", en: "Land" },59 { key: "chalet", fr: "Chalet", en: "Cottage" },60 { key: "fermette", fr: "Fermette / agricole", en: "Hobby farm" },61 { key: "mobile", fr: "Maison mobile", en: "Mobile home" },62 { key: "commercial", fr: "Commercial", en: "Commercial" },63 { key: "autre", fr: "Autre", en: "Other" },64];6566const fold = (s: string | null | undefined) =>67 (s ?? "")68 .normalize("NFD")69 .replace(/[\u0300-\u036f]/g, "")70 .toLowerCase()71 .trim();7273/** Type Immo-Ka (libre, sale) → groupe stable. Même logique que typeBucket du pipeline. */74export function typeGroup(pt: string | null): TypeGroupKey {75 const t = fold(pt);76 if (!t) return "autre";77 if (t.includes("condo")) return "condo";78 if (/(du|tri|quadru|multi)plex/.test(t) || t.includes("plex")) return "plex";79 if (t.includes("terrain") || t === "lot") return "terrain";80 if (t.includes("commerc") || t.includes("industri") || t.includes("bureau") || t.includes("service"))81 return "commercial";82 if (t.includes("chalet") || t.includes("recreativ")) return "chalet";83 if (t.includes("ferme") || t.includes("agric")) return "fermette";84 if (t.includes("mobile") || t.includes("roulotte")) return "mobile";85 if (86 t.includes("maison") ||87 t.includes("jumel") ||88 t.includes("detach") ||89 t.includes("residen") ||90 t === "propriete" ||91 t.includes("bungalow") ||92 t.includes("cottage")93 )94 return "maison";95 return "autre";96}9798/** groupe → type_prop du rôle (moteur) pour un sujet sans unité jumelée. */99export function groupToTypeProp(g: TypeGroupKey): string {100 switch (g) {101 case "condo":102 return "condo_ou_multi";103 case "plex":104 return "plex";105 case "terrain":106 return "terrain";107 case "chalet":108 return "chalet";109 case "mobile":110 return "maison_mobile";111 case "commercial":112 return "autre";113 default:114 return "unifamilial";115 }116}117118export function groupLabel(key: string, fr: boolean): string {119 const g = TYPE_GROUPS.find((x) => x.key === key);120 return g ? (fr ? g.fr : g.en) : key;121}122