import { useState, useRef, FC } from "react"; import { useRouter } from "next/router"; import Link from "next/link"; import useSWR from "swr"; // headless ui import { Transition } from "@headlessui/react"; // hooks import useTheme from "hooks/use-theme"; import useOutsideClickDetector from "hooks/use-outside-click-detector"; // icons import { ArrowLongLeftIcon, ChatBubbleOvalLeftEllipsisIcon, RocketLaunchIcon, ArrowUpCircleIcon, XMarkIcon, } from "@heroicons/react/24/outline"; import { QuestionMarkCircleIcon, DocumentIcon, DiscordIcon, GithubIcon } from "components/icons"; // services import workspaceService from "services/workspace.service"; // fetch-keys import { WORKSPACE_DETAILS } from "constants/fetch-keys"; // ui import { CircularProgress } from "components/ui"; // components import UpgradeToProModal from "./upgrade-to-pro-modal"; import useUser from "hooks/use-user"; const helpOptions = [ { name: "Documentation", href: "https://docs.plane.so/", Icon: DocumentIcon, }, { name: "Join our Discord", href: "https://discord.com/invite/A92xrEGCge", Icon: DiscordIcon, }, { name: "Report a bug", href: "https://github.com/makeplane/plane/issues/new/choose", Icon: GithubIcon, }, { name: "Chat with us", href: null, onClick: () => (window as any).$crisp.push(["do", "chat:show"]), Icon: ChatBubbleOvalLeftEllipsisIcon, }, ]; export interface WorkspaceHelpSectionProps { setSidebarActive: React.Dispatch>; } type progress = { progress: number; }; export const WorkspaceHelpSection: FC = (props) => { // router const router = useRouter(); const { workspaceSlug } = router.query; const { setSidebarActive } = props; // theme const { collapsed: sidebarCollapse, toggleCollapsed } = useTheme(); // states const [isNeedHelpOpen, setIsNeedHelpOpen] = useState(false); // refs const helpOptionsRef = useRef(null); // hooks useOutsideClickDetector(helpOptionsRef, () => setIsNeedHelpOpen(false)); const { user } = useUser(); const helpOptionMode = sidebarCollapse ? "left-full" : "left-[-75px]"; const [alert, setAlert] = useState(false); const [upgradeModal, setUpgradeModal] = useState(false); const { data: workspaceDetails } = useSWR( workspaceSlug ? WORKSPACE_DETAILS(workspaceSlug as string) : null, workspaceSlug ? () => workspaceService.getWorkspace(workspaceSlug as string) : null ); const issueNumber = workspaceDetails?.total_issues || 0; return ( <> setUpgradeModal(false)} user={user} issueNumber={issueNumber} /> {!sidebarCollapse && (alert || (issueNumber && issueNumber >= 750)) ? ( <>
= 750 ? "bg-red-50 text-red-600 border-red-200" : issueNumber >= 500 ? "bg-yellow-50 text-yellow-600 border-yellow-200" : "text-green-600" }`} >
Free Plan
{issueNumber < 750 && (
setAlert(false)}>
)}
This workspace has used {issueNumber} of its 1024 issues creation limit ( {((issueNumber / 1024) * 100).toFixed(0)} %).
) : ( "" )}
{alert || (issueNumber && issueNumber >= 750) ? ( ) : ( )}
{helpOptions.map(({ name, Icon, href, onClick }) => { if (href) return ( {name} ); else return ( ); })}
); };