import React, { useEffect, useState } from 'react' import { Link, router } from '@inertiajs/react' import { usePrevious } from 'react-use' 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 { hasPermission } from '@/utils' export default function Info(props) { const { query: { links, data }, auth, } = props const confirmModal = useModalState() const handleDeleteClick = (banner) => { confirmModal.setData(banner) confirmModal.toggle() } const onDelete = () => { if (confirmModal.data !== null) { router.delete(route('banner.destroy', confirmModal.data.id)) } } const canCreate = hasPermission(auth, 'create-banner') const canUpdate = hasPermission(auth, 'update-banner') const canDelete = hasPermission(auth, 'delete-banner') return (
{canCreate && ( )}
{data.map((banner) => ( ))}
Judul
{banner.title} {canUpdate && (
Ubah
)} {canDelete && ( handleDeleteClick( banner ) } >
Hapus
)}
) }