-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve dashboard #82
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
import React, { useState } from 'react'; | ||
import { | ||
Box, Checkbox, Flex, Heading, HStack, Icon, | ||
SimpleGrid, Text, VStack, IconButton, useMediaQuery, | ||
Box, Checkbox, | ||
Flex, | ||
Heading, HStack, | ||
Icon, | ||
SimpleGrid, | ||
Text, | ||
VStack, | ||
IconButton, useMediaQuery, | ||
Spacer | ||
} from '@chakra-ui/react'; | ||
import { FiHome, FiMessageSquare, FiBriefcase, FiUser, FiMoon, FiLogOut, FiBarChart2, FiCalendar, FiSettings, FiHelpCircle, FiEdit, FiZap } from 'react-icons/fi'; | ||
import { | ||
FiHome, FiMessageSquare, FiBriefcase, FiUser, FiMoon, FiLogOut, | ||
FiBarChart2, FiCalendar, | ||
FiSettings, FiHelpCircle, | ||
FiEdit, FiZap | ||
} from 'react-icons/fi'; | ||
|
||
interface Todo { | ||
id: number; | ||
|
@@ -29,6 +40,8 @@ const Dashboard: React.FC = () => { | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const [activeTab, setActiveTab] = useState('dashboard'); | ||
const [isMobile] = useMediaQuery("(max-width: 768px)"); | ||
const [isWide, setIsWide] = useState(true); | ||
|
||
const [todos, setTodos] = useState<Todo[]>(initialTodos); | ||
|
||
const navItems: NavItem[] = [ | ||
|
@@ -45,114 +58,147 @@ const Dashboard: React.FC = () => { | |
todo.id === id ? { ...todo, completed: !todo.completed } : todo | ||
)); | ||
}; | ||
|
||
|
||
|
||
|
||
const toggleWidth = () => { | ||
setIsWide(!isWide); | ||
}; | ||
return ( | ||
<Flex direction="column" h="100vh"> | ||
<Flex as="nav" bg="gray.800" py={3} px={6} alignItems="center" pl={6}> | ||
|
||
|
||
|
||
|
||
|
||
|
||
<div className='flex w-full min-h-screen '> | ||
<Flex as="nav" py={2} alignItems="center" className={`${isWide ? 'w-64' : 'w-20'} flex flex-col w-20 shadow-2xl border-r-2 `}> | ||
<button | ||
onClick={toggleWidth} | ||
className={` text-black rounded transition-all duration-600`} | ||
> | ||
|
||
</button> | ||
{navItems.map((item) => ( | ||
<Flex | ||
key={item.id} | ||
alignItems="center" | ||
px={4} | ||
py={2} | ||
cursor="pointer" | ||
bg={item.id === 'dashboard' ? "blue.600" : "transparent"} | ||
color={item.id === 'dashboard' ? "white" : "gray.300"} | ||
onClick={() => setActiveTab(item.id)} | ||
_hover={item.id !== 'dashboard' ? { bg: "gray.700" } : {}} | ||
mr={5} | ||
_hover={item.id !== 'dashboard' ? { bg: "gray.700", } : {bg:"gray.700"}} | ||
className=' hover:rounded-md hover:text-white mt-3' | ||
cursor={"pointer"} | ||
|
||
> | ||
<Icon as={item.icon} boxSize={6} mr={3} /> | ||
<Text fontWeight={item.id === 'dashboard' ? "semibold" : "normal"} fontSize="14px">{item.label}</Text> | ||
|
||
<div className='flex justify-between m-2 items-center '> | ||
|
||
|
||
<div> <Icon as={item.icon} boxSize={6} /></div> | ||
{/* <p className={``}>{item.label}</p> */} | ||
</div> | ||
</Flex> | ||
Comment on lines
83
to
100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve navigation accessibility and user experience The navigation items need accessibility improvements and better keyboard support. - <Flex
+ <Flex
+ role="button"
+ tabIndex={0}
+ aria-label={item.label}
+ onKeyPress={(e) => e.key === 'Enter' && setActiveTab(item.id)}
key={item.id}
alignItems="center"
onClick={() => setActiveTab(item.id)}
_hover={item.id !== 'dashboard' ? { bg: "gray.700", } : {bg:"gray.700"}}
className=' hover:rounded-md hover:text-white mt-3'
cursor={"pointer"}
>
<div className='flex justify-between m-2 items-center'>
<div><Icon as={item.icon} boxSize={6} /></div>
- {/* <p className={``}>{item.label}</p> */}
+ {isWide && <Text ml={2}>{item.label}</Text>}
</div>
</Flex>
|
||
))} | ||
<Spacer /> | ||
|
||
<IconButton | ||
aria-label="Toggle Dark Mode" | ||
icon={<Icon as={FiMoon} boxSize={6} />} | ||
onClick={() => {/* Implement dark mode toggle */}} | ||
onClick={() => { }} | ||
variant="ghost" | ||
color="gray.300" | ||
color="gray.800" | ||
_hover={{ bg: "gray.700" }} | ||
mr={3} | ||
className='mt-2 hover:text-white' | ||
|
||
/> | ||
|
||
|
||
|
||
<IconButton | ||
aria-label="Logout" | ||
icon={<Icon as={FiLogOut} boxSize={6} />} | ||
onClick={() => {/* Implement logout */}} | ||
onClick={() => { }} | ||
variant="ghost" | ||
color="gray.300" | ||
color="gray.800" | ||
_hover={{ bg: "gray.700" }} | ||
className='mt-2 hover:text-white' | ||
/> | ||
<Spacer /> | ||
|
||
</Flex> | ||
<Box flex="1" p={8} bg="gray.50" overflowY="auto"> | ||
<SimpleGrid columns={isMobile ? 1 : 2} spacing={8} mb={8}> | ||
<Box bg="white" p={6} borderRadius="lg" boxShadow="md" _hover={{ boxShadow: "lg" }}> | ||
<Heading as="h3" size="md" mb={6} color="purple.500">Application Statistics</Heading> | ||
<SimpleGrid columns={[1, 2, 3]} spacing={6}> | ||
<VStack align="start" spacing={2}> | ||
<HStack spacing={3}> | ||
<Icon as={FiZap} boxSize={6} color="purple.500" /> | ||
<Text fontSize="2xl" fontWeight="bold" color="purple.500">28</Text> | ||
</HStack> | ||
<Text fontSize="sm" color="gray.600">Auto-Applied Jobs</Text> | ||
<div className='flex flex-col w-full min-h-screen bg-yellow-600 '> | ||
<Box flex="1" p={8} bg="gray.50" overflowY="auto"> | ||
<SimpleGrid columns={isMobile ? 1 : 2} spacing={8} mb={8}> | ||
<Box bg="white" p={6} borderRadius="lg" boxShadow="md" _hover={{ boxShadow: "lg" }}> | ||
<Heading as="h3" size="md" mb={6} color="purple.500">Application Statistics</Heading> | ||
<SimpleGrid columns={[1, 2, 3]} spacing={6}> | ||
<VStack align="start" spacing={2}> | ||
<HStack spacing={3}> | ||
<Icon as={FiZap} boxSize={6} color="purple.500" /> | ||
<Text fontSize="2xl" fontWeight="bold" color="purple.500">28</Text> | ||
</HStack> | ||
<Text fontSize="sm" color="gray.600">Auto-Applied Jobs</Text> | ||
</VStack> | ||
<VStack align="start" spacing={2}> | ||
<HStack spacing={3}> | ||
<Icon as={FiBarChart2} boxSize={6} color="purple.500" /> | ||
<Text fontSize="2xl" fontWeight="bold" color="purple.500">68%</Text> | ||
</HStack> | ||
<Text fontSize="sm" color="gray.600">Success Rate</Text> | ||
</VStack> | ||
<VStack align="start" spacing={2}> | ||
<HStack spacing={3}> | ||
<Icon as={FiCalendar} boxSize={6} color="purple.500" /> | ||
<Text fontSize="2xl" fontWeight="bold" color="purple.500">3</Text> | ||
</HStack> | ||
<Text fontSize="sm" color="gray.600">Upcoming Interviews</Text> | ||
</VStack> | ||
</SimpleGrid> | ||
</Box> | ||
Comment on lines
+131
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add proper data management for statistics The statistics section contains hardcoded values. Consider implementing proper data fetching with loading and error states. + interface DashboardStats {
+ autoAppliedJobs: number;
+ successRate: number;
+ upcomingInterviews: number;
+ }
+
+ const [stats, setStats] = useState<DashboardStats | null>(null);
+ const [isLoading, setIsLoading] = useState(true);
+ const [error, setError] = useState<Error | null>(null);
+
+ useEffect(() => {
+ const fetchStats = async () => {
+ try {
+ setIsLoading(true);
+ // Replace with actual API call
+ const response = await fetch('/api/dashboard/stats');
+ const data = await response.json();
+ setStats(data);
+ } catch (err) {
+ setError(err as Error);
+ } finally {
+ setIsLoading(false);
+ }
+ };
+ fetchStats();
+ }, []);
<Box bg="white" p={6} borderRadius="lg" boxShadow="md">
+ {isLoading && <Spinner />}
+ {error && <Alert status="error">{error.message}</Alert>}
+ {stats && (
<SimpleGrid columns={[1, 2, 3]} spacing={6}>
<VStack align="start" spacing={2}>
<HStack spacing={3}>
<Icon as={FiZap} boxSize={6} color="purple.500" />
- <Text fontSize="2xl" fontWeight="bold" color="purple.500">28</Text>
+ <Text fontSize="2xl" fontWeight="bold" color="purple.500">{stats.autoAppliedJobs}</Text>
</HStack>
<Text fontSize="sm" color="gray.600">Auto-Applied Jobs</Text>
</VStack>
// Similar changes for other statistics
</SimpleGrid>
+ )}
</Box>
|
||
<Box bg="white" p={6} borderRadius="lg" boxShadow="md" _hover={{ boxShadow: "lg" }}> | ||
<Heading as="h3" size="md" mb={4} color="purple.500">Upcoming Interviews</Heading> | ||
<VStack align="stretch" spacing={4}> | ||
{[ | ||
{ company: 'TechCorp', date: '15/06/2023, 14:00:00' }, | ||
{ company: 'InnoSoft', date: '17/06/2023, 10:30:00' }, | ||
{ company: 'DataDynamics', date: '20/06/2023, 15:45:00' }, | ||
].map((interview, index) => ( | ||
<HStack key={index} justify="space-between" p={2} _hover={{ bg: "purple.50" }}> | ||
<Text fontWeight="bold">{interview.company}</Text> | ||
<Text fontSize="sm" color="gray.500">{interview.date}</Text> | ||
</HStack> | ||
))} | ||
</VStack> | ||
<VStack align="start" spacing={2}> | ||
<HStack spacing={3}> | ||
<Icon as={FiBarChart2} boxSize={6} color="purple.500" /> | ||
<Text fontSize="2xl" fontWeight="bold" color="purple.500">68%</Text> | ||
</HStack> | ||
<Text fontSize="sm" color="gray.600">Success Rate</Text> | ||
</VStack> | ||
<VStack align="start" spacing={2}> | ||
<HStack spacing={3}> | ||
<Icon as={FiCalendar} boxSize={6} color="purple.500" /> | ||
<Text fontSize="2xl" fontWeight="bold" color="purple.500">3</Text> | ||
</HStack> | ||
<Text fontSize="sm" color="gray.600">Upcoming Interviews</Text> | ||
</VStack> | ||
</SimpleGrid> | ||
</Box> | ||
</Box> | ||
</SimpleGrid> | ||
<Box bg="white" p={6} borderRadius="lg" boxShadow="md" _hover={{ boxShadow: "lg" }}> | ||
<Heading as="h3" size="md" mb={4} color="purple.500">Upcoming Interviews</Heading> | ||
<VStack align="stretch" spacing={4}> | ||
{[ | ||
{ company: 'TechCorp', date: '15/06/2023, 14:00:00' }, | ||
{ company: 'InnoSoft', date: '17/06/2023, 10:30:00' }, | ||
{ company: 'DataDynamics', date: '20/06/2023, 15:45:00' }, | ||
].map((interview, index) => ( | ||
<HStack key={index} justify="space-between" p={2} _hover={{ bg: "purple.50" }}> | ||
<Text fontWeight="bold">{interview.company}</Text> | ||
<Text fontSize="sm" color="gray.500">{interview.date}</Text> | ||
<Heading as="h3" size="md" mb={4} color="purple.500">Todo List</Heading> | ||
<VStack align="stretch" spacing={2}> | ||
{todos.map((todo) => ( | ||
<HStack key={todo.id} justify="space-between" p={2} _hover={{ bg: "purple.50" }}> | ||
<Checkbox | ||
isChecked={todo.completed} | ||
onChange={() => toggleTodo(todo.id)} | ||
colorScheme="purple" | ||
> | ||
<Text as={todo.completed ? "s" : "span"}>{todo.text}</Text> | ||
</Checkbox> | ||
<IconButton | ||
aria-label="Edit todo" | ||
icon={<Icon as={FiEdit} />} | ||
size="sm" | ||
variant="ghost" | ||
_hover={{ color: "purple.500" }} | ||
/> | ||
</HStack> | ||
))} | ||
</VStack> | ||
</Box> | ||
Comment on lines
+174
to
195
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement missing todo functionality The todo list has incomplete features:
Would you like me to help implement the missing todo functionality including proper error handling and CRUD operations? |
||
</SimpleGrid> | ||
<Box bg="white" p={6} borderRadius="lg" boxShadow="md" _hover={{ boxShadow: "lg" }}> | ||
<Heading as="h3" size="md" mb={4} color="purple.500">Todo List</Heading> | ||
<VStack align="stretch" spacing={2}> | ||
{todos.map((todo) => ( | ||
<HStack key={todo.id} justify="space-between" p={2} _hover={{ bg: "purple.50" }}> | ||
<Checkbox | ||
isChecked={todo.completed} | ||
onChange={() => toggleTodo(todo.id)} | ||
colorScheme="purple" | ||
> | ||
<Text as={todo.completed ? "s" : "span"}>{todo.text}</Text> | ||
</Checkbox> | ||
<IconButton | ||
aria-label="Edit todo" | ||
icon={<Icon as={FiEdit} />} | ||
size="sm" | ||
variant="ghost" | ||
_hover={{ color: "purple.500" }} | ||
/> | ||
</HStack> | ||
))} | ||
</VStack> | ||
</Box> | ||
</Box> | ||
</Flex> | ||
</div> | ||
|
||
</div> | ||
|
||
|
||
); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix empty button and add proper accessibility attributes
The button element is empty and missing necessary accessibility attributes.