// ----------------------------------------------------------------------------- // Rent-Ka — Rental listings aggregator (Canada, outside Québec) // Author: Simon-Pierre Boucher — contact@spboucher.ai // pages/Favoris.tsx: the rentals saved by the signed-in account // ----------------------------------------------------------------------------- import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { Listing, fetchFavorites } from "../api"; import { useAccount } from "../account"; import ListingCard from "../components/ListingCard"; import { IcoHeart } from "../components/Icons"; export default function FavorisPage() { const { me, loaded, favs } = useAccount(); const [listings, setListings] = useState(null); useEffect(() => { if (me) fetchFavorites().then((f) => setListings(f.listings)).catch(() => setListings([])); }, [me]); if (loaded && !me) { return (
Saved rentals

Sign in to keep your favourites.

Sign in with KA ID
); } // only show what is still saved (instant toggle without re-fetch) const visible = (listings ?? []).filter((l) => favs.has(l.uid)); return (
Saved rentals

Your favourites.

{listings === null && me &&
Loading…
} {listings !== null && visible.length === 0 && (

Nothing saved yet

Tap the heart on a listing to find it here.

Explore rentals
)} {visible.length > 0 && (
{visible.map((l) => )}
)}
); }