// ----------------------------------------------------------------------------- // Lou-Ka — Agrégateur de logements à louer (province de Québec) // Auteur : Simon-Pierre Boucher — contact@spboucher.ai // pages/PublicProfile.tsx : profil membre PUBLIC — /u/{ka_id} // Carte de membre partageable (nom, avatar, ancienneté, KA-ID) — jamais le // courriel. Visible seulement si le membre a activé son profil public. // ----------------------------------------------------------------------------- import { useEffect, useState } from "react"; import { Link, useParams } from "react-router-dom"; import { PublicProfile, Socials, fetchPublicProfile } from "../api"; import { IcoCompass, IcoFacebook, IcoInstagram, IcoLinkedIn, IcoTikTok, IcoX, IcoYouTube, } from "../components/Icons"; const SOCIAL_META: { key: keyof Socials; label: string; icon: JSX.Element }[] = [ { key: "instagram", label: "Instagram", icon: }, { key: "facebook", label: "Facebook", icon: }, { key: "x", label: "X (Twitter)", icon: }, { key: "linkedin", label: "LinkedIn", icon: }, { key: "tiktok", label: "TikTok", icon: }, { key: "youtube", label: "YouTube", icon: }, ]; const SOCIAL_BASE: Record = { instagram: "https://www.instagram.com/", facebook: "https://www.facebook.com/", x: "https://x.com/", linkedin: "https://www.linkedin.com/in/", tiktok: "https://www.tiktok.com/@", youtube: "https://www.youtube.com/@", }; /** « @pseudo » ou « pseudo » -> URL complète de la plateforme ; URL laissée telle quelle */ function socialUrl(key: string, value: string): string { const v = value.trim(); if (/^https?:\/\//i.test(v)) return v; if (key === "website") return `https://${v}`; return (SOCIAL_BASE[key] ?? "https://") + v.replace(/^@/, ""); } const fmtEpoch = (ts: number | null | undefined): string => { if (!ts) return "—"; return new Date(ts * 1000).toLocaleDateString("fr-CA", { day: "numeric", month: "long", year: "numeric", }).replace(/^1 /, "1ᵉʳ "); }; export default function PublicProfilePage() { const { kaId = "" } = useParams(); const [profile, setProfile] = useState(undefined); useEffect(() => { fetchPublicProfile(kaId).then(setProfile).catch(() => setProfile(null)); }, [kaId]); if (profile === undefined) { return
Chargement…
; } if (profile === null) { return (

Profil introuvable

Ce membre n'existe pas, ou son profil n'est pas public.

Explorer les logements
); } return (
Profil membre

{profile.name || "Membre Lou-Ka"}

Groupe KA Carte de membre · Groupe KA
KA-ID {profile.ka_id}
{profile.name || "Membre Lou-Ka"} {profile.role_label && ( {profile.role_label} )} Membre depuis le {fmtEpoch(profile.created_at)}
{profile.picture && ( )}
{(profile.bio || profile.city || profile.role || profile.job_title || profile.company || profile.role_label) && (
{profile.bio &&

{profile.bio}

}
{(profile.job_title || profile.company) && ( {[profile.job_title, profile.company].filter(Boolean).join(" · ")} )} {profile.role_label && ( {profile.role_label} )} {profile.city && {profile.city}} {profile.age != null && ( {profile.age} ans )} {profile.role === "gestionnaire" && ( Gestionnaire de logements )} {profile.role === "locataire" && ( À la recherche d'un logement )} {profile.website && ( Site web ↗ )}
)} {Object.keys(profile.socials || {}).length > 0 && (
{SOCIAL_META.filter((s) => profile.socials[s.key]).map((s) => ( {s.icon} ))}
)}

Membre de Lou-Ka, l'agrégateur de logements à louer du{" "} Groupe KA .

Explorer les logements Créer mon compte
); }