import AuthenticatedLayout from "@/layouts/authenticated-layout";
import { Head, usePage, router } from "@inertiajs/react";
import React, { useState } from "react";
import hasAnyPermission from "@/utils/hasAnyPermission";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import Pagination from "@/components/pagination";
export default function RolesIndex() {
const { roles } = usePage().props;
const [dialogOpen, setDialogOpen] = useState(false);
const [roleToDelete, setRoleToDelete] = useState(null);
const handleDelete = (id) => {
setRoleToDelete(id);
setDialogOpen(true);
};
const confirmDelete = () => {
router.delete(`/admin/roles/${roleToDelete}`, {
onSuccess: () => {
setDialogOpen(false);
setRoleToDelete(null);
},
});
};
return (
No. | Role Name | Permissions | Actions |
---|---|---|---|
{index + 1 + (roles.current_page - 1) * roles.per_page} | {role.name} |
{role.permissions.map(
(permission, i) => (
{
permission.name
}
)
)}
|
{/* {hasAnyPermission([ "roles.edit", ]) && ( */} {" "} Edit {/* )} */} {/* {hasAnyPermission([ "roles.delete", ]) && ( */} {/* )} */} |