Skip to content

Commit

Permalink
Modify delete popup to accept type to adjust popup and toast text
Browse files Browse the repository at this point in the history
  • Loading branch information
LillianHo5 committed May 28, 2024
1 parent 584f9ab commit 60e38f3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
6 changes: 1 addition & 5 deletions admin-portal-frontend/src/app/all-page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,7 @@ export default function CategoriesPage() {
</div>
<PageContainer items={categories} onDeletePage={onDeletePage}></PageContainer>
{showToast && (
<Toast
backgroundColor={"#000000"}
message={"Category deleted"}
onClose={handleCloseToast}
/>
<Toast backgroundColor={"#000000"} message={"Page deleted"} onClose={handleCloseToast} />
)}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ const CategoryItem: React.FC<CategoryItemProps> = ({ id, title, pages, onDeleteC
</button>
</td>
{popupVisible ? (
<DeleteConfirmationPopup onDelete={handleConfirmDelete} onCancel={handleCancelDelete} />
<DeleteConfirmationPopup
onDelete={handleConfirmDelete}
onCancel={handleCancelDelete}
type={"category"}
/>
) : null}
</tr>
);
Expand Down
12 changes: 7 additions & 5 deletions admin-portal-frontend/src/app/components/DeletePopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ import React from "react";
import CloseIcon from "../icons/close.svg";

type IconProps = {
'content-type': string,
src: string
}
"content-type": string;
src: string;
};

type DeleteConfirmationPopupProps = {
onDelete: () => void;
onCancel: () => void;
type: String;
};

const DeleteConfirmationPopup: React.FC<DeleteConfirmationPopupProps> = ({
onDelete,
onCancel,
type,
}) => {
return (
<div className="fixed top-0 left-0 w-full h-full flex items-center justify-center bg-gray-800 bg-opacity-50 z-50">
Expand All @@ -26,10 +28,10 @@ const DeleteConfirmationPopup: React.FC<DeleteConfirmationPopupProps> = ({
<h1 className="text-xl sm:text-2xl text-[#182B49] font-bold">
Are you sure you want to delete
<br />
this category?
this {type}?
</h1>
<p className="my-4 text-[#182B49]">
This category cannot be restored and will not be saved.
This {type} cannot be restored and will not be saved.
</p>
<div className="flex justify-evenly mt-4 sm:mt-6">
<button
Expand Down
6 changes: 5 additions & 1 deletion admin-portal-frontend/src/app/components/PageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ const PageItem: React.FC<PageItemProps> = ({ id, page, categoryId, title, onDele
/>
</button>
{popupVisible ? (
<DeleteConfirmationPopup onDelete={handleConfirmDelete} onCancel={handleCancelDelete} />
<DeleteConfirmationPopup
onDelete={handleConfirmDelete}
onCancel={handleCancelDelete}
type={"page"}
/>
) : null}
</td>
</tr>
Expand Down

0 comments on commit 60e38f3

Please sign in to comment.