forked from github/plane
4a81b988b4
* chore: add page types and page api service * chore: add create, list, update and delete on pages * chore: add create, delete and patch page blocks * feat: add and remove pages to favorite * fix: made neccessary changes - used tailwind for hover events - add error toast alert - used partial for patch request * fix: replace absolute positiong with a flex box * fix: design list page view to match with ui * feat: add top large textarea for page title and description * refactor: add page label with types * feat: add pages grid layout * feat: add tabs and masonry layout * fix: build errors --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { useState } from "react";
|
|
// components
|
|
import { DeletePageModal } from "components/pages";
|
|
import { Loader } from "components/ui";
|
|
import { SinglePageGridItem } from "components/pages/page-grid-item";
|
|
// types
|
|
import { IPage } from "types";
|
|
|
|
export const PagesGrid: React.FC<any> = ({ pages, setCreateUpdatePageModal, setSelectedPage }) => {
|
|
const [pageDeleteModal, setPageDeleteModal] = useState(false);
|
|
const [selectedPageForDelete, setSelectedPageForDelete] = useState<any>();
|
|
|
|
const handleDeletePage = (page: IPage) => {
|
|
setSelectedPageForDelete({ ...page, actionType: "delete" });
|
|
setPageDeleteModal(true);
|
|
};
|
|
|
|
const handleEditPage = (page: IPage) => {
|
|
setSelectedPage({ ...page, actionType: "edit" });
|
|
setCreateUpdatePageModal(true);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<DeletePageModal
|
|
isOpen={
|
|
pageDeleteModal &&
|
|
!!selectedPageForDelete &&
|
|
selectedPageForDelete.actionType === "delete"
|
|
}
|
|
setIsOpen={setPageDeleteModal}
|
|
data={selectedPageForDelete}
|
|
/>
|
|
{pages ? (
|
|
pages.length > 0 ? (
|
|
<div className="rounded-[10px] border border-gray-200 bg-white">
|
|
<ul role="list" className="divide-y divide-gray-200">
|
|
{pages.map((page: any) => (
|
|
<SinglePageGridItem
|
|
page={page}
|
|
key={page.id}
|
|
handleDeletePage={() => handleDeletePage(page)}
|
|
handleEditPage={() => handleEditPage(page)}
|
|
/>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
) : (
|
|
"No Pages found"
|
|
)
|
|
) : (
|
|
<Loader className="grid grid-cols-1 gap-9 md:grid-cols-2 lg:grid-cols-3">
|
|
<Loader.Item height="200px" />
|
|
</Loader>
|
|
)}
|
|
</>
|
|
);
|
|
};
|