diff --git a/src/components/Posts/PostCard.jsx b/src/components/Posts/PostCard.jsx deleted file mode 100644 index 52ca087..0000000 --- a/src/components/Posts/PostCard.jsx +++ /dev/null @@ -1,39 +0,0 @@ -import React from "react"; - -function getKmFromPost(post) { - return ( - post.km ?? - post.distance_km ?? - post.distanceKm ?? - post.dist_km ?? - null - ); -} - -export default function PostCard({ post, selected, onSelect }) { - const title = post.title || post.name || "Post"; - - const fullBody = - post.body || post.content || post.text || ""; - - // texte court dans le Sociowall - const body = - fullBody.length > 80 ? fullBody.slice(0, 77) + "..." : fullBody; - - const km = getKmFromPost(post); - - function handleClick() { - if (onSelect) onSelect(post); - } - - return ( -
-

{title}

-

{body}

- {km != null && {km} km} -
- ); -} diff --git a/src/components/Posts/PostList.jsx b/src/components/Posts/PostList.jsx deleted file mode 100644 index 8091acf..0000000 --- a/src/components/Posts/PostList.jsx +++ /dev/null @@ -1,67 +0,0 @@ -import React, { useState, useMemo } from "react"; -import PostCard from "./PostCard"; - -function getKmFromPost(post) { - return ( - post.km ?? - post.distance_km ?? - post.distanceKm ?? - post.dist_km ?? - null - ); -} - -export default function PostList({ - posts, - loading, - error, - selectedPost, - onSelectPost, -}) { - const [kmFilter, setKmFilter] = useState(1000); - - const filtered = useMemo( - () => - posts.filter((p) => { - const km = getKmFromPost(p); - if (km == null) return true; - return km <= kmFilter; - }), - [posts, kmFilter] - ); - - return ( -
-
-
- - setKmFilter(Number(e.target.value))} - /> -
-
- - {loading &&

Chargement...

} - {error &&

{error}

} - - {filtered.map((p) => ( - - ))} - - {!loading && filtered.length === 0 && ( -

Aucun post dans ce rayon.

- )} -
- ); -} diff --git a/src/components/Posts/WallPage.jsx b/src/components/Posts/WallPage.jsx deleted file mode 100644 index 634ee4a..0000000 --- a/src/components/Posts/WallPage.jsx +++ /dev/null @@ -1,68 +0,0 @@ -import React, { useEffect, useMemo, useState } from "react"; -import { fetchPosts } from "../../api/client"; - -function useHashParams() { - const [hash, setHash] = useState(window.location.hash || ""); - useEffect(() => { - const onHash = () => setHash(window.location.hash || ""); - window.addEventListener("hashchange", onHash); - return () => window.removeEventListener("hashchange", onHash); - }, []); - const q = new URLSearchParams(hash.replace(/^#wall\??/, "")); - return { hash, params: q }; -} - -export default function WallPage() { - const { params } = useHashParams(); - const [posts, setPosts] = useState([]); - const [loading, setLoading] = useState(true); - - const filters = useMemo(() => { - const f = {}; - if (params.get("category")) f.category = params.get("category"); - if (params.get("sub")) f.subCategory = params.get("sub"); - if (params.get("time")) f.time = params.get("time"); - if (params.get("lat")) f.lat = Number(params.get("lat")); - if (params.get("lon")) f.lon = Number(params.get("lon")); - if (params.get("r")) f.radiusKm = Number(params.get("r")); - return f; - }, [params]); - - useEffect(() => { - let off = false; - (async () => { - try { - setLoading(true); - const data = await fetchPosts(filters); - if (!off) setPosts(Array.isArray(data) ? data : []); - } finally { - if (!off) setLoading(false); - } - })(); - return () => { - off = true; - }; - }, [filters]); - - return ( -
-
- -
SOCIOWALL — full view
-
- -
- {loading &&
Loading…
} - {!loading && posts.length === 0 &&
No posts with these filters.
} - {posts.map((p) => ( -
-

{p.title || "Post"}

-

{p.snippet || p.body || p.text || ""}

-
- ))} -
-
- ); -}