// ----------------------------------------------------------------------------- // Rent-Ka — Rental listings aggregator (Canada, outside Québec) // Author: Simon-Pierre Boucher — contact@spboucher.ai // pages/Passerelle.tsx: gateway page to the original listing. // Opened in a new tab by the listing CTAs: shows Rent-Ka → manager with a // progress bar, then redirects to the manager's ad after ~2.2 s. // Security: we receive a uid (never a raw URL) — the destination URL comes // from our API, not from the parameter. No open redirect possible. // ----------------------------------------------------------------------------- import { useEffect, useRef, useState } from "react"; import { Link, useParams } from "react-router-dom"; import { fetchListing, fetchSources, registerSourceNames, sourceName } from "../api"; const DELAI_MS = 2200; export default function PasserellePage() { const { uid } = useParams<{ uid: string }>(); const [dest, setDest] = useState<{ url: string; source: string } | null>(null); const [error, setError] = useState(false); const timer = useRef(null); useEffect(() => { if (!uid) return; let cancelled = false; Promise.all([fetchSources(), fetchListing(uid)]) .then(([src, l]) => { if (cancelled) return; registerSourceNames(src.sources); if (!l.url || !/^https?:\/\//.test(l.url)) { setError(true); return; } setDest({ url: l.url, source: l.source }); timer.current = window.setTimeout(() => { window.location.replace(l.url); }, DELAI_MS); }) .catch(() => !cancelled && setError(true)); return () => { cancelled = true; if (timer.current) window.clearTimeout(timer.current); }; }, [uid]); if (error) return (
⚠️

Listing not found

Could not find the original listing.

Back to rentals
); const nom = dest ? sourceName(dest.source) : "…"; return (
Rent·Ka

Gateway to the original listing

{dest ? <>We are taking you to {nom} — prices, visits and signatures happen directly with the manager. : "Preparing the redirect…"}

{dest && ( Go now ↗ )}
Rent-Ka is an independent aggregator: every listing links back to the ad published by the property manager.
); }