import React, { useEffect } from "react"; import { useTheme } from "next-themes"; import Image from "next/image"; import { Control, Controller, UseFormSetValue, UseFormWatch } from "react-hook-form"; import { BarChart2, Briefcase, CheckCircle, ChevronDown, ContrastIcon, FileText, LayersIcon, LayoutGrid, PenSquare, Search, Settings, Bell, } from "lucide-react"; import { Avatar, DiceIcon, PhotoFilterIcon } from "@plane/ui"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // types import { IWorkspace } from "types"; // assets import projectEmoji from "public/emoji/project-emoji.svg"; const workspaceLinks = [ { Icon: LayoutGrid, name: "Dashboard", }, { Icon: BarChart2, name: "Analytics", }, { Icon: Briefcase, name: "Projects", }, { Icon: CheckCircle, name: "All Issues", }, { Icon: Bell, name: "Notifications", }, ]; const projectLinks = [ { name: "Issues", Icon: LayersIcon, }, { name: "Cycles", Icon: ContrastIcon, }, { name: "Modules", Icon: DiceIcon, }, { name: "Views", Icon: PhotoFilterIcon, }, { name: "Pages", Icon: FileText, }, { name: "Settings", Icon: Settings, }, ]; type Props = { workspaceName: string; showProject: boolean; control?: Control; setValue?: UseFormSetValue; watch?: UseFormWatch; userFullName?: string; }; var timer: number = 0; var lastWorkspaceName: string = ""; export const OnboardingSidebar: React.FC = (props) => { const { workspaceName, showProject, control, setValue, watch, userFullName } = props; const { workspace: workspaceStore, user: { currentUser }, } = useMobxStore(); const workspace = workspaceStore.workspaces ? workspaceStore.workspaces[0] : null; const { resolvedTheme } = useTheme(); const handleZoomWorkspace = (value: string) => { // console.log(lastWorkspaceName,value); if (lastWorkspaceName === value) return; lastWorkspaceName = value; if (timer > 0) { timer += 2; timer = Math.min(timer, 2); } else { timer = 2; timer = Math.min(timer, 2); const interval = setInterval(() => { if (timer < 0) { setValue!("name", lastWorkspaceName); clearInterval(interval); } timer--; }, 1000); } }; useEffect(() => { if (watch) { watch("name"); } }); return (
{control && setValue ? ( { if (value.length > 0) { handleZoomWorkspace(value); } else { lastWorkspaceName = ""; } return timer > 0 ? (
0 ? value : "New Workspace"} src={""} size={30} shape="square" fallbackBackgroundColor="black" className="!text-base capitalize" />
{value}
) : (
0 ? value : workspace ? workspace.name : "New Workspace"} src={""} size={24} shape="square" fallbackBackgroundColor="black" className="!text-base capitalize" />

{workspaceName}

); }} /> ) : (

{workspaceName}

)}
{New Issue}
{workspaceLinks.map((link) => (
{} {link.name}
))}
{showProject && (

Projects

{" "}
Plane Logo Plane
{projectLinks.map((link) => (
{} {link.name}
))}
)}
); };