import React, { useEffect, MouseEvent } from "react"; import { Outlet, useSearchParams } from "react-router-dom"; import Theme from "./theme"; import Citylist from "./citylist"; import {getPicure} from "./pic"; const initSearchParams = { "theme": "", "city": "" } export default function Body() { const [searchParams, setSearchParams] = useSearchParams(initSearchParams) 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 }) } const Idpics = getPics.filter(p => { return (p.themeid == searchParams.get('theme') && p.cityid == searchParams.get('city'))||(p.themeid == searchParams.get('theme') && searchParams.get('city') == "") ||(searchParams.get('theme') == "" && p.cityid == searchParams.get('city'))||(searchParams.get('theme') == "" && searchParams.get('city') == "") }) return (
{Idpics.map((pic, index: number) => (

{pic.name}

))}
// Body Page ); };