FunctionsNav.tsx 832 B

123456789101112131415161718192021222324252627282930
  1. import { useRouter } from 'next/router'
  2. import { Tabs } from 'ui'
  3. const FunctionsNav = ({ item }: any) => {
  4. const router = useRouter()
  5. const activeRoute = router.pathname.split('/')[5]
  6. const { ref } = router.query
  7. return (
  8. <Tabs
  9. defaultActiveId="1"
  10. type="underlined"
  11. size="medium"
  12. baseClassNames="space-y-0!"
  13. activeId={!activeRoute ? 'overview' : activeRoute}
  14. onChange={(e: string) => {
  15. if (item?.slug) {
  16. router.push(`/project/${ref}/functions/${item.slug}/${e === 'overview' ? '' : e}`)
  17. }
  18. }}
  19. >
  20. <Tabs.Panel id="overview" label="Overview" />
  21. <Tabs.Panel id="invocations" label="Invocations" />
  22. <Tabs.Panel id="logs" label="Logs" />
  23. <Tabs.Panel id="details" label="Details" />
  24. </Tabs>
  25. )
  26. }
  27. export default FunctionsNav