diff --git a/django_project/frontend/package.json b/django_project/frontend/package.json index 92b2b991..4bd644a0 100644 --- a/django_project/frontend/package.json +++ b/django_project/frontend/package.json @@ -20,6 +20,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-helmet": "^6.1.0", + "react-icons": "^5.3.0", "react-pro-sidebar": "^1.1.0", "react-redux": "^8.0.5", "react-refresh": "^0.14.2", diff --git a/django_project/frontend/src/Routes.tsx b/django_project/frontend/src/Routes.tsx index 243f1206..ca4ea64e 100644 --- a/django_project/frontend/src/Routes.tsx +++ b/django_project/frontend/src/Routes.tsx @@ -1,15 +1,15 @@ import React from "react"; import { useRoutes } from "react-router-dom"; -import Home from "./pages/Home"; import NotFound from "./pages/NotFound"; import HomePage from "./pages/Home/index"; +import OrganisationInformation from "./pages/OrganisationInformation"; import ProfileInformationPage from "./pages/Profile"; const ProjectRoutes = () => { const element = useRoutes([ - { path: "", element: }, - { path: "/routes", element: }, - { path: "/home", element: }, + { path: "*", element: }, + { path: "/", element: }, + { path: "/organisation", element: }, { path: "/profile", element: } ]); diff --git a/django_project/frontend/src/components/SideBar/index.tsx b/django_project/frontend/src/components/SideBar/index.tsx index 93ea853a..d73174a7 100644 --- a/django_project/frontend/src/components/SideBar/index.tsx +++ b/django_project/frontend/src/components/SideBar/index.tsx @@ -11,15 +11,16 @@ import { import React from "react"; import { MenuItem, Menu } from "react-pro-sidebar"; import { HamburgerIcon } from "@chakra-ui/icons"; -import { useLocation } from "react-router-dom"; +import { useLocation, useNavigate } from "react-router-dom"; interface Props extends ChakraProps { className?: string; } -export default function Sidebar1(props: Props) { +export default function Sidebar(props: Props) { const { isOpen, onOpen, onClose } = useDisclosure(); const location = useLocation(); + const navigate = useNavigate(); const isActive = (path: string) => location.pathname === path; return ( @@ -32,7 +33,7 @@ export default function Sidebar1(props: Props) { flexDirection="column" display={{ md: "flex", base: "none" }} bg="dark_green.800" - h="100vh" + h={{base:"auto" ,md:"100vh"}} top="0px" overflow="auto" sx={{ position: "sticky !important" }} @@ -56,16 +57,24 @@ export default function Sidebar1(props: Props) { w="100%" justifyContent="space-between" > - + navigate('/profile')} + > Profile - Organisation Information - My Dashboard - Analysis Results - Uploaded Resources - Support - Notifications - Sign Out + navigate('/organisation')} + > + Organisation Information + + navigate('/dashboard')}>My Dashboard + navigate('/analysis-results')}>Analysis Results + navigate('/uploaded-resources')}>Uploaded Resources + navigate('/support')}>Support + navigate('/notifications')}>Notifications + navigate('/sign-out')}>Sign Out @@ -125,17 +134,28 @@ export default function Sidebar1(props: Props) { > { + navigate('/profile'); + onClose(); + }} > Profile - Organisation Information - My Dashboard - Analysis Results - Uploaded Resources - Support - Notifications - Sign Out + { + navigate('/organisation'); + onClose(); + }} + > + Organisation Information + + { navigate('/dashboard'); onClose(); }}>My Dashboard + { navigate('/analysis-results'); onClose(); }}>Analysis Results + { navigate('/uploaded-resources'); onClose(); }}>Uploaded Resources + { navigate('/support'); onClose(); }}>Support + { navigate('/notifications'); onClose(); }}>Notifications + { navigate('/sign-out'); onClose(); }}>Sign Out @@ -143,4 +163,4 @@ export default function Sidebar1(props: Props) { ); -} +} \ No newline at end of file diff --git a/django_project/frontend/src/pages/Home.tsx b/django_project/frontend/src/pages/Home.tsx deleted file mode 100644 index cf39f45c..00000000 --- a/django_project/frontend/src/pages/Home.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { Link } from "react-router-dom"; -import React from "react"; - -export default function Home() { - return ( -
-

Homepage

-

- Quickly use the links below to navigate through all pages -

-
    -
  • - - HomePage - -
  • -
  • - - Another Page - -
  • -
-

src/pages/Home.tsx

-

This project was generated by Dhiwise

-
- ); -} diff --git a/django_project/frontend/src/pages/OrganisationInformation/index.tsx b/django_project/frontend/src/pages/OrganisationInformation/index.tsx new file mode 100644 index 00000000..d821db27 --- /dev/null +++ b/django_project/frontend/src/pages/OrganisationInformation/index.tsx @@ -0,0 +1,265 @@ +import React, { useState, useEffect } from "react"; +import Helmet from "react-helmet"; +import { + Box, + Heading, + Flex, + Input, + Table, + Tbody, + Tr, + Td, + Thead, + Button, + Badge, + IconButton, + Tabs, + TabList, + Tab, + TabPanels, + TabPanel, + Divider, +} from "@chakra-ui/react"; +import { FaPlus, FaTrash } from "react-icons/fa"; +import Header from "../../components/Header"; +import Sidebar from "../../components/SideBar"; +import "../../styles/index.css"; + +// Define types for the data +interface Member { + user: string; + role: string; +} + +interface Invitation { + user: string; + role: string; + status: string; +} + +interface Organization { + members: Member[]; + invitations: Invitation[]; +} + +export default function OrganisationInformation() { + const [searchTerm, setSearchTerm] = useState(""); + const [organizations, setOrganizations] = useState<{ [key: string]: Organization }>({}); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + const fetchOrganizations = async () => { + try { + setLoading(true); + setError(null); + + const response = await fetch("/api/organizations"); // Example API endpoint will replace with real one TODO + if (!response.ok) { + throw new Error("Failed to fetch organizations."); + } + + const data = await response.json(); + setOrganizations(data); + } catch (err: any) { + setError("No data available."); + setOrganizations({ + default: { + members: [], + invitations: [], + } + }) + } finally { + setLoading(false); + } + }; + + fetchOrganizations(); + }, []); + + return ( + <> + + Organisation Information - Manage Organisation Details + + +
+ + + + {/* Sidebar */} + + + {/* Main Content */} + + + My Organisations + + + {loading &&

Loading...

} + {error &&

{error}

} + + {/* Organisation Tabs */} + + + + {Object.keys(organizations).map((orgKey, idx) => ( + + {orgKey} + + ))} + + + + + + + {Object.values(organizations).map((organization, index) => ( + + {/* Organisation Members Section */} + + Organisation Members + + + + setSearchTerm(e.target.value)} + borderColor="gray.400" + mr={2} + w={{ base: "full", md: 80 }} + /> + + + + + + + + + + + + + + + + + + {organization.members.slice(0, 5).map((member, idx) => ( + + + + + + ))} + +
UserRoleActions
{member.user}{member.role} + } + colorScheme="red" + variant="ghost" + /> +
+
+ + {organization.members.length > 4 && ( + + + + )} + + + Invitations + + + + + + + + + + + + + + + {organization.invitations.slice(0, 5).map((invite, idx) => ( + + + + + + ))} + +
UserRoleStatus
{invite.user}{invite.role} + + {invite.status} + +
+
+ + {organization.invitations.length > 5 && ( + + + + )} +
+ ))} +
+
+
+
+
+ + ); +}