Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
RNR1 committed Jun 22, 2024
1 parent a8fe874 commit ef9a1ae
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 104 deletions.
5 changes: 1 addition & 4 deletions src/components/SelectedTapHours/SelectedTapHours.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { useState, useEffect } from 'react';
import { hours } from '../../helpers/hours';
import styles from './SelectedTapHours.module.scss';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCaretDown } from '@fortawesome/free-solid-svg-icons';
import useIsMobile from 'hooks/useIsMobile';

const SelectedTapHours = ({ infoIsExpanded, selectedPlace }) => {
const isMobile = useIsMobile();
const [isHoursExpanded, setIsHoursExpanded] = useState(false);
const [currentDay, setCurrentDay] = useState(new Date().getDay());
const [currentOrgHours, setCurrentOrgHours] = useState(false);
Expand Down Expand Up @@ -74,7 +71,7 @@ const SelectedTapHours = ({ infoIsExpanded, selectedPlace }) => {
setCurrentOrgHours(false);
setIsOpen(null);
}
}, [selectedPlace]);
}, [currentDay, selectedPlace]);

return (
<>
Expand Down
9 changes: 2 additions & 7 deletions src/components/TutorialModal/TutorialModal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { faSlidersH } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import { Button, Form, Modal } from 'react-bootstrap';
import useLocalStorage from '../../hooks/useLocalStorage';
import phlaskFilterIcon from '../icons/PhlaskFilterIcon';
Expand All @@ -21,11 +21,6 @@ const TutorialModal = () => {
const [showModalCheckbox, setShowModalCheckbox] = useState(true);
const [modalCheckbox, setModalCheckbox] = useState(false);

function handleShow() {
setShowModal(true);
setShowModalCheckbox(false);
}

function handleClose() {
setShowModal(false);
setModalStep(1);
Expand All @@ -50,7 +45,7 @@ const TutorialModal = () => {

useEffect(() => {
setShowModal(showModalPreference);
}, []);
}, [showModalPreference]);

const modalContent = {
1: {
Expand Down
184 changes: 91 additions & 93 deletions src/contexts/HeaderContext.js
Original file line number Diff line number Diff line change
@@ -1,112 +1,110 @@
import About from 'components/Pages/About';
import Contact from 'components/Pages/Contact';
import Join from 'components/Pages/Join';
import React, { createContext, useEffect, useState } from 'react';
import { createContext, useCallback, useEffect, useState } from 'react';
import { useSelector } from 'react-redux';

const HeaderContext = createContext({});

// Create a HeaderProvider component
const HeaderProvider = ({ children }) => {
// Define the state for the header context
const [anchorEl, setAnchorEl] = useState(null);
const [sidebarOpen, setSidebarOpen] = useState(false);
const [showMapControls, setShowMapControls] = useState(false);
const [menuExpand, setMenuExpand] = useState(false);
const [pageExpand, setPageExpand] = useState(false);
const [verticalAnimFinished1, setVerticalAnimFinished1] = useState(false);
const [verticalAnimFinished2, setVerticalAnimFinished2] = useState(false);
const [shownPage, setShownPage] = useState(null);
const isSearchShown = useSelector(state => state.filterMarkers.isSearchShown);
const isFilterShown = useSelector(state => state.filterMarkers.isFilterShown);
// Define the state for the header context
const [anchorEl, setAnchorEl] = useState(null);
const [sidebarOpen, setSidebarOpen] = useState(false);
const [showMapControls, setShowMapControls] = useState(false);
const [menuExpand, setMenuExpand] = useState(false);
const [pageExpand, setPageExpand] = useState(false);
const [verticalAnimFinished1, setVerticalAnimFinished1] = useState(false);
const [verticalAnimFinished2, setVerticalAnimFinished2] = useState(false);
const [shownPage, setShownPage] = useState(null);
const isSearchShown = useSelector(state => state.filterMarkers.isSearchShown);
const isFilterShown = useSelector(state => state.filterMarkers.isFilterShown);

// Define any functions or values you want to expose to consumers of the context
const open = Boolean(anchorEl);
const toggleMenuExpand = event => {
if (menuExpand) {
setVerticalAnimFinished1(false);
setVerticalAnimFinished2(false);
setPageExpand(false);
setShownPage(null);
}
setMenuExpand(!menuExpand);
};
// Define any functions or values you want to expose to consumers of the context
const open = Boolean(anchorEl);
const toggleMenuExpand = event => {
if (menuExpand) {
setVerticalAnimFinished1(false);
setVerticalAnimFinished2(false);
setPageExpand(false);
setShownPage(null);
}
setMenuExpand(!menuExpand);
};

const showSidebar = () => {
setSidebarOpen(true);
};
const showSidebar = () => {
setSidebarOpen(true);
};

const menuClicked = page => {
if (page == shownPage) {
setVerticalAnimFinished1(false);
setVerticalAnimFinished2(false);
setPageExpand(false);
setShownPage(null);
} else {
setPageExpand(true);
switch (page) {
case 'about':
page = <About />;
break;
case 'join':
page = <Join />;
break;
case 'contact':
page = <Contact />;
break;
default:
break;
}
setShownPage(page);
}
};
const menuClicked = page => {
if (page == shownPage) {
setVerticalAnimFinished1(false);
setVerticalAnimFinished2(false);
setPageExpand(false);
setShownPage(null);
} else {
setPageExpand(true);
switch (page) {
case 'about':
page = <About />;
break;
case 'join':
page = <Join />;
break;
case 'contact':
page = <Contact />;
break;
default:
break;
}
setShownPage(page);
}
};

const isNotMapPage = useCallback(() => {
const pagePaths = /(\/mission)|(\/share)|(\/project)|(\/contribute)/;
const isNotMapPage = () => {
return window.location.pathname.match(pagePaths);
};
return window.location.pathname.match(pagePaths);
}, []);

//On render, check if on map page to show or hide map controls
useEffect(() => {
if (isNotMapPage()) {
setShowMapControls(false);
} else {
setShowMapControls(true);
}
}, [isNotMapPage, setShowMapControls]);
//On render, check if on map page to show or hide map controls
useEffect(() => {
if (isNotMapPage()) {
setShowMapControls(false);
} else {
setShowMapControls(true);
}
}, [isNotMapPage, setShowMapControls]);

const stateVal = {
anchorEl,
setAnchorEl,
sidebarOpen,
setSidebarOpen,
showMapControls,
setShowMapControls,
menuExpand,
setMenuExpand,
pageExpand,
setPageExpand,
verticalAnimFinished1,
setVerticalAnimFinished1,
verticalAnimFinished2,
setVerticalAnimFinished2,
shownPage,
setShownPage,
isSearchShown,
isFilterShown,
open,
toggleMenuExpand,
showSidebar,
menuClicked,
isNotMapPage,
};
const stateVal = {
anchorEl,
setAnchorEl,
sidebarOpen,
setSidebarOpen,
showMapControls,
setShowMapControls,
menuExpand,
setMenuExpand,
pageExpand,
setPageExpand,
verticalAnimFinished1,
setVerticalAnimFinished1,
verticalAnimFinished2,
setVerticalAnimFinished2,
shownPage,
setShownPage,
isSearchShown,
isFilterShown,
open,
toggleMenuExpand,
showSidebar,
menuClicked,
isNotMapPage
};

// Return the HeaderContext.Provider with the headerState and any other values/functions
return (
<HeaderContext.Provider value={stateVal} >
{children}
</HeaderContext.Provider>
);
// Return the HeaderContext.Provider with the headerState and any other values/functions
return (
<HeaderContext.Provider value={stateVal}>{children}</HeaderContext.Provider>
);
};

export { HeaderContext, HeaderProvider };
export { HeaderContext, HeaderProvider };

0 comments on commit ef9a1ae

Please sign in to comment.