// ----------------------------------------------------------------------------- // Rent-Ka — Rental listings aggregator (Canada, outside Québec) // Author: Simon-Pierre Boucher — contact@spboucher.ai // pages/GestionPublic.tsx: public page of a property management — /g/{source} // Banner customized by the manager (tagline, description, contact, logo) // + automatically linked inventory (12/page, pagination). // ----------------------------------------------------------------------------- import { useEffect, useState } from "react"; import { Link, useParams } from "react-router-dom"; import { Listing, OrgProfile, fetchListings, fetchOrg } from "../api"; import ListingCard from "../components/ListingCard"; import Pager from "../components/Pager"; import { IcoCompass, IcoPin } from "../components/Icons"; const PAGE_SIZE = 12; export default function GestionPublicPage() { const { sourceId = "" } = useParams(); const [org, setOrg] = useState(undefined); const [listings, setListings] = useState(null); const [total, setTotal] = useState(0); const [page, setPage] = useState(1); useEffect(() => { fetchOrg(sourceId).then(setOrg).catch(() => setOrg(null)); setPage(1); }, [sourceId]); useEffect(() => { setListings(null); fetchListings({ source: sourceId }, PAGE_SIZE, (page - 1) * PAGE_SIZE) .then((r) => { setListings(r.listings); setTotal(r.total); }) .catch(() => setListings([])); }, [sourceId, page]); if (org === undefined) { return
Loading…
; } if (org === null) { return (

Page not found

This management does not exist on Rent-Ka.

Explore rentals
); } return (
{org.logo_url && ( )}
Property management

{org.name}

{org.tagline &&

{org.tagline}

}
{org.active_listings} active rentals {org.claimed && Page managed by the organization} {org.phone && {org.phone}} {org.email && {org.email}} {org.website && ( Website ↗ )}
{org.description &&

{org.description}

}

Available rentals

{listings && {total} result{total > 1 ? "s" : ""}}
{listings === null && (
{Array.from({ length: 4 }).map((_, i) => (
))}
)} {listings !== null && ( <>
{listings.map((l) => )}
{ setPage(p); window.scrollTo({ top: 0, behavior: "smooth" }); }} /> )}
); }