diff --git a/admin-portal-frontend/src/app/all-page/page.tsx b/admin-portal-frontend/src/app/all-page/page.tsx
deleted file mode 100644
index f7c1d2c..0000000
--- a/admin-portal-frontend/src/app/all-page/page.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-"use client";
-
-import { useEffect, useState } from "react";
-import Filter from "../icons/filter.svg";
-import { Category, getAllCategories } from "../components/categoryRoutes";
-import PageContainer from "../components/PageContainer";
-
-export default function CategoriesPage() {
- const [categories, setCategories] = useState([]);
- const [publishedState, setPublishedState] = useState(true);
-
- useEffect(() => {
- const fetchData = async () => {
- const fetchedCategories = (await getAllCategories()) as Category[];
- console.log(fetchedCategories);
-
- setCategories(fetchedCategories as never);
- };
-
- fetchData();
- }, []);
-
- const selectedStyle = "text-[#00629B] border-[#00629B] border-solid";
- const unselectedStyle = "text-[#6C6C6C]";
-
- return (
-
-
-
Global Search
-
-
-
-
-
-
-
-
-
-
-
-
All Pages
-
-
-
-
-
-
-
-
- );
-}
diff --git a/admin-portal-frontend/src/app/components/CategoryContainer.tsx b/admin-portal-frontend/src/app/components/CategoryContainer.tsx
deleted file mode 100644
index b3e0cd4..0000000
--- a/admin-portal-frontend/src/app/components/CategoryContainer.tsx
+++ /dev/null
@@ -1,120 +0,0 @@
-"use client";
-
-import React, { useState } from "react";
-import { Category } from "./categoryRoutes";
-import DeleteConfirmationPopup from "./DeletePopup";
-import TrashIcon from "../icons/trash.svg";
-import EditIcon from "../icons/edit.svg";
-
-type CategoryItemProps = {
- id: string;
- title: string;
- visibility?: boolean;
- pages: number;
- onDeleteCategory: (categoryId: string) => void;
-};
-
-const CategoryItem: React.FC = ({ id, title, pages, onDeleteCategory }) => {
- const [selectedValue, setSelectedValue] = useState("public");
- const [allowEdits, setAllowEdits] = useState(false);
- const [popupVisible, setPopupVisible] = useState(false);
-
- const handleDelete = () => {
- setPopupVisible(true);
- };
-
- const handleConfirmDelete = async () => {
- try {
- onDeleteCategory(id);
- setPopupVisible(false);
- } catch (error) {
- console.error("Error deleting category:", error);
- }
- };
-
- const handleCancelDelete = () => {
- setPopupVisible(false);
- };
-
- return (
-
- {title} |
-
- {/* Added just to check styling */}
-
- |
- {pages} |
-
-
-
- |
- {popupVisible ? (
-
- ) : null}
-
- );
-};
-
-export const CategoryContainer: React.FC<{
- items: Category[];
- type: string;
- onDeleteCategory: (categoryId: string) => void;
-}> = ({ items: categories, type, onDeleteCategory }) => {
- return (
-
- {/* table heading */}
-
-
- Category Name |
- Visibility |
- Pages |
- Actions |
-
-
- {categories
- // gets only either emergency or general principle
- .filter((category) => category.type === type)
- .map((category: Category) => {
- return (
-
- );
- })}
-
-
- );
-};
-
-export default CategoryContainer;
diff --git a/admin-portal-frontend/src/app/components/DeletePopup.tsx b/admin-portal-frontend/src/app/components/DeletePopup.tsx
deleted file mode 100644
index d40253e..0000000
--- a/admin-portal-frontend/src/app/components/DeletePopup.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import React from "react";
-
-import CloseIcon from "../icons/close.svg";
-
-type DeleteConfirmationPopupProps = {
- onDelete: () => void;
- onCancel: () => void;
-};
-
-const DeleteConfirmationPopup: React.FC = ({
- onDelete,
- onCancel,
-}) => {
- return (
-
-
-
-
-
- Are you sure you want to delete
-
- this category?
-
-
- This category cannot be restored and will not be saved.
-
-
-
-
-
-
-
-
- );
-};
-
-export default DeleteConfirmationPopup;
diff --git a/admin-portal-frontend/src/app/components/PageContainer.tsx b/admin-portal-frontend/src/app/components/PageContainer.tsx
deleted file mode 100644
index ace7b14..0000000
--- a/admin-portal-frontend/src/app/components/PageContainer.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-"use client";
-
-import React, { useState } from "react";
-import { Category } from "./categoryRoutes";
-import TrashIcon from "../icons/trash.svg";
-import EditIcon from "../icons/edit.svg";
-
-type PageItemProps = {
- id: string;
- title: string;
- page: string;
- visibility?: boolean;
-};
-
-const PageItem: React.FC = ({ id, page, title }) => {
- const [selectedValue, setSelectedValue] = useState("public");
- const [allowEdits, setAllowEdits] = useState(false);
-
- return (
-
- {page} |
-
-
- |
- {title} |
-
-
-
- |
-
- );
-};
-
-export const PageContainer: React.FC<{ items: Category[] }> = ({ items: categories }) => {
- return (
-
-
-
- Page Name |
- Visibility |
- Category |
- Actions |
-
-
- {
- // go through each category's items
- categories.map((category: Category) => {
- return category.items.map((page, j) => (
-
- ));
- })
- }
-
-
- );
-};
-
-export default PageContainer;
diff --git a/admin-portal-frontend/src/app/components/Toast.tsx b/admin-portal-frontend/src/app/components/Toast.tsx
deleted file mode 100644
index 52ec720..0000000
--- a/admin-portal-frontend/src/app/components/Toast.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import React from "react";
-
-import { useEffect, useState } from "react";
-import CloseIcon from "../icons/close.svg";
-import CheckIcon from "../icons/check.svg";
-
-type ToastProps = {
- backgroundColor: string;
- message: string;
- onClose: () => void;
-};
-
-const Toast: React.FC = ({ backgroundColor, message, onClose }) => {
- useEffect(() => {
- // Set a timer to hide the toast after 10 seconds
- const timer = setTimeout(() => {
- onClose();
- }, 10000);
-
- return () => {
- clearTimeout(timer);
- };
- }, []);
-
- return (
-
-
-
-
{message}
-
-
-
- );
-};
-
-export default Toast;
diff --git a/admin-portal-frontend/src/app/components/categoryRoutes.tsx b/admin-portal-frontend/src/app/components/categoryRoutes.tsx
deleted file mode 100644
index 1dcfba1..0000000
--- a/admin-portal-frontend/src/app/components/categoryRoutes.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-export type Category = {
- _id: string;
- title: string;
- items: [];
- type: string;
-};
-
-// Gets and returns all categories from API
-export const getAllCategories = async () => {
- try {
- const url = process.env.API_URL;
-
- if (!url) {
- throw new Error("API URL is not defined");
- }
-
- const response = await fetch(url);
- const data = (await response.json()).categories as Category;
-
- // console.log(data);
- return data;
- } catch (error) {
- console.log("Error getting categories", error);
- return [];
- }
-};
-
-// Deletes a specific category
-export const deleteCategory = async (itemId: string) => {
- try {
- if (!process.env.API_URL) {
- throw new Error("API URL is not defined");
- }
-
- const url = process.env.API_URL + `/${itemId}`;
-
- if (!url) {
- throw new Error("API URL is not defined");
- }
-
- fetch(url, {
- method: "DELETE",
- });
- } catch (error) {
- console.log("Error delete category", error);
- }
-};
diff --git a/admin-portal-frontend/src/app/emergencies/page.tsx b/admin-portal-frontend/src/app/emergencies/page.tsx
deleted file mode 100644
index efbcdf5..0000000
--- a/admin-portal-frontend/src/app/emergencies/page.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-"use client";
-
-import { useEffect, useState } from "react";
-import CategoryContainer from "../components/CategoryContainer";
-import { Category, getAllCategories, deleteCategory } from "../components/categoryRoutes";
-import Toast from "../components/Toast";
-
-export default function CategoriesPage() {
- const [categories, setCategories] = useState([]);
- const [showToast, setShowToast] = useState(false);
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- const fetchedCategories = (await getAllCategories()) as Category[];
- setCategories(fetchedCategories as never);
- } catch (error) {
- console.log("Fetch categories failed.");
- }
- };
-
- fetchData();
- }, [categories]);
-
- const onDeleteCategory = async (categoryId: string) => {
- try {
- console.log("Deleting category with ID:", categoryId);
- await deleteCategory(categoryId);
- setShowToast(true);
- } catch (error) {
- console.error("Error deleting category:", error);
- }
- };
-
- const handleCloseToast = () => {
- setShowToast(false);
- };
-
- return (
-
-
-
Global Search
-
-
-
-
-
-
-
All Categories
-
-
-
-
-
-
- {showToast && (
-
- )}
-
-
- );
-}
diff --git a/admin-portal-frontend/src/app/general-principles/page.tsx b/admin-portal-frontend/src/app/general-principles/page.tsx
deleted file mode 100644
index ea316e4..0000000
--- a/admin-portal-frontend/src/app/general-principles/page.tsx
+++ /dev/null
@@ -1,80 +0,0 @@
-"use client";
-
-import { useEffect, useState } from "react";
-import CategoryContainer from "../components/CategoryContainer";
-import { Category, getAllCategories, deleteCategory } from "../components/categoryRoutes";
-import Toast from "../components/Toast";
-
-export default function CategoriesPage() {
- const [categories, setCategories] = useState([]);
- const [showToast, setShowToast] = useState(false);
-
- useEffect(() => {
- const fetchData = async () => {
- try {
- const fetchedCategories = (await getAllCategories()) as Category[];
- setCategories(fetchedCategories as never);
- } catch (error) {
- console.log("Fetch categories failed.");
- }
- };
-
- fetchData();
- }, [categories]);
-
- const onDeleteCategory = async (categoryId: string) => {
- try {
- console.log("Deleting category with ID:", categoryId);
- await deleteCategory(categoryId);
- setShowToast(true);
- } catch (error) {
- console.error("Error deleting category:", error);
- }
- };
-
- const handleCloseToast = () => {
- setShowToast(false);
- };
-
- return (
-
-
-
General Principles
-
-
-
-
-
-
-
All Categories
-
-
-
-
-
-
- {showToast && (
-
- )}
-
-
- );
-}