芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/reginaeigbe.com/folder/admin/tmp/resources/js/Admin/Pages/CaseStudy/Index.jsx
import AdminLayouts from "@/Admin/Layouts/AdminLayouts"; import { Head, Link } from "@inertiajs/react"; import { imageOutline, 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({ case_studies, 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.case.study.index", { search: search ?? setSearchQuery, sort: sort, filter: { category: selectedCategory }, }), {}, { preserveState: true } ); }; // mark all const markAll = () => { if (isMarkAll) { setMarkItems([]); setIsMarkAll(false); } else { const items = case_studies.data.map((case_study) => case_study.id); setMarkItems(items); setIsMarkAll(true); } }; // handle mark unmark const handleMark = (case_studyId) => { const existsMark = markItems.some((item) => item === case_studyId); if (existsMark) { const removeItem = markItems.filter( (item) => item !== case_studyId ); setMarkItems(removeItem); } else { const addedItem = [...markItems, case_studyId]; setMarkItems(addedItem); } }; // handle bulk action const handleBulkAction = () => { setIsMarkAll([]); showAlert( "Are you sure?", "You want to delete selected case_studies?", "Delete!", () => { router.delete( route("admin.case.study.bulk.delete", { ids: markItems.join(","), }) ); } ); }; return ( <>
All case study
case study
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( "case_study.create" ) && (
+
{" "} Create New )}
markAll() } style={{ width: "1%" }} >
getResults( searchQuery ) } column="title" > Title
getResults( searchQuery ) } column="category" > Categories
getResults( searchQuery ) } column="created_at" > Date
Action
{case_studies.data.map( (case_study, index) => (
handleMark( case_study.id ) } >
item === case_study.id ) && "active" }`} />
{ case_study.title }
{ case_study .category .title }
{moment( case_study.created_at ).format("ll")}
{hasPermission( "case_study.edit" ) && (
)} {hasPermission( "case_study.show" ) && (
)} {hasPermission( "case_study.delete" ) && (
)}
) )}
{!case_studies.data.length && (
No case study found!
)}
{/* .yoo-card */} {case_studies.total > 1 && (
{case_studies.links.map((link, index) => (
))}
)}
> ); }