import { useState } from "react"; // components import { DeletePageModal } from "components/pages"; import { Loader } from "components/ui"; // types import { IPage } from "types"; import { SinglePageListItem } from "./single-page-list-item"; type TPagesListProps = { pages: IPage[] | undefined; setCreateUpdatePageModal: React.Dispatch>; setSelectedPage: React.Dispatch>; }; export const PagesList: React.FC = ({ pages, setCreateUpdatePageModal, setSelectedPage, }) => { const [pageDeleteModal, setPageDeleteModal] = useState(false); const [selectedPageForDelete, setSelectedPageForDelete] = useState(); const handleDeletePage = (page: IPage) => { setSelectedPageForDelete({ ...page, actionType: "delete" }); setPageDeleteModal(true); }; const handleEditPage = (page: IPage) => { setSelectedPage({ ...page, actionType: "edit" }); setCreateUpdatePageModal(true); }; return ( <> {pages ? ( pages.length > 0 ? (
    {pages.map((page) => ( handleDeletePage(page)} handleEditPage={() => handleEditPage(page)} /> ))}
) : ( "No Pages found" ) ) : ( )} ); };