芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/reginaeigbe.com/folder/admin/tmp/resources/js/Admin/Pages/Teams/Index.jsx
import AdminLayouts from "@/Admin/Layouts/AdminLayouts"; import { Head, Link } from "@inertiajs/react"; import { newspaperOutline, peopleOutline, search } from "ionicons/icons"; import { IonIcon } from "@ionic/react"; import { trashOutline, createOutline, eyeOutline } from "ionicons/icons"; import moment from "moment"; import { useState } from "react"; import { router } from "@inertiajs/react"; import ThSortable from "@/Admin/Components/Table/ThSortable"; import DropDownButton from "@/Admin/Components/Button/DropDownButton"; import { showAlert } from "@/Admin/Utils/SweetAlert.js"; import DeleteButton from "@/Admin/Components/Button/DeleteButton"; import hasPermission from "@/Admin/Utils/hasPermission"; export default function Index({ teams, sort, categories }) { const [searchQuery, setSearchQuery] = useState(""); const [selectedOption, setSelectedOption] = useState("Bulk Action"); const [isMarkAll, setIsMarkAll] = useState(false); const [markItems, setMarkItems] = useState([]); // handle search sort const getResults = (search) => { router.get( route("admin.teams.index", { search: search ?? setSearchQuery, sort: sort, }), {}, { preserveState: true } ); }; // mark all const markAll = () => { if (isMarkAll) { setMarkItems([]); setIsMarkAll(false); } else { const items = teams.data.map((team) => team.id); setMarkItems(items); setIsMarkAll(true); } }; // handle mark unmark const handleMark = (teamId) => { const existsMark = markItems.some((item) => item === teamId); if (existsMark) { const removeItem = markItems.filter((item) => item !== teamId); setMarkItems(removeItem); } else { const addedItem = [...markItems, teamId]; setMarkItems(addedItem); } }; // handle bulk action const handleBulkAction = () => { setIsMarkAll([]); showAlert( "Are you sure?", "You want to delete selected teams?", "Delete!", () => { router.delete( route("admin.teams.bulk.delete", { ids: markItems.join(","), }) ); } ); }; return ( <>
All teams
teams
setSelectedOption( "Delete" ) } className={`dropdown-item ${ selectedOption === "Delete" ? "active" : "" }`} href="#" > Delete
handleBulkAction() } className="btn btn-success btn-sm" > Apply
{ setSearchQuery( e.target.value ); getResults( e.target.value ); }} />
{hasPermission("teams.create") && (
+
{" "} Create New )}
markAll() } style={{ width: "1%" }} >
getResults( searchQuery ) } column="image" > Image
getResults( searchQuery ) } column="name" > Name
getResults( searchQuery ) } column="designation" > Designation
getResults( searchQuery ) } column="created_at" > Date
Action
{teams.data.map( (team, index) => (
handleMark( team.id ) } >
item === team.id ) && "active" }`} />
{team.name}
{ team.designation }
{moment( team.created_at ).format("ll")}
{hasPermission( "teams.edit" ) && (
)} {/*
*/} {hasPermission( "teams.delete" ) && (
)}
) )}
{!teams.data.length && (
No teams found!
)}
{/* .yoo-card */} {teams.total > 1 && (
{teams.links.map((link, index) => (
))}
)}
> ); }