// ----------------------------------------------------------------------------- // Rent-Ka — Rental listings aggregator (Canada, outside Québec) // Author: Simon-Pierre Boucher — contact@spboucher.ai // pages/Gestion.tsx: manager dashboard — claim YOUR page (source) then // customize it (tagline, description, contact info, logo). The matching // public page lives at /g/{source}. // ----------------------------------------------------------------------------- import { useEffect, useMemo, useState } from "react"; import { Link } from "react-router-dom"; import { Source, claimOrg, fetchMyOrg, fetchSources, updateOrg, } from "../api"; import { useAccount } from "../account"; import { IcoBuilding } from "../components/Icons"; interface OrgMine { source: string | null; name?: string; active_listings?: number; profile?: Record; } export default function GestionPage() { const { me, loaded, refresh } = useAccount(); const [org, setOrg] = useState(null); const [sources, setSources] = useState([]); const [pick, setPick] = useState(""); const [saving, setSaving] = useState(false); const [saved, setSaved] = useState(false); const [error, setError] = useState(""); const [form, setForm] = useState({ tagline: "", description: "", website: "", phone: "", email: "", logo_url: "", }); useEffect(() => { if (me) fetchMyOrg().then((o) => { setOrg(o); const p = o.profile ?? {}; setForm({ tagline: p.tagline ?? "", description: p.description ?? "", website: p.website ?? "", phone: p.phone ?? "", email: p.email ?? "", logo_url: p.logo_url ?? "", }); }).catch(() => setOrg({ source: null })); }, [me]); useEffect(() => { if (me && org && !org.source) { fetchSources().then((r) => setSources(r.sources)).catch(() => {}); } }, [me, org]); const claimable = useMemo( () => sources .filter((s) => s.connector && s.active_listings > 0) .sort((a, b) => a.name.localeCompare(b.name, "en")), [sources]); if (loaded && !me) { return (
Manager space

Sign in to manage your page.

Sign in with KA ID
); } if (me && me.role !== "gestionnaire") { return (
Manager space

Reserved for managers.

Your account is in tenant mode. If you manage rentals displayed on Rent-Ka, switch profiles.

Change profile
); } const doClaim = async () => { if (!pick) return; setError(""); const res = await claimOrg(pick); if (!res.ok) { setError(res.status === 409 ? "This page is already claimed by another account." : "Could not claim this page."); return; } refresh(); const o = await fetchMyOrg(); setOrg(o); }; const doSave = async () => { setSaving(true); setError(""); const res = await updateOrg(form); setSaving(false); if (!res.ok) { setError("Could not save — try again."); return; } setSaved(true); setTimeout(() => setSaved(false), 2000); }; return (
Manager space {org && !org.source && ( <>

Claim the page of your management.

Pick your organization among the sources displayed on Rent-Ka. You'll then be able to customize its public page — your inventory is already linked automatically.

{error &&

{error}

}

Can't find your organization? Write to us at{" "} contact@groupe-ka.com and we'll add your site as a source.

)} {org && org.source && ( <>

{org.name}

{org.active_listings ?? 0} active linked rentals See my public page ↗

Customize my page