import React, { useEffect, useState } from 'react' import { usePrevious } from 'react-use' import { router } from '@inertiajs/react' import Modal from '@/Components/Modal' import Pagination from '@/Components/Pagination' import SearchInput from '@/Components/SearchInput' export default function LocationModal(props) { const { modalState, locations: { data, links }, onItemClick, } = props const [search, setSearch] = useState('') const preValue = usePrevious(search) const handleOnItemClick = (location) => { onItemClick(location) modalState.toggle() } const params = { location_q: search } useEffect(() => { if (preValue) { router.get( route(route().current()), { location_q: search }, { replace: true, preserveState: true, } ) } }, [search]) return (
setSearch(e.target.value)} />
{data.map((location) => ( handleOnItemClick(location)} > ))}
Nama Deskripsi
{location.name} {location.description}
) }