Skip to content

Commit

Permalink
Created responsive design for Navbar. Adjusted VolunteerEventPage and…
Browse files Browse the repository at this point in the history
… VolunteerHomePage to properly accomodate responsive Navbar design. Adjusted naming for Export buttons. iPad view now uses VolunteerSideViewDrawer.
  • Loading branch information
Aokijiop committed May 19, 2024
1 parent 91b384c commit f553ba4
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 36 deletions.
12 changes: 6 additions & 6 deletions src/components/Events/EventFilteredGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Heading,
HStack,
} from '@chakra-ui/react';
import { useEffect, useState } from 'react';
import { useEffect, useState, useCallback } from 'react';
import { SearchIcon } from '@chakra-ui/icons';
import PropTypes from 'prop-types';

Expand All @@ -30,7 +30,7 @@ const EventFilteredGrid = ({ setCurrentEventId, setIsOpen, setShowOpenDrawerButt
const [date, setDate] = useState('');
const [fuse, setFuse] = useState();

const getEvents = async () => {
const getEvents = useCallback(async () => {
try {
const eventsData = await Backend.get('/events/currentEvents');
setEvents(eventsData.data);
Expand All @@ -42,7 +42,7 @@ const EventFilteredGrid = ({ setCurrentEventId, setIsOpen, setShowOpenDrawerButt
} catch (err) {
console.log(`Error getting events: `, err.message);
}
};
}, []);

const getLocation = data => {
let location = [];
Expand Down Expand Up @@ -75,7 +75,7 @@ const EventFilteredGrid = ({ setCurrentEventId, setIsOpen, setShowOpenDrawerButt

useEffect(() => {
getEvents();
}, []);
}, [getEvents]);

const handleLocationChange = event => {
const selectedLocation = event.target.value;
Expand Down Expand Up @@ -121,7 +121,7 @@ const EventFilteredGrid = ({ setCurrentEventId, setIsOpen, setShowOpenDrawerButt
} else result = events;
// result.map((e) -> e.)
setDisplayEvents(result);
}, [name, location, date, fuse]);
}, [name, location, date, fuse, events]);

return (
<>
Expand All @@ -130,7 +130,7 @@ const EventFilteredGrid = ({ setCurrentEventId, setIsOpen, setShowOpenDrawerButt
flexDir={'column'}
alignItems={'center'}
bg="#E6EAEF"
ml={{ base: '2vw', xl: '15%' }}
ml={{ base: '2vw', xl: isOpen ? '22%' : '15%' }}
mr={{ base: '2vw' }}
pt={4}
mb="32px"
Expand Down
21 changes: 12 additions & 9 deletions src/components/Events/FeaturedDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@ const FeaturedDashboard = ({
setIsOpen,
setShowOpenDrawerButton,
onOpen,
isSideBarOpen,
showOpenDrawerButton,
}) => {
const [featuredEvents, setFeaturedEvents] = useState([]);
const numEvents = useBreakpointValue({ base: 1, md: 2, xl: 2 });

const getEvents = async () => {
try {
const eventsData = await Backend.get('/events');
setFeaturedEvents(eventsData.data.slice(0, numEvents));
} catch (err) {
console.log(`Error getting events: `, err.message);
}
};

useEffect(() => {
const getEvents = async () => {
try {
const eventsData = await Backend.get('/events');
setFeaturedEvents(eventsData.data.slice(0, numEvents));
} catch (err) {
console.log(`Error getting events: `, err.message);
}
};

getEvents();
}, [numEvents]);

Expand All @@ -34,7 +36,7 @@ const FeaturedDashboard = ({
flexDir={'column'}
alignItems={'center'}
bg="#E6EAEF"
ml={{ base: '3vw', xl: '15%' }}
ml={{ base: '3vw', xl: isSideBarOpen ? '22%' : '15%' }}
mr={{ base: '3vw' }}
pt={4}
>
Expand Down Expand Up @@ -128,6 +130,7 @@ FeaturedDashboard.propTypes = {
setCurrentEventId: PropTypes.func.isRequired,
setIsOpen: PropTypes.func.isRequired,
setShowOpenDrawerButton: PropTypes.func.isRequired,
isSideBarOpen: PropTypes.bool
};

export default FeaturedDashboard;
2 changes: 1 addition & 1 deletion src/components/Events/ImpactSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const ImpactSummary = () => {
filename="./data.csv"
headers={header}
>
Export Data
Export All Data
</CSVLink>
{/* {eventIdData.map((eventData) => <CSVLink
data={eventData ? [eventData] : ''}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Events/PastEventsImpactSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const PastEventsImpactSummary = () => {
filename="./data.csv"
headers={header}
>
Export Data
Export Past Events Data
</CSVLink>
</Button>
</VStack>
Expand Down
11 changes: 6 additions & 5 deletions src/components/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const Navbar = () => {

useEffect(() => {
updateUser();
}, []);
}, [updateUser]);

// Change the paths for each button since these might change
const homePath = '/';
Expand Down Expand Up @@ -252,6 +252,7 @@ const Navbar = () => {
// borderRadius: '12px',
backgroundColor: '#FFF',
border: '1px',
width: 'full'
}}
onClick={e => {
e.preventDefault();
Expand All @@ -264,8 +265,8 @@ const Navbar = () => {
{/* <Box style={{ borderRadius: '50%' }}> */}
<Image
src={user?.image_url}
width="2.75vw"
height="2.75vw"
width="20%"
aspectRatio={1}
borderRadius="full"
objectFit="cover"
/>
Expand All @@ -284,7 +285,7 @@ const Navbar = () => {
textOverflow="ellipsis"
fontWeight='800'
color='#000000'
fontSize='1vw'
fontSize='75%'
lineHeight='25px'
textAlign='left'
marginTop='-1px'
Expand All @@ -295,7 +296,7 @@ const Navbar = () => {

<Tag
style={{
fontSize: '0.75vw',
fontSize: '56.25%',
fontWeight: '500',
lineHeight: '16px',
color: '#717171',
Expand Down
6 changes: 2 additions & 4 deletions src/components/VolunteerSideViewDrawer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Drawer,
DrawerOverlay,
DrawerContent,
DrawerCloseButton,
DrawerBody,
useDisclosure,
} from '@chakra-ui/react';
Expand Down Expand Up @@ -46,7 +45,7 @@ const VolunteerSideViewDrawer = ({ eventId, isOpen, onClose, setShowOpenDrawerBu
getEventById(eventId).then(data => setEventData(data));
getEventDataVolunteerId(user?.id, eventId).then(data => setEventDataVolunteer(data));
// setDateObj(new Date(Date.parse(eventData.date)))
}, [eventId]);
}, [eventId, user?.id]);

function formatDate(dateString) {
const months = [
Expand Down Expand Up @@ -81,12 +80,11 @@ const VolunteerSideViewDrawer = ({ eventId, isOpen, onClose, setShowOpenDrawerBu
<Drawer isOpen={isOpen} placement="right" onClose={onClose} size="full">
<DrawerOverlay />
<DrawerContent>
<DrawerCloseButton />
<DrawerBody>
<Flex
flexDir={'column'}
w={'100%'}
maxW={'26em'}
maxW={'100vw'}
mt={'1em'}
px={{ base: '10px', md: '20px' }}
>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/VolunteerEventPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const VolunteerEventPage = () => {
/>
</Box>
{/* Drawer Component */}
{breakpoint == 'base' ? (
{breakpoint != 'xl' ? (
<VolunteerSideViewDrawer
eventId={currentEventId}
isOpen={isDrawerOpen}
Expand Down
10 changes: 5 additions & 5 deletions src/pages/VolunteerHomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
useBreakpoint,
useDisclosure,
} from '@chakra-ui/react';
import { useEffect, useState, useContext } from 'react';
import { useEffect, useState, useContext, useCallback } from 'react';
import { SearchIcon, HamburgerIcon } from '@chakra-ui/icons';

import EventCard from '../components/Events/EventCard';
Expand Down Expand Up @@ -42,7 +42,7 @@ const VolunteerHomePage = () => {

const { user } = useContext(UserContext);

const getEvents = async () => {
const getEvents = useCallback(async () => {
try {
console.log;
console.log(user);
Expand All @@ -54,7 +54,7 @@ const VolunteerHomePage = () => {
} catch (err) {
console.log(`Error getting events: `, err.message);
}
};
}, [user]);

const eventCards = displayEvents.map(element => (
<GridItem
Expand All @@ -73,7 +73,7 @@ const VolunteerHomePage = () => {
if (user) {
getEvents();
}
}, [user]);
}, [getEvents, user]);

useEffect(() => {
if (!fuse) {
Expand Down Expand Up @@ -231,7 +231,7 @@ const VolunteerHomePage = () => {
</Box>
</Flex>
</Flex>
{breakpoint == 'base' ? (
{breakpoint != 'xl' ? (
<VolunteerSideViewDrawer
eventId={currentEventId}
isOpen={isOpen}
Expand Down
22 changes: 18 additions & 4 deletions src/pages/Volunteers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { IoDocumentText } from 'react-icons/io5';
import VolunteersTable from '../components/VolunteersTable';
import { useState, useEffect, useContext } from 'react';
import Backend from '../utils/utils';
import { ExternalLinkIcon, HamburgerIcon } from '@chakra-ui/icons';
import { HamburgerIcon } from '@chakra-ui/icons';
import { AiOutlineExport } from 'react-icons/ai';
import { GreyCustomSearchIcon } from '../components/Icons/CustomSearchIcon';
import Fuse from 'fuse.js';
import { TrophyIcon } from '../components/Icons/TrophyIcon';
Expand Down Expand Up @@ -255,7 +256,7 @@ const Volunteers = () => {
justifyContent={{ base: 'center', lg: 'start' }}
alignItems={'end'}
>
<Button
{/* <Button
backgroundColor={'#0075FF'}
fontSize="lg"
style={{
Expand All @@ -266,13 +267,26 @@ const Volunteers = () => {
}}
height={'fit-content'}
>
<ExternalLinkIcon marginRight="2" boxSize="6" color={'white'} />{' '}
<ExternalLinkIcon marginRight="2" boxSize="1vw" color={'white'} />{' '}
<CSVLink
data={volunteerData.length ? volunteerData : []}
filename="./data.csv"
headers={header}
>
Export
</CSVLink>
</Button> */}
<Button
colorScheme={'messenger'}
leftIcon={<AiOutlineExport></AiOutlineExport>}
size="md"
>
<CSVLink
data={volunteerData.length ? volunteerData : []}
filename="./data.csv"
headers={header}
>
Export All
Export Volunteer Data
</CSVLink>
</Button>
</Box>
Expand Down

0 comments on commit f553ba4

Please sign in to comment.