import React from "react"; import { useRouteError } from "react-router"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism"; import { FileExplorer } from "#/components/features/file-explorer/file-explorer"; import { useFiles } from "#/context/files"; export function ErrorBoundary() { const error = useRouteError(); return (

Oops! An error occurred!

{error instanceof Error &&
{error.message}
}
); } function getLanguageFromPath(path: string): string { const extension = path.split(".").pop()?.toLowerCase(); switch (extension) { case "js": case "jsx": return "javascript"; case "ts": case "tsx": return "typescript"; case "py": return "python"; case "html": return "html"; case "css": return "css"; case "json": return "json"; case "md": return "markdown"; case "yml": case "yaml": return "yaml"; case "sh": case "bash": return "bash"; case "dockerfile": return "dockerfile"; case "rs": return "rust"; case "go": return "go"; case "java": return "java"; case "cpp": case "cc": case "cxx": return "cpp"; case "c": return "c"; case "rb": return "ruby"; case "php": return "php"; case "sql": return "sql"; default: return "text"; } } function FileViewer() { const [fileExplorerIsOpen, setFileExplorerIsOpen] = React.useState(true); const { selectedPath, files } = useFiles(); const toggleFileExplorer = () => { setFileExplorerIsOpen((prev) => !prev); }; return (
{selectedPath && (
{selectedPath}
)} {selectedPath && files[selectedPath] && (
{files[selectedPath]}
)}
); } export default FileViewer;