芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/reginaeigbe.com/folder/admin/tmp/resources/js/Admin/Pages/Portfolios/Index.jsx
import AdminLayouts from "@/Admin/Layouts/AdminLayouts"; import { Head, Link } from "@inertiajs/react"; import { idCardOutline, newspaperOutline, 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({ portfolios, sort, categories, filter }) { const [searchQuery, setSearchQuery] = useState(""); const [selectedOption, setSelectedOption] = useState("Bulk Action"); const [isMarkAll, setIsMarkAll] = useState(false); const [markItems, setMarkItems] = useState([]); const [selectedStatus, setSelectedStatus] = useState(filter.status); const [selectedCategory, setSelectedCategory] = useState(filter.category); // handle search sort const getResults = (search) => { router.get( route("admin.portfolios.index", { search: search ?? setSearchQuery, sort: sort, filter: { category: selectedCategory }, }), {}, { preserveState: true } ); }; // mark all const markAll = () => { if (isMarkAll) { setMarkItems([]); setIsMarkAll(false); } else { const items = portfolios.data.map((portfolio) => portfolio.id); setMarkItems(items); setIsMarkAll(true); } }; // handle mark unmark const handleMark = (portfolioId) => { const existsMark = markItems.some((item) => item === portfolioId); if (existsMark) { const removeItem = markItems.filter((item) => item !== portfolioId); setMarkItems(removeItem); } else { const addedItem = [...markItems, portfolioId]; setMarkItems(addedItem); } }; // handle bulk action const handleBulkAction = () => { setIsMarkAll([]); showAlert( "Are you sure?", "You want to delete selected portfolios?", "Delete!", () => { router.delete( route("admin.portfolios.bulk.delete", { ids: markItems.join(","), }) ); } ); }; return ( <>
All portfolios
portfolios
setSelectedOption( "Delete" ) } className={`dropdown-item ${ selectedOption === "Delete" ? "active" : "" }`} href="#" > Delete
handleBulkAction() } className="btn btn-success btn-sm" > Apply
setSelectedCategory( "All Categories" ) } className={`dropdown-item ${ selectedCategory === "All Categories" ? "active" : "" }`} href="#" > All Category
{categories.map( (category) => (
setSelectedCategory( category.title ) } className={`dropdown-item ${ selectedCategory === category.title ? "active" : "" }`} href="#" > { category.title }
) )}
getResults(searchQuery) } className="btn btn-success btn-sm" > Filter
{ setSearchQuery( e.target.value ); getResults( e.target.value ); }} />
{hasPermission( "portfolios.create" ) && (
+
{" "} Create New )}
markAll() } style={{ width: "1%" }} >
getResults( searchQuery ) } column="title" > Title
getResults( searchQuery ) } column="sub_title" > Sub Title
getResults( searchQuery ) } column="category" > Categories
getResults( searchQuery ) } column="created_at" > Date
Action
{portfolios.data.map( (portfolio, index) => (
handleMark( portfolio.id ) } >
item === portfolio.id ) && "active" }`} />
{ portfolio.title }
{ portfolio.sub_title }
{ portfolio .category .title }
{moment( portfolio.created_at ).format("ll")}
{hasPermission( "portfolios.edit" ) && (
)} {hasPermission( "portfolios.show" ) && (
)} {hasPermission( "portfolios.delete" ) && (
)}
) )}
{!portfolios.data.length && (
No portfolios found!
)}
{/* .yoo-card */} {portfolios.total > 1 && (
{portfolios.links.map((link, index) => (
))}
)}
> ); }