import React, { useEffect, useState } from 'react'
import { router, Link } from '@inertiajs/react'
import { usePrevious } from 'react-use'
import { Head } from '@inertiajs/react'
import { Button } from 'flowbite-react'
import { useModalState } from '@/hooks'
import { hasPermission } from '@/utils'
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
import Pagination from '@/Components/Pagination'
import SearchInput from '@/Components/SearchInput'
import ImportModal from './ImportModal'
import CustomerSelectionInput from '../Customer/SelectionInput'
export default function Customer(props) {
const {
query: { links, data },
auth,
} = props
const [search, setSearch] = useState('')
const [customer_id, setCustomerId] = useState(null)
const preValue = usePrevious(`${search}-${customer_id}`)
const importModal = useModalState()
const toggleImportModal = () => {
importModal.toggle()
}
const params = { q: search, customer_id: customer_id }
useEffect(() => {
if (preValue) {
router.get(
route(route().current()),
{ q: search, customer_id: customer_id },
{
replace: true,
preserveState: true,
}
)
}
}, [search, customer_id])
const canCreate = hasPermission(auth, 'create-customer-point')
return (
Customer | Point | Description |
---|---|---|
{point.customer.name} ({' '} {point.customer.code} ) | {point.point} | {point.description} |