import React, { useEffect, useState } from 'react' import { router } from '@inertiajs/react' import { usePrevious } from 'react-use' import { Head } from '@inertiajs/react' import { Button, Dropdown } from 'flowbite-react' import { HiPencil, HiTrash } from 'react-icons/hi' import { useModalState } from '@/hooks' import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout' import Pagination from '@/Components/Pagination' import ModalConfirm from '@/Components/ModalConfirm' import FormModal from './FormModal' import SearchInput from '@/Components/SearchInput' import { formatIDR, hasPermission } from '@/utils' import { HiEye } from 'react-icons/hi2' export default function Index(props) { const { query: { links, data }, auth, } = props const [search, setSearch] = useState('') const preValue = usePrevious(search) const formModal = useModalState() const toggleFormModal = (deposit = null) => { formModal.setData(deposit) formModal.toggle() } const params = { q: search } useEffect(() => { if (preValue) { router.get( route(route().current()), { q: search }, { replace: true, preserveState: true, } ) } }, [search]) const canUpdate = hasPermission(auth, 'update-deposit') return (
setSearch(e.target.value)} value={search} />
{data.map((deposit) => ( ))}
Customer Deposit Deskripsi Status
{deposit.customer.name} {deposit.amount} {deposit.description} {deposit.status.text} {canUpdate && (
toggleFormModal( deposit ) } >
Lihat
)}
) }