import React from 'react' import { router } from '@inertiajs/react' 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 { formatIDR, hasPermission } from '@/utils' export default function Info(props) { const { query: { links, data }, auth, } = props const confirmModal = useModalState() const formModal = useModalState() const toggleFormModal = (reward = null) => { formModal.setData(reward) formModal.toggle() } const handleDeleteClick = (reward) => { confirmModal.setData(reward) confirmModal.toggle() } const onDelete = () => { if (confirmModal.data !== null) { router.delete(route('coin-reward.destroy', confirmModal.data.id)) } } const canCreate = hasPermission(auth, 'create-coin-reward') const canUpdate = hasPermission(auth, 'update-coin-reward') const canDelete = hasPermission(auth, 'delete-coin-reward') return (
{canCreate && ( )}
{data.map((reward) => ( ))}
Jumlah Transaksi Level Coin
{formatIDR( reward.amount_buy )} {reward.level.name} {formatIDR( reward.bonus_coin )} {canUpdate && ( toggleFormModal( reward ) } >
Ubah
)} {canDelete && ( handleDeleteClick( reward ) } >
Hapus
)}
) }