|
2 | 2 |
|
3 | 3 | import { useState, useEffect, createContext, useContext, useCallback } from 'react'
|
4 | 4 | import { TaskSidebar } from '@/components/task-sidebar'
|
5 |
| -import { Task } from '@/lib/db/schema' |
| 5 | +import { Task, Connector } from '@/lib/db/schema' |
6 | 6 | import { useRouter } from 'next/navigation'
|
7 | 7 | import { Button } from '@/components/ui/button'
|
8 | 8 | import { Plus } from 'lucide-react'
|
9 | 9 | import Link from 'next/link'
|
10 | 10 | import { getSidebarWidth, setSidebarWidth, getSidebarOpen, setSidebarOpen } from '@/lib/utils/cookies'
|
11 | 11 | import { nanoid } from 'nanoid'
|
| 12 | +import { ConnectorsProvider } from '@/components/connectors-provider' |
12 | 13 |
|
13 | 14 | interface AppLayoutProps {
|
14 | 15 | children: React.ReactNode
|
@@ -264,72 +265,74 @@ export function AppLayout({ children, initialSidebarWidth, initialSidebarOpen }:
|
264 | 265 |
|
265 | 266 | return (
|
266 | 267 | <TasksContext.Provider value={{ refreshTasks: fetchTasks, toggleSidebar, isSidebarOpen, addTaskOptimistically }}>
|
267 |
| - <div |
268 |
| - className="h-screen flex relative" |
269 |
| - style={ |
270 |
| - { |
271 |
| - '--sidebar-width': `${sidebarWidth}px`, |
272 |
| - '--sidebar-open': isSidebarOpen ? '1' : '0', |
273 |
| - } as React.CSSProperties |
274 |
| - } |
275 |
| - suppressHydrationWarning |
276 |
| - > |
277 |
| - {/* Backdrop - Mobile Only */} |
278 |
| - {isSidebarOpen && <div className="lg:hidden fixed inset-0 bg-black/50 z-30" onClick={closeSidebar} />} |
279 |
| - |
280 |
| - {/* Sidebar */} |
| 268 | + <ConnectorsProvider> |
281 | 269 | <div
|
282 |
| - className={` |
| 270 | + className="h-screen flex relative" |
| 271 | + style={ |
| 272 | + { |
| 273 | + '--sidebar-width': `${sidebarWidth}px`, |
| 274 | + '--sidebar-open': isSidebarOpen ? '1' : '0', |
| 275 | + } as React.CSSProperties |
| 276 | + } |
| 277 | + suppressHydrationWarning |
| 278 | + > |
| 279 | + {/* Backdrop - Mobile Only */} |
| 280 | + {isSidebarOpen && <div className="lg:hidden fixed inset-0 bg-black/50 z-30" onClick={closeSidebar} />} |
| 281 | + |
| 282 | + {/* Sidebar */} |
| 283 | + <div |
| 284 | + className={` |
283 | 285 | fixed inset-y-0 left-0 z-40
|
284 | 286 | ${isResizing ? '' : 'transition-all duration-300 ease-in-out'}
|
285 | 287 | ${isSidebarOpen ? 'translate-x-0' : '-translate-x-full'}
|
286 | 288 | ${isSidebarOpen ? 'pointer-events-auto' : 'pointer-events-none'}
|
287 | 289 | `}
|
288 |
| - style={{ |
289 |
| - width: `${sidebarWidth}px`, |
290 |
| - }} |
291 |
| - > |
292 |
| - <div |
293 |
| - className="h-full overflow-hidden" |
294 | 290 | style={{
|
295 | 291 | width: `${sidebarWidth}px`,
|
296 | 292 | }}
|
297 | 293 | >
|
298 |
| - {isLoading ? ( |
299 |
| - <SidebarLoader width={sidebarWidth} /> |
300 |
| - ) : ( |
301 |
| - <TaskSidebar tasks={tasks} onTaskSelect={handleTaskSelect} width={sidebarWidth} /> |
302 |
| - )} |
| 294 | + <div |
| 295 | + className="h-full overflow-hidden" |
| 296 | + style={{ |
| 297 | + width: `${sidebarWidth}px`, |
| 298 | + }} |
| 299 | + > |
| 300 | + {isLoading ? ( |
| 301 | + <SidebarLoader width={sidebarWidth} /> |
| 302 | + ) : ( |
| 303 | + <TaskSidebar tasks={tasks} onTaskSelect={handleTaskSelect} width={sidebarWidth} /> |
| 304 | + )} |
| 305 | + </div> |
303 | 306 | </div>
|
304 |
| - </div> |
305 | 307 |
|
306 |
| - {/* Resize Handle - Desktop Only, when sidebar is open */} |
307 |
| - <div |
308 |
| - className={` |
| 308 | + {/* Resize Handle - Desktop Only, when sidebar is open */} |
| 309 | + <div |
| 310 | + className={` |
309 | 311 | hidden lg:block fixed inset-y-0 cursor-col-resize group z-41 hover:bg-primary/20
|
310 | 312 | ${isResizing ? '' : 'transition-all duration-300 ease-in-out'}
|
311 | 313 | ${isSidebarOpen ? 'w-1 opacity-100' : 'w-0 opacity-0'}
|
312 | 314 | `}
|
313 |
| - onMouseDown={isSidebarOpen ? handleMouseDown : undefined} |
314 |
| - style={{ |
315 |
| - // Position it right after the sidebar |
316 |
| - left: isSidebarOpen ? `${sidebarWidth}px` : '0px', |
317 |
| - }} |
318 |
| - > |
319 |
| - <div className="absolute inset-0 w-2 -ml-0.5" /> |
320 |
| - <div className="absolute inset-y-0 left-0 w-0.5 bg-primary/50 opacity-0 group-hover:opacity-100 transition-opacity" /> |
321 |
| - </div> |
| 315 | + onMouseDown={isSidebarOpen ? handleMouseDown : undefined} |
| 316 | + style={{ |
| 317 | + // Position it right after the sidebar |
| 318 | + left: isSidebarOpen ? `${sidebarWidth}px` : '0px', |
| 319 | + }} |
| 320 | + > |
| 321 | + <div className="absolute inset-0 w-2 -ml-0.5" /> |
| 322 | + <div className="absolute inset-y-0 left-0 w-0.5 bg-primary/50 opacity-0 group-hover:opacity-100 transition-opacity" /> |
| 323 | + </div> |
322 | 324 |
|
323 |
| - {/* Main Content */} |
324 |
| - <div |
325 |
| - className={`flex-1 overflow-auto flex flex-col lg:ml-0 ${isResizing ? '' : 'transition-all duration-300 ease-in-out'}`} |
326 |
| - style={{ |
327 |
| - marginLeft: isSidebarOpen ? `${sidebarWidth + 4}px` : '0px', |
328 |
| - }} |
329 |
| - > |
330 |
| - {children} |
| 325 | + {/* Main Content */} |
| 326 | + <div |
| 327 | + className={`flex-1 overflow-auto flex flex-col lg:ml-0 ${isResizing ? '' : 'transition-all duration-300 ease-in-out'}`} |
| 328 | + style={{ |
| 329 | + marginLeft: isSidebarOpen ? `${sidebarWidth + 4}px` : '0px', |
| 330 | + }} |
| 331 | + > |
| 332 | + {children} |
| 333 | + </div> |
331 | 334 | </div>
|
332 |
| - </div> |
| 335 | + </ConnectorsProvider> |
333 | 336 | </TasksContext.Provider>
|
334 | 337 | )
|
335 | 338 | }
|
0 commit comments