// ----------------------------------------------------------------------------- // Rent-Ka — Rental listings aggregator (Canada, outside Québec) // Author: Simon-Pierre Boucher — contact@spboucher.ai // pages/PublicProfile.tsx: PUBLIC member profile — /u/{ka_id} // Shareable member card (name, avatar, seniority, KA-ID) — never the // email. Visible only if the member enabled their public profile. // ----------------------------------------------------------------------------- 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/@", }; /** "@handle" or "handle" -> full platform URL; a URL is left as is */ 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("en-CA", { day: "numeric", month: "long", year: "numeric", }); }; 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
Loading…
; } if (profile === null) { return (

Profile not found

This member does not exist, or their profile is not public.

Explore rentals
); } return (
Member profile

{profile.name || "Rent-Ka member"}

Groupe KA Member card · Groupe KA
KA-ID {profile.ka_id}
{profile.name || "Rent-Ka member"} {profile.role_label && ( {profile.role_label} )} Member since {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} years old )} {profile.role === "gestionnaire" && ( Rental manager )} {profile.role === "locataire" && ( Looking for a rental )} {profile.website && ( Website ↗ )}
)} {Object.keys(profile.socials || {}).length > 0 && (
{SOCIAL_META.filter((s) => profile.socials[s.key]).map((s) => ( {s.icon} ))}
)}

Member of Rent-Ka, the rental listings aggregator of{" "} Groupe KA .

Explore rentals Create my account
); }