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 AuthenticatedLayout from '@/Layouts/AuthenticatedLayout' import Pagination from '@/Components/Pagination' import SearchInput from '@/Components/SearchInput' import { formatIDR, hasPermission } from '@/utils' export default function Index(props) { const { query: { links, data }, location, stats, auth, } = props const [search, setSearch] = useState('') const preValue = usePrevious(`${search}`) const params = { q: search } useEffect(() => { if (preValue) { router.get( route(route().current()), { q: search }, { replace: true, preserveState: true, } ) } }, [search]) const canCreate = hasPermission(auth, 'create-voucher') return (
Total Voucher
{formatIDR(stats.count_voucher_total)} PCS
Total Voucher
Rp. {formatIDR(stats.sum_voucher_total)}
Total Voucher sudah terjual
{formatIDR(stats.count_voucher_sold)} PCS
Jumlah Voucher sudah terjual
Rp. {formatIDR(stats.sum_voucher_sold)}
Total Voucher belum terjual
{formatIDR(stats.count_voucher_unsold)} PCS
Jumlah Voucher belum terjual
Rp. {formatIDR(stats.sum_voucher_unsold)}
{canCreate && (
)}
setSearch(e.target.value) } value={search} />
{data.map((profile) => (
{profile.name}
{ profile.count_vouchers .unsold_count }
))}
) }