import React, { useState, useEffect } from 'react'
import { Head, Link, router } from '@inertiajs/react'
import { usePrevious } from 'react-use'
import { HiEye, HiFilter, HiOutlineFilter } from 'react-icons/hi'
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
import Pagination from '@/Components/Pagination'
import SearchInput from '@/Components/SearchInput'
import { formatIDR } from '@/utils'
import { useModalState } from '@/hooks'
import ModalFilter from './ModalFilter'
import ThSort from '@/Components/ThSortComponent'
export default function Info(props) {
const {
query: { links, data },
customer_with_deposit,
customer_with_paylaters,
_q,
_sortBy,
_sortRule,
} = props
const filterModal = useModalState()
const [search, setSearch] = useState({
q: _q,
sortBy: _sortBy,
sortRule: _sortRule,
})
const preValue = usePrevious(search)
const handleChangeSearch = (e) => {
setSearch({
...search,
q: e.target.value,
})
}
const handleFilter = (filter) => {
setSearch({
...search,
...filter,
})
}
const sort = (key, sort = null) => {
if (sort !== null) {
setSearch({
...search,
sortBy: key,
sortRule: sort,
})
return
}
setSearch({
...search,
sortBy: key,
sortRule: search.sortRule == 'asc' ? 'desc' : 'asc',
})
}
const params = { ...search }
useEffect(() => {
if (preValue) {
router.get(
route(route().current()),
{ ...search },
{
replace: true,
preserveState: true,
}
)
}
}, [search])
return (
Saldo Deposit
Nama
|
Total Beli
|
{customer_with_deposit.map((sale) => (
{sale.customer.name}
|
Rp. {formatIDR(sale.total)}
|
))}
Saldo Hutang
Nama
|
Total Beli
|
{customer_with_paylaters.map((sale) => (
{sale.customer.name}
|
Rp. {formatIDR(sale.total)}
|
))}
#
Customer
Tanggal
Pembayaran
Voucher
|
Total
|
{data.map((sale) => (
{sale.code}
|
{sale.customer.name}
|
{sale.format_created_at}
|
{sale.payment_with}
|
{formatIDR(
sale.items_count
)}
|
{formatIDR(sale.amount)}
|
router.get(
route(
'sale.show',
sale
)
)
}
>
Lihat
|
))}
)
}