-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: define notifications page * feat: define notifications path * Update index.tsx * patch: use components for each tab * Create notificationsTab.tsx * Create systemTab.tsx * Update index.tsx * Update notificationsTab.tsx * Update index.tsx * Update index.tsx
- Loading branch information
1 parent
3d5abbe
commit 42a0ba6
Showing
5 changed files
with
478 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
django_project/frontend/src/pages/Notifications/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import Helmet from "react-helmet"; | ||
import { | ||
Box, | ||
Heading, | ||
Flex, | ||
Tabs, | ||
TabList, | ||
TabPanels, | ||
Tab, | ||
TabPanel, | ||
Text, | ||
IconButton, | ||
} from "@chakra-ui/react"; | ||
import { FaCog } from "react-icons/fa"; // Importing the gear icon | ||
import Header from "../../components/Header"; | ||
import Sidebar from "../../components/SideBar"; | ||
import NotificationsTab from "./notificationsTab"; | ||
import "../../styles/index.css"; | ||
import SystemTab from "./systemTab"; | ||
|
||
export default function Notifications() { | ||
const [selectedTab, setSelectedTab] = useState("all"); | ||
|
||
const handleSettingsClick = () => { | ||
// You can handle the settings button click here (e.g., open a modal or navigate to settings page) | ||
alert("Settings clicked"); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Helmet> | ||
<title>Notifications</title> | ||
<meta name="description" content="View and manage your notifications." /> | ||
</Helmet> | ||
|
||
<Header /> | ||
<Box bg="white" w="100%"> | ||
<Flex direction={{ base: "column", md: "row" }} gap="30px" alignItems="start"> | ||
{/* Sidebar */} | ||
<Sidebar display={{ base: "none", md: "flex" }} /> | ||
|
||
{/* Main Content */} | ||
<Box | ||
flex="1" | ||
ml={{ base: "55px", md: "0px" }} | ||
mt={{ base: "0px", md: "20px" }} | ||
width={{ base: "80%", md: "auto" }} | ||
overflow={"auto"} | ||
> | ||
<Heading size="lg" mb={6} color="black"> | ||
Notifications | ||
</Heading> | ||
|
||
{/* Tabs */} | ||
<Tabs | ||
variant="enclosed" | ||
isLazy | ||
onChange={(index) => | ||
setSelectedTab( | ||
index === 0 | ||
? "all" | ||
: index === 1 | ||
? "personal" | ||
: index === 2 | ||
? "organisations" | ||
: "system" | ||
) | ||
} | ||
> | ||
<TabList display="flex" alignItems="center"> | ||
<Tab | ||
_selected={{ color: "white", bg: "dark_green.800" }} | ||
color={selectedTab === "all" ? "white" : "black"} | ||
bg={selectedTab === "all" ? "dark_green.800" : "transparent"} | ||
> | ||
All | ||
</Tab> | ||
<Tab | ||
_selected={{ color: "white", bg: "dark_green.800" }} | ||
color={selectedTab === "personal" ? "white" : "black"} | ||
bg={selectedTab === "personal" ? "dark_green.800" : "transparent"} | ||
> | ||
Personal | ||
</Tab> | ||
<Tab | ||
_selected={{ color: "white", bg: "dark_green.800" }} | ||
color={selectedTab === "organisations" ? "white" : "black"} | ||
bg={selectedTab === "organisations" ? "dark_green.800" : "transparent"} | ||
> | ||
Organisations | ||
</Tab> | ||
<Tab | ||
_selected={{ color: "white", bg: "dark_green.800" }} | ||
color={selectedTab === "system" ? "white" : "black"} | ||
bg={selectedTab === "system" ? "dark_green.800" : "transparent"} | ||
> | ||
System | ||
</Tab> | ||
|
||
{/* Gear Icon on the extreme right */} | ||
<IconButton | ||
icon={<FaCog />} | ||
aria-label="Settings" | ||
onClick={handleSettingsClick} | ||
size="lg" | ||
variant="ghost" | ||
colorScheme="green" | ||
ml="auto" | ||
/> | ||
</TabList> | ||
|
||
<TabPanels> | ||
<TabPanel> | ||
<NotificationsTab /> | ||
</TabPanel> | ||
<TabPanel> | ||
<Text>No data available for Personal notifications.</Text> | ||
</TabPanel> | ||
<TabPanel> | ||
<Text>No data available for Organisations notifications.</Text> | ||
</TabPanel> | ||
<TabPanel> | ||
<SystemTab /> | ||
</TabPanel> | ||
</TabPanels> | ||
</Tabs> | ||
</Box> | ||
</Flex> | ||
</Box> | ||
</> | ||
); | ||
} |
78 changes: 78 additions & 0 deletions
78
django_project/frontend/src/pages/Notifications/notificationsTab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { | ||
Box, | ||
Heading, | ||
Text, | ||
Badge, | ||
} from "@chakra-ui/react"; | ||
import "../../styles/index.css"; | ||
|
||
export default function NotificationsTab() { | ||
const [allNotifications, setAllNotifications] = useState<any[]>([]); | ||
|
||
useEffect(() => { | ||
// Simulate fetching data for "All" notifications | ||
const fetchNotificationsData = () => { | ||
|
||
setAllNotifications([]); | ||
}; | ||
|
||
fetchNotificationsData(); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<Box> | ||
{allNotifications.map((notification) => ( | ||
<Box | ||
key={notification.id} | ||
p={4} | ||
mb={4} | ||
bg="gray.50" | ||
borderRadius="md" | ||
boxShadow="sm" | ||
display="flex" | ||
flexDirection="column" | ||
position="relative" | ||
minHeight="150px" | ||
> | ||
{/* Badge - Custom styled */} | ||
<Badge | ||
colorScheme="green" | ||
position="absolute" | ||
top={2} | ||
right={2} | ||
fontSize="sm" | ||
fontWeight="normal" | ||
px={2} | ||
py={1} | ||
> | ||
{notification.badge} | ||
</Badge> | ||
|
||
{/* Title */} | ||
<Heading size="sm" mb={2} color="black"> | ||
{notification.title} | ||
</Heading> | ||
|
||
{/* Description */} | ||
<Text color="black" mb={4}> | ||
{notification.description} | ||
</Text> | ||
|
||
{/* Timestamp */} | ||
<Text | ||
color="black" | ||
position="absolute" | ||
bottom={4} | ||
left={4} | ||
fontSize="sm" | ||
> | ||
{notification.timestamp} | ||
</Text> | ||
</Box> | ||
))} | ||
</Box> | ||
</> | ||
); | ||
} |
Oops, something went wrong.