Skip to content

Commit

Permalink
finished fixing bugs with sideview and open tab button
Browse files Browse the repository at this point in the history
  • Loading branch information
NwinNwin committed May 6, 2024
1 parent 2d8afc8 commit 062e213
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/components/Events/FeaturedDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import EventCard from './EventCard';
import { RxCaretLeft } from 'react-icons/rx';
import PropTypes from 'prop-types';

const FeaturedDashboard = ({ onOpen, showOpenDrawerButton }) => {
const FeaturedDashboard = ({ onOpen, showOpenDrawerButton, isOpen }) => {
const [featuredEvents, setFeaturedEvents] = useState([]);
const numEvents = useBreakpointValue({ base: 1, md: 2, xl: 2 });

Expand Down Expand Up @@ -66,7 +66,7 @@ const FeaturedDashboard = ({ onOpen, showOpenDrawerButton }) => {
w="40px"
icon={<RxCaretLeft size={22} />}
onClick={onOpen}
display={showOpenDrawerButton ? { base: 'none', xl: 'flex' } : 'none'}
display={showOpenDrawerButton && !isOpen ? { base: 'none', xl: 'flex' } : 'none'}
></IconButton>
</Flex>
</Flex>
Expand Down Expand Up @@ -103,6 +103,7 @@ const FeaturedDashboard = ({ onOpen, showOpenDrawerButton }) => {
};

FeaturedDashboard.propTypes = {
isOpen: PropTypes.bool,
onOpen: PropTypes.func,
showOpenDrawerButton: PropTypes.bool,
};
Expand Down
17 changes: 9 additions & 8 deletions src/components/VolunteerSideView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ const VolunteerSideView = ({ eventId, onClose, setShowOpenDrawerButton }) => {
// setDateObj(new Date(Date.parse(eventData.date)))
}, [eventId]);

const handleClose = () => {
if (setShowOpenDrawerButton) {
setShowOpenDrawerButton(false);
}
onClose(); // Ensure onClose is always called to close the view
};
// const handleClose = () => {
// onClose(); // Ensure onClose is always called to close the view
// setShowOpenDrawerButton(true);
// };

// console.log('e', eventData);
// console.log('d', dateObj)
Expand Down Expand Up @@ -93,7 +91,10 @@ const VolunteerSideView = ({ eventId, onClose, setShowOpenDrawerButton }) => {
h="40px"
w="40px"
icon={<RxCaretRight size={22} />}
onClick={handleClose}
onClick={() => {
onClose();
setShowOpenDrawerButton(true);
}}
></IconButton>
<Flex
bg="#EFEFEF"
Expand Down Expand Up @@ -291,4 +292,4 @@ VolunteerSideView.propTypes = {
setShowOpenDrawerButton: PropTypes.func.isRequired,
};

export default VolunteerSideView;
export default VolunteerSideView;
16 changes: 11 additions & 5 deletions src/pages/VolunteerEventPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ const VolunteerEventPage = () => {

const openEventDrawer = eventId => {
setCurrentEventId(eventId); // Set the current event ID, which triggers the side view to display
setShowOpenDrawerButton(false);
onOpen();
};

const handleClose = () => {
onClose();
setCurrentEventId(null); // Clear the current event ID on close
};
console.log('test' + currentEventId);
// const {
Expand Down Expand Up @@ -82,7 +82,7 @@ const VolunteerEventPage = () => {
flex-shrink="0"
borderRadius={'xl'}
flexDir={'column'}
display={showOpenDrawerButton ? { base: 'flex', xl: 'none' } : 'none'}
display={showOpenDrawerButton && !isOpen ? { base: 'flex', xl: 'none' } : 'none'}
>
<IconButton
borderRadius="md"
Expand All @@ -93,11 +93,18 @@ const VolunteerEventPage = () => {
h="64px"
w="64px"
icon={<RxCaretLeft size={40} />}
onClick={onOpen}
onClick={() => {
onOpen();
}}
></IconButton>
</Flex>
</Flex>
<FeaturedDashboard width={{ base: '90%' }} onOpen={onOpen} />
<FeaturedDashboard
width={{ base: '90%' }}
onOpen={onOpen}
showOpenDrawerButton={showOpenDrawerButton}
isOpen={isOpen}
/>
<EventFilteredGrid
width={{ base: '90%' }}
setCurrentEventId={openEventDrawer} // Adjusted to call `openEventDrawer`
Expand All @@ -123,7 +130,6 @@ const VolunteerEventPage = () => {
/>
)
)}
{/* { : null} */}
</Flex>
);
};
Expand Down

0 comments on commit 062e213

Please sign in to comment.