"use client"; import { Canvas } from "./canvas"; import React, { createContext, useContext, useState } from "react"; import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels"; import { SettingsIcon, DragIcon } from "@repo/ui/icons"; import DraggableComponentsContainer from "./draggableComponent"; import Image from "next/image"; import { Label } from "@repo/ui/shadcn/label"; interface RectContextType { fullScreen: boolean; setFullScreen: React.Dispatch>; visible: boolean; setVisible: React.Dispatch>; id: string; } const RectContext = createContext(undefined); export const RectProvider = ({ id, children, }: { id: string; children: React.ReactNode; }) => { const [fullScreen, setFullScreen] = useState(false); const [visible, setVisible] = useState(true); const value = { id, fullScreen, setFullScreen, visible, setVisible, }; return {children}; }; export const useRect = () => { const context = useContext(RectContext); if (context === undefined) { throw new Error("useRect must be used within a RectProvider"); } return context; }; export function ResizaleLayout() { const { setVisible, fullScreen, setFullScreen } = useRect(); return (
{ l[0]! < 20 ? setVisible(false) : setVisible(true); }} className={` ${fullScreen ? "w-[calc(100vw-2rem)]" : "w-screen"} transition-all`} direction="horizontal" > { setTimeout(() => setFullScreen(false), 50); }} onCollapse={() => { setTimeout(() => setFullScreen(true), 50); }} defaultSize={30} collapsible={true} >
); } function DragIconContainer() { const { fullScreen } = useRect(); return (
drag-icon
); } function CanvasContainer() { const { fullScreen } = useRect(); return (
); } function SidePanelContainer() { const { fullScreen, visible } = useRect(); return (
Change Filters setting-icon
{visible ? ( ) : (

Need more space to show!

)}
); } function SidePanel() { const [content, setContent] = useState<{ context: string }[]>(); return ( <>
{ const search = FormData.get("search"); console.log(search); const res = await fetch("/api/canvasai", { method: "POST", body: JSON.stringify({ query: search }), }); const t = await res.json(); // @ts-expect-error TODO: fix this console.log(t.response.response); // @ts-expect-error TODO: fix this setContent(t.response.response); }} >
); } const content = [ { content: "Regional growth patterns diverge, with strong performance in the United States and several emerging markets, contrasted by weaker prospects in many advanced economies, particularly in Europe (World Economic Forum) (OECD). The rapid adoption of artificial intelligence (AI) is expected to drive productivity growth, especially in advanced economies, potentially mitigating labor shortages and boosting income levels in emerging markets (World Economic Forum) (OECD). However, ongoing geopolitical tensions and economic fragmentation are likely to maintain a level of uncertainty and volatility in the global economy (World Economic Forum.", iconAlt: "Autocomplete", extraInfo: "Page Url: https://chatgpt.com/c/762cd44e-1752-495b-967a-aa3c23c6024a", }, { content: "As of mid-2024, the global economy is experiencing modest growth with significant regional disparities. Global GDP growth is projected to be around 3.1% in 2024, rising slightly to 3.2% in 2025. This performance, although below the pre-pandemic average, reflects resilience despite various economic pressures, including tight monetary conditions and geopolitical tensions (IMF)(OECD) Inflation is moderating faster than expected, with global headline inflation projected to fall to 5.8% in 2024 and 4.4% in 2025, contributing to improving real incomes and positive trade growth (IMF) (OECD)", iconAlt: "Autocomplete", extraInfo: "Page Url: https://www.cnbc.com/2024/05/23/nvidia-keeps-hitting-records-can-investors-still-buy-the-stock.html?&qsearchterm=nvidia", }, ];