import React, { useEffect } from "react"; import Image from "next/image"; import { useTheme } from "next-themes"; 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 { IWorkspace } from "@plane/types"; import { Avatar, DiceIcon, PhotoFilterIcon } from "@plane/ui"; // hooks import { useUser, useWorkspace } from "@/hooks/store"; // types import projectEmoji from "public/emoji/project-emoji.svg"; // assets 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; }; let timer: number = 0; let lastWorkspaceName: string = ""; export const OnboardingSidebar: React.FC = (props) => { const { workspaceName, showProject, control, setValue, watch, userFullName } = props; // store hooks const { currentUser } = useUser(); const { workspaces } = useWorkspace(); const workspaceDetails = Object.values(workspaces ?? {})?.[0]; const { resolvedTheme } = useTheme(); const handleZoomWorkspace = (value: string) => { 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 : workspaceDetails ? workspaceDetails.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}
))}
)}
); };