import { Box, Flex, Link, Select } from "@theme-ui/components" import React, { useContext } from "react" import ChevronDown from "./icons/chevron-down" import GitHub from "../components/icons/github" import NavigationContext from "../context/navigation-context" import Search from "./search" import { convertToKebabCase } from "../utils/convert-to-kebab-case" import { navigate } from "gatsby-link" const Topbar = ({ data, api }) => { const { goTo, reset, currentSection } = useContext(NavigationContext) const handleChange = e => { const parts = e.target.value.split(" ") if (parts[0] === api) { //find section let sectionObj = data.sections.find((s) => convertToKebabCase(s.section.section_name) === parts[1]); sectionObj = sectionObj ? sectionObj.section : {}; goTo({ section: parts[1], sectionObj }) } else { reset() navigate(`/api/${api === "admin" ? "store" : "admin"}`) } } return ( Docs ) } export default Topbar