File size: 2,763 Bytes
65d68f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"use client";

import type { ComponentProps, RefObject } from "react";
import type { ApiDocument } from "@/lib/api/types";
import type { StudyIntent } from "@/lib/study-intents";
import { ConversationWorkspace } from "./ConversationWorkspace";
import { EmptyStudyWorkspace } from "./EmptyStudyWorkspace";
import { StudyComposer } from "./StudyComposer";
import { MobileTopBar } from "./WorkspacePanels";
import type { ChatMessage, StudyActionHandler } from "./types";

type MainWorkspaceProps = {
  activeIntent: StudyIntent;
  composerProps: ComponentProps<typeof StudyComposer>;
  documents: ApiDocument[];
  heroSubtitle: string;
  heroTitle: string;
  isLoading: boolean;
  messages: ChatMessage[];
  onAction: StudyActionHandler;
  onClearSources: () => void;
  onNewChat: () => void;
  onOpenProfile: () => void;
  onOpenSources: () => void;
  onStartRender?: (topic: string, sourceId: string | null, minutes: number) => void;
  onToggleSource: (sourceId: string) => void;
  onUpload?: () => void;
  selectedDocuments: ApiDocument[];
  studentName: string;
  threadEndRef: RefObject<HTMLDivElement | null>;
};

export function MainWorkspace({
  activeIntent,
  composerProps,
  documents,
  heroSubtitle,
  heroTitle,
  isLoading,
  messages,
  onAction,
  onClearSources,
  onNewChat,
  onOpenProfile,
  onOpenSources,
  onStartRender,
  onToggleSource,
  onUpload,
  selectedDocuments,
  studentName,
  threadEndRef,
}: MainWorkspaceProps) {
  return (
    <main className="relative flex min-h-0 min-w-0 flex-col overflow-hidden">
      <MobileTopBar
        selectedCount={selectedDocuments.length}
        onOpenSources={onOpenSources}
        onOpenProfile={onOpenProfile}
      />

      {messages.length === 0 ? (
        <EmptyStudyWorkspace
          activeIntent={activeIntent}
          composerProps={composerProps}
          documents={documents}
          heroSubtitle={heroSubtitle}
          heroTitle={heroTitle}
          isLoading={isLoading}
          onAction={onAction}
          onClearSources={onClearSources}
          onToggleSource={onToggleSource}
          onUpload={onUpload}
          selectedDocuments={selectedDocuments}
          studentName={studentName}
        />
      ) : (
        <ConversationWorkspace
          activeIntent={activeIntent}
          composerProps={composerProps}
          documents={documents}
          isLoading={isLoading}
          messages={messages}
          onAction={onAction}
          onClearSources={onClearSources}
          onNewChat={onNewChat}
          onStartRender={onStartRender}
          onToggleSource={onToggleSource}
          onUpload={onUpload}
          selectedDocuments={selectedDocuments}
          threadEndRef={threadEndRef}
        />
      )}
    </main>
  );
}