diff --git a/client/src/Services/rightServices.js b/client/src/Services/rightServices.js new file mode 100644 index 0000000..2593405 --- /dev/null +++ b/client/src/Services/rightServices.js @@ -0,0 +1,37 @@ +import thaliaAPI from "../API/thaliaAPI"; + +export const createRight = async (rightDetails) => { + try { + const response = await thaliaAPI.post("/admin/rights", rightDetails, { withCredentials: true }); + return response.data; + } catch (error) { + return error; + } +} +export const updateRight = async (rightDetails, rightId) => { + try { + const response = await thaliaAPI.put(`/admin/rights/${rightId}`, rightDetails, { withCredentials: true }); + return response.data; + } catch (error) { + return error; + } +} +export const getRight = async () => { + try { + const response = await thaliaAPI.get('/admin/rights', {}, { withCredentials: true }); + return response.data; + } catch (error) { + return error; + } +} +export const getDelete = async (rightId) => { + try { + const response = await thaliaAPI.delete(`/admin/rights/${rightId}`, {}, { withCredentials: true }); + return response.data; + } catch (error) { + return error; + } +} + + + diff --git a/client/src/components/AddBody/AddBody.jsx b/client/src/components/AddBody/AddBody.jsx new file mode 100644 index 0000000..2a382e9 --- /dev/null +++ b/client/src/components/AddBody/AddBody.jsx @@ -0,0 +1,56 @@ +import { useState } from "react"; +import { Modal } from "flowbite-react"; + +function AddBody({ openModal, setOpenModal }) { + const [formData, setFormData] = useState({ + body_name: "", + body_desc: "", + }); + const handleChange = (e) => { + const { name, value } = e.target; + setFormData({ + ...formData, + [name]: value, + }); + }; + return ( + <> + setOpenModal(false)}> + +

Add New Topic

+
+ +
+ +
+
+ +
+ +
+
+ + ); +} +export default AddBody; diff --git a/client/src/components/AddRight/AddRight.jsx b/client/src/components/AddRight/AddRight.jsx index 2b15f95..e9e8d38 100644 --- a/client/src/components/AddRight/AddRight.jsx +++ b/client/src/components/AddRight/AddRight.jsx @@ -1,5 +1,6 @@ import { useState } from "react"; import { Modal } from "flowbite-react"; +import { createRight } from "../../Services/rightServices"; // eslint-disable-next-line react/prop-types function AddRight({ setOpenModal, openModal }) { @@ -14,6 +15,20 @@ function AddRight({ setOpenModal, openModal }) { [name]: value, }); }; + + const handleCreate = async () => { + if (!formData.right_name || !formData.right_desc) { + console.log("Data fields Missing"); + return; + } + try { + const response = await createRight(formData); + console.log("response in the page", response); + } catch (error) { + console.log("Error occurred", error); + } + }; + return ( <> setOpenModal(false)}> @@ -59,7 +74,10 @@ function AddRight({ setOpenModal, openModal }) { /> */} - diff --git a/client/src/components/CheckReport/CheckReport.jsx b/client/src/components/CheckReport/CheckReport.jsx index 0a54e96..215891d 100644 --- a/client/src/components/CheckReport/CheckReport.jsx +++ b/client/src/components/CheckReport/CheckReport.jsx @@ -1,7 +1,12 @@ import { Modal } from "flowbite-react"; +import { useState } from "react"; // eslint-disable-next-line react/prop-types function CheckReport({ openModal, setOpenModal, reportObject }) { + const [show, setShow] = useState(false); + const handleView = () => { + setShow((state) => !state); + }; return ( <> -

Reports

+

User Reports

- -
- -
-
- +
+

+ +

+
+
+

+ Flowbite is an open-source library of interactive components + built on top of Tailwind CSS including buttons, dropdowns, + modals, navbars, and more. +

+
+
+
- - - -
diff --git a/client/src/components/EditBody/EditBody.jsx b/client/src/components/EditBody/EditBody.jsx new file mode 100644 index 0000000..37a2115 --- /dev/null +++ b/client/src/components/EditBody/EditBody.jsx @@ -0,0 +1,63 @@ +import { useState, useEffect } from "react"; +import { Modal } from "flowbite-react"; + +function EditBody({ bodyDetails, openModal, setOpenModal }) { + const [formData, setFormData] = useState({ + body_name: "", + body_desc: "", + }); + useEffect(() => { + if (bodyDetails) { + // eslint-disable-next-line react/prop-types + formData.body_name = bodyDetails?.name; + // eslint-disable-next-line react/prop-types + formData.body_desc = bodyDetails?.description; + } + }, [formData, bodyDetails]); + const handleChange = (e) => { + const { name, value } = e.target; + setFormData({ + ...formData, + [name]: value, + }); + }; + return ( + <> + setOpenModal(false)}> + +

Edit Topic

+
+ +
+ +
+
+ +
+ +
+
+ + ); +} +export default EditBody; diff --git a/client/src/components/Sidebar/Sidebar.jsx b/client/src/components/Sidebar/Sidebar.jsx index ac034d7..52652c7 100644 --- a/client/src/components/Sidebar/Sidebar.jsx +++ b/client/src/components/Sidebar/Sidebar.jsx @@ -2,6 +2,7 @@ import { Link } from "react-router-dom"; import { MdDashboard } from "react-icons/md"; import { FaUsers } from "react-icons/fa"; import { TbFileReport } from "react-icons/tb"; +import { IoBody } from "react-icons/io5"; function Sidebar() { return ( <> @@ -28,6 +29,12 @@ function Sidebar() { Rights Management + diff --git a/client/src/pages/AdminPages/Login/Login.jsx b/client/src/pages/AdminPages/Login/Login.jsx deleted file mode 100644 index 7f30ce4..0000000 --- a/client/src/pages/AdminPages/Login/Login.jsx +++ /dev/null @@ -1,38 +0,0 @@ -function Login() { - return ( - <> -
-
-
-
-
-

- Login -

-
-
- -
- -
-
-
- -
-
-
-
-
- - ); -} - -export default Login; diff --git a/client/src/pages/AdminPages/MyBody/MyBody.jsx b/client/src/pages/AdminPages/MyBody/MyBody.jsx new file mode 100644 index 0000000..02a0d85 --- /dev/null +++ b/client/src/pages/AdminPages/MyBody/MyBody.jsx @@ -0,0 +1,86 @@ +import { useState } from "react"; +import EditRight from "../../../components/EditRight/EditRight"; +import AddBody from "../../../components/AddBody/AddBody"; + +function MyBody() { + const [openModal, setOpenModal] = useState(false); + // eslint-disable-next-line no-unused-vars + const [rightDetails, setRightDetails] = useState(); + const handleModal = () => { + setOpenModal(true); + }; + return ( + <> + + +
+
+ {/* Text Components */} +
+
+

Body Topics

+
+
+ +
+
+ {/* Table Component */} +
+ + + + + + + + + + + + + + + + + +
+ No + + Name + + Created At + + Edit or Delete +
+ 1 + Dealing with Period Cramps18-03-2003 + + +
+
+
+
+ + ); +} + +export default MyBody; diff --git a/client/src/pages/AdminPages/Rights/Rights.tsx b/client/src/pages/AdminPages/Rights/Rights.tsx index 37dadaf..78f812f 100644 --- a/client/src/pages/AdminPages/Rights/Rights.tsx +++ b/client/src/pages/AdminPages/Rights/Rights.tsx @@ -1,6 +1,8 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import AddRight from "../../../components/AddRight/AddRight"; import EditRight from "../../../components/EditRight/EditRight"; +import { getRight } from "../../../Services/rightServices"; +import { getDelete } from "../../../Services/rightServices"; function Rights() { const [openModal, setOpenModal] = useState(false); @@ -8,6 +10,15 @@ function Rights() { const handleModal = () => { setOpenModal(true); }; + useEffect(() => { + const getRights = async () => { + const response = await getRight(); + console.log("This is the response", response); + }; + }, []); + const handleDelete = async (rightId: string) => { + const response = await getDelete(rightId); + }; return ( <> Edit - diff --git a/client/src/routes/AdminRoute.jsx b/client/src/routes/AdminRoute.jsx index 19afd58..0be1189 100644 --- a/client/src/routes/AdminRoute.jsx +++ b/client/src/routes/AdminRoute.jsx @@ -3,19 +3,14 @@ import { Route, Routes } from "react-router"; import Loader from "../components/Loader/Loader1/Loader"; const Home = lazy(() => import("../pages/AdminPages/Home/Home")); -const Login = lazy(() => import("../pages/AdminPages/Login/Login")); const Managment = lazy(() => import("../pages/AdminPages/Managment/Managment")); const Rights = lazy(() => import("../pages/AdminPages/Rights/Rights")); const Sidebar = lazy(() => import("../components/Sidebar/Sidebar")); +const MyBody = lazy(() => import("../pages/AdminPages/MyBody/MyBody")); export default function AdminRoute() { return ( <> - }> - - } /> - -
@@ -26,6 +21,7 @@ export default function AdminRoute() { } /> } /> } /> + } />