'use client' import { AlertTriangle, ArrowLeft } from 'lucide-react' import { type PropsWithChildren, forwardRef, useEffect, useState } from 'react' import { ErrorBoundary } from 'react-error-boundary' import { Button, Command_Shadcn_, Dialog, DialogContent, cn } from 'ui' import { useCurrentPage, usePageComponent, usePopPage } from './hooks/pagesHooks' import { useQuery, useSetQuery } from './hooks/queryHooks' import { useCommandMenuSize, useCommandMenuOpen, useSetCommandMenuOpen } from './hooks/viewHooks' import { PageType } from './utils' function Breadcrumb() { const currPage = useCurrentPage() const popPage = usePopPage() if (!currPage) return return (
{currPage.name}
) } const CommandWrapper = forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ children, className, ...props }, ref) => { const currPage = useCurrentPage() return ( {currPage?.type === PageType.Commands && } {children} ) }) CommandWrapper.displayName = Command_Shadcn_.displayName function CommandError({ resetErrorBoundary }: { resetErrorBoundary: () => void }) { return (

Sorry, looks like we're having some issues with the command menu!

Please try again in a bit.

) } function PageSwitch({ children }: PropsWithChildren) { const PageComponent = usePageComponent() return PageComponent ? : {children} } function CommandMenu({ children }: PropsWithChildren) { const open = useCommandMenuOpen() const setOpen = useSetCommandMenuOpen() const size = useCommandMenuSize() const page = useCurrentPage() const popPage = usePopPage() const query = useQuery() const setQuery = useSetQuery() return ( setOpen(false)} onEscapeKeyDown={(e) => { e.preventDefault() return query ? setQuery('') : page ? popPage() : setOpen(false) }} size={size} className={cn('place-self-start mx-auto top-24')} > {children} ) } export { CommandMenu, CommandWrapper }