import React, { useEffect, useState } from 'react'
import { usePrevious } from 'react-use'
import { Head, Link } from '@inertiajs/inertia-react'
import { Inertia } from '@inertiajs/inertia'
import { toast } from 'react-toastify'
import { useModalState } from '@/Hooks'
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
import Pagination from '@/Components/Pagination'
import ModalConfirm from '@/Components/ModalConfirm'
import ModalFilter from './ModalFilter'
import DocStatusItem from './DocStatusItem'
import { IconFilter, IconMenu } from '@/Icons'
export default function Document(props) {
const { types, departments } = props
const { data: docs, links } = props.docs
const [search, setSearch] = useState({q: ''})
const preValue = usePrevious(search)
const confirmModal = useModalState(false)
const handleDelete = (doc) => {
confirmModal.setData(doc)
confirmModal.toggle()
}
const onDelete = () => {
const doc = confirmModal.data
if(doc != null) {
Inertia.delete(route('docs.destroy', doc), {
onSuccess: () => toast.success('The Data has been deleted'),
})
}
}
const filterModal = useModalState(false)
const handleFilter = (filter) => {
setSearch({
...search,
...filter
})
}
useEffect(() => {
if (preValue) {
Inertia.get(
route(route().current()),
search,
{
replace: true,
preserveState: true,
}
)
}
}, [search])
return (
No | No. Dokumen | Nama PIC | Jenis | Deparment | Status | |
---|---|---|---|---|---|---|
{doc.no} | {doc.no_doc} | {doc.pic_name} | {doc.type.name} | {doc.department.name} |
|