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('poin-reward.destroy', confirmModal.data.id)) } } const canCreate = hasPermission(auth, 'create-poin-reward') const canUpdate = hasPermission(auth, 'update-poin-reward') const canDelete = hasPermission(auth, 'delete-poin-reward') return (
{canCreate && ( )}
{data.map((reward) => ( ))}
Jumlah Transaksi Level poin
{formatIDR( reward.amount_buy )} {reward.level.name} {formatIDR( reward.bonus_poin )} {canUpdate && ( toggleFormModal( reward ) } >
Ubah
)} {canDelete && ( handleDeleteClick( reward ) } >
Hapus
)}
) }