diff --git a/src/components/header.js b/src/components/header.js index bfb3483..964ba7f 100644 --- a/src/components/header.js +++ b/src/components/header.js @@ -8,39 +8,38 @@ import { MiscContext } from "../state/misc" import BaseButton from "./baseButton" import ButtonCart from "./buttonCart" import IconBars from "./iconBars" - import Search from "./search" +export const getActiveSidebar = (location) => location.state?.activeSidebar + +export const setActiveSidebar = (location, value) => { + const activeSidebar = getActiveSidebar(location) + + // first value (uninitialized): go, push state + if (activeSidebar === undefined) { + navigate(location.pathname, { + state: { activeSidebar: value }, + }) + } + // same value: go back + else if (activeSidebar === value) { + navigate(-1) + } + // new value: go, replace state + else { + navigate(location.pathname, { + state: { activeSidebar: value }, + replace: true, + }) + } +} + const Header = ({ location }) => { const [state, dispatch] = useContext(CartContext) const [miscState, miscDispatch] = useContext(MiscContext) - const getActiveSidebar = () => location.state?.activeSidebar - - const setActiveSidebar = (value) => { - const activeSidebar = getActiveSidebar() - - // first value (uninitialized): go, push state - if (activeSidebar === undefined) { - navigate(location.pathname, { - state: { activeSidebar: value }, - }) - } - // same value: go back - else if (activeSidebar === value) { - navigate(-1) - } - // new value: go, replace state - else { - navigate(location.pathname, { - state: { activeSidebar: value }, - replace: true, - }) - } - } - const Logo = () => - getActiveSidebar() ? ( + getActiveSidebar(location) ? ( ELSUPER @@ -56,7 +55,7 @@ const Header = ({ location }) => { setActiveSidebar("categoriesMenu")} + onClick={() => setActiveSidebar(location, "categoriesMenu")} > @@ -85,13 +84,13 @@ const Header = ({ location }) => { setActiveSidebar("userAccount")} + onClick={() => setActiveSidebar(location, "userAccount")} > setActiveSidebar("cart")} + onClick={() => setActiveSidebar(location, "cart")} /> ) diff --git a/src/components/product/productSummary.js b/src/components/product/productSummary.js index 9aa3a2d..fffd5db 100644 --- a/src/components/product/productSummary.js +++ b/src/components/product/productSummary.js @@ -61,7 +61,11 @@ const ProductSummary = (props) => { countInCart={countInCart} /> -

{nl2br(data.description)}

+ {/*

{nl2br(data.description)}

*/} +

+ En ELSUPER encuentras todo tipo de articulos para tu hogar y alacena. + Proximamente agregaremos una descripcion cool a este producto. +