/* eslint-disable no-prototype-builtins */ import React, { useEffect, useState } from "react"; import { MenuItemProps, SubMenuItemProps } from "../DynamicMenu"; import { Link } from "vtex.render-runtime"; import styles from "./MenuItemMobile.css"; const MenuItemMobile: React.FC = ({ href, title, content, internal, items, }: MenuItemProps) => { const [subMenuItems, setSubMenuItems] = useState([]); const [showSubMenu, setShowSubMenu] = useState(false); const standardizeSubItems = () => { const newItems = items?.map((item) => { if (item.hasOwnProperty("SubMenuItemProps")) { return item.SubMenuItemProps; } return item; }); setSubMenuItems(newItems as []); }; useEffect(() => { if (items) { standardizeSubItems(); } }, [items]); return ( <>
{subMenuItems.length === 0 ? ( {title} ) : ( )} {subMenuItems && (
{title}
    {subMenuItems.map((item, i) => { let isNextItemHighlight = false; if (i > 0 || i !== subMenuItems.length) { isNextItemHighlight = subMenuItems[i + 1] ?.highlight ? true : false; } return ( <>
  • { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore Location.reload(); }} > {item.title}
  • {isNextItemHighlight && (
  •  
  • )} ); })}
)}
); }; export { MenuItemMobile };