import React, { useEffect, MouseEvent, useState } from "react"; import { Outlet, useSearchParams } from "react-router-dom"; import Theme from "./theme"; import Citylist from "../Pages/citylist"; import { getPicure } from "../Pages/pic"; import { PaginationLeft ,PaginationRight} from "../Pages/picpagination"; const initSearchParams = { theme: "", city: "" }; export default function Body() { let limit = 15; const [searchParams, setSearchParams] = useSearchParams(initSearchParams); const [page, setPage] = useState(1); const offset = (page - 1) * limit; const [selected, setSelected] = useState(1); let getPics = getPicure(); useEffect(() => { console.log(searchParams.get("theme"), searchParams.get("city")); // setSearchParams(searchParams) }, []); const themeHandleClick = (event: MouseEvent) => { console.log(`theme id= ${event.currentTarget.id}`); setSearchParams({ ...Object.fromEntries(searchParams), theme: event.currentTarget.id, }); }; const cityHandleClick = (event: MouseEvent) => { console.log(`city id= ${event.currentTarget.id}`); setSearchParams({ ...Object.fromEntries(searchParams), city: event.currentTarget.id, }); }; let themechange = searchParams.get("theme"); let citylistchange = searchParams.get("city"); const Idpics = getPics.filter((p) => { return ( (p.themeid == themechange && p.cityid == citylistchange) || (p.themeid == themechange && citylistchange == "") || (themechange == "" && p.cityid == citylistchange) || (themechange == "" && citylistchange == "") ); }); const pre = () =>{ setSelected(selected -1) }; const next = () =>{ setSelected(selected + 1) }; return (
// Body Page ); } {/*
*/} {/* {Idpics.slice(offset, offset + limit).map((pic, index: number) => (

{pic.name}

))} */} {/* */} {/* */}