-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMainLayout.tsx
More file actions
105 lines (90 loc) · 3.71 KB
/
MainLayout.tsx
File metadata and controls
105 lines (90 loc) · 3.71 KB
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
97
98
99
100
101
102
103
104
105
import { ConnectivityPrompt } from "@components/ConnectivityPrompt";
import { HeaderRow } from "@components/HeaderRow";
import { HedgehogMode } from "@components/HedgehogMode";
import { KeyboardShortcutsSheet } from "@components/KeyboardShortcutsSheet";
import { ArchivedTasksView } from "@features/archive/components/ArchivedTasksView";
import { CommandMenu } from "@features/command/components/CommandMenu";
import { CommandCenterView } from "@features/command-center/components/CommandCenterView";
import { InboxView } from "@features/inbox/components/InboxView";
import { FolderSettingsView } from "@features/settings/components/FolderSettingsView";
import { SettingsDialog } from "@features/settings/components/SettingsDialog";
import { MainSidebar } from "@features/sidebar/components/MainSidebar";
import { SkillsView } from "@features/skills/components/SkillsView";
import { TaskDetail } from "@features/task-detail/components/TaskDetail";
import { TaskInput } from "@features/task-detail/components/TaskInput";
import { useTasks } from "@features/tasks/hooks/useTasks";
import { useConnectivity } from "@hooks/useConnectivity";
import { useIntegrations } from "@hooks/useIntegrations";
import { Box, Flex } from "@radix-ui/themes";
import { useCommandMenuStore } from "@stores/commandMenuStore";
import { useNavigationStore } from "@stores/navigationStore";
import { useShortcutsSheetStore } from "@stores/shortcutsSheetStore";
import { useCallback, useEffect } from "react";
import { useTaskDeepLink } from "../hooks/useTaskDeepLink";
import { GlobalEventHandlers } from "./GlobalEventHandlers";
export function MainLayout() {
const { view, hydrateTask, navigateToTaskInput } = useNavigationStore();
const {
isOpen: commandMenuOpen,
setOpen: setCommandMenuOpen,
toggle: toggleCommandMenu,
} = useCommandMenuStore();
const {
isOpen: shortcutsSheetOpen,
toggle: toggleShortcutsSheet,
close: closeShortcutsSheet,
} = useShortcutsSheetStore();
const { data: tasks } = useTasks();
const { showPrompt, isChecking, check, dismiss } = useConnectivity();
useIntegrations();
useTaskDeepLink();
useEffect(() => {
if (tasks) {
hydrateTask(tasks);
}
}, [tasks, hydrateTask]);
useEffect(() => {
if (view.type === "task-detail" && !view.data && !view.taskId) {
navigateToTaskInput();
}
}, [view, navigateToTaskInput]);
const handleToggleCommandMenu = useCallback(() => {
toggleCommandMenu();
}, [toggleCommandMenu]);
return (
<Flex direction="column" height="100vh">
<HeaderRow />
<Flex flexGrow="1" overflow="hidden">
<MainSidebar />
<Box flexGrow="1" overflow="hidden">
{view.type === "task-input" && <TaskInput />}
{view.type === "task-detail" && view.data && (
<TaskDetail key={view.data.id} task={view.data} />
)}
{view.type === "folder-settings" && <FolderSettingsView />}
{view.type === "inbox" && <InboxView />}
{view.type === "archived" && <ArchivedTasksView />}
{view.type === "command-center" && <CommandCenterView />}
{view.type === "skills" && <SkillsView />}
</Box>
</Flex>
<CommandMenu open={commandMenuOpen} onOpenChange={setCommandMenuOpen} />
<KeyboardShortcutsSheet
open={shortcutsSheetOpen}
onOpenChange={(open) => (open ? null : closeShortcutsSheet())}
/>
<ConnectivityPrompt
open={showPrompt}
isChecking={isChecking}
onRetry={check}
onDismiss={dismiss}
/>
<GlobalEventHandlers
onToggleCommandMenu={handleToggleCommandMenu}
onToggleShortcutsSheet={toggleShortcutsSheet}
/>
<SettingsDialog />
<HedgehogMode />
</Flex>
);
}