|
1 | | -import React, { useState, useEffect, useRef } from "react"; |
2 | | -import { InterviewPattern } from "../interviews/types"; |
| 1 | +import React, {useEffect, useRef, useState} from "react"; |
| 2 | +import {InterviewPattern} from "@/interviews/types"; |
| 3 | +import {setupRoutes} from "@/server"; |
3 | 4 | import Instructions from "./Instructions"; |
4 | 5 | import CodingChallengeWrapper from "./CodingChallengeWrapper"; |
5 | 6 | import CodeReviewInterface from "./CodeReviewInterface"; |
6 | 7 | import "./InterviewShell.css"; |
7 | | -import { Button } from "./ui/button"; |
8 | | -import { ArrowLeftIcon } from "lucide-react"; |
9 | | -import { ThemeSwitcher } from "./theme-switcher"; |
10 | | -import { Badge } from "./ui/badge"; |
| 8 | +import {Button} from "./ui/button"; |
| 9 | +import {ThemeSwitcher} from "./theme-switcher"; |
| 10 | +import {Badge} from "./ui/badge"; |
11 | 11 | import { |
12 | 12 | Breadcrumb, |
13 | | - BreadcrumbList, |
14 | 13 | BreadcrumbItem, |
15 | 14 | BreadcrumbLink, |
16 | | - BreadcrumbSeparator, |
| 15 | + BreadcrumbList, |
17 | 16 | BreadcrumbPage, |
| 17 | + BreadcrumbSeparator, |
18 | 18 | } from "@/components/ui/breadcrumb"; |
19 | 19 | import { |
20 | 20 | Sidebar, |
21 | 21 | SidebarContent, |
22 | | - SidebarGroup, |
23 | | - SidebarGroupLabel, |
24 | | - SidebarGroupContent, |
25 | | - SidebarMenu, |
26 | | - SidebarMenuItem, |
27 | | - SidebarMenuButton, |
28 | | - SidebarProvider, |
29 | 22 | SidebarInset, |
| 23 | + SidebarProvider, |
30 | 24 | SidebarTrigger, |
31 | 25 | useSidebar, |
32 | 26 | } from "@/components/ui/sidebar"; |
33 | | -import { Separator } from "./ui/separator"; |
| 27 | +import {Separator} from "./ui/separator"; |
34 | 28 |
|
35 | 29 | interface InterviewShellProps { |
36 | 30 | pattern: InterviewPattern; |
@@ -108,6 +102,15 @@ const SIDEBAR_OPEN_KEY_PREFIX = "sidebar-open-"; |
108 | 102 | const InterviewShell: React.FC<InterviewShellProps> = ({ pattern, onBack }) => { |
109 | 103 | const [showInstructions, setShowInstructions] = useState(false); |
110 | 104 | const [hasViewedInstructions, setHasViewedInstructions] = useState(false); |
| 105 | + const [serverReady, setServerReady] = useState(!pattern.routes?.length); |
| 106 | + |
| 107 | + // Initialize mock API server if the pattern declares routes |
| 108 | + useEffect(() => { |
| 109 | + if (pattern.routes?.length) { |
| 110 | + setServerReady(false); |
| 111 | + setupRoutes(pattern.routes).then(() => setServerReady(true)); |
| 112 | + } |
| 113 | + }, [pattern]); |
111 | 114 | const [sidebarWidth, setSidebarWidth] = useState(640); // 40rem in pixels |
112 | 115 | const [isDragging, setIsDragging] = useState(false); |
113 | 116 | const sidebarRef = useRef<HTMLDivElement>(null); |
@@ -252,7 +255,11 @@ const InterviewShell: React.FC<InterviewShellProps> = ({ pattern, onBack }) => { |
252 | 255 | </div> |
253 | 256 | </header> |
254 | 257 | <main className="bg-white flex-1 overflow-y-auto"> |
255 | | - {showInstructions && pattern.readmes ? ( |
| 258 | + {!serverReady ? ( |
| 259 | + <div className="flex items-center justify-center h-full text-muted-foreground"> |
| 260 | + Starting server... |
| 261 | + </div> |
| 262 | + ) : showInstructions && pattern.readmes ? ( |
256 | 263 | <Instructions |
257 | 264 | readmes={pattern.readmes} |
258 | 265 | onClose={() => setShowInstructions(false)} |
|
0 commit comments