/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import { useRef, useState } from "react"; import { observer } from "mobx-react"; import { useParams } from "next/navigation"; import useSWR from "swr"; // plane hooks import { useOutsideClickDetector } from "@plane/hooks"; // plane ui import { AddOutline, CloseOutline, MultipleStickyOutline, StickyNoteOutline } from "@makeplane/propel/icons"; import { PreviewCard, PreviewCardContent, PreviewCardTrigger } from "@makeplane/propel/components/preview-card"; import { Tooltip } from "@makeplane/propel/components/tooltip"; // plane utils import { cn } from "@plane/utils"; // hooks import { useCommandPalette } from "@/hooks/store/use-command-palette"; import { useSticky } from "@/hooks/use-stickies"; // components import { STICKY_COLORS_LIST } from "../editor/sticky-editor/color-palette"; import { AllStickiesModal } from "./modal"; import { StickyNote } from "./sticky"; export const StickyActionBar = observer(function StickyActionBar() { // states const [isExpanded, setIsExpanded] = useState(false); const [newSticky, setNewSticky] = useState(false); const [showRecentSticky, setShowRecentSticky] = useState(false); // navigation const { workspaceSlug } = useParams(); // refs const ref = useRef(null); // store hooks const { stickies, activeStickyId, recentStickyId, updateActiveStickyId, fetchRecentSticky, toggleShowNewSticky } = useSticky(); const { toggleAllStickiesModal, allStickiesModal } = useCommandPalette(); // derived values const recentStickyBackgroundColor = recentStickyId ? STICKY_COLORS_LIST.find((c) => c.key === stickies[recentStickyId].background_color)?.backgroundColor : STICKY_COLORS_LIST[0].backgroundColor; useSWR( workspaceSlug ? `WORKSPACE_STICKIES_RECENT_${workspaceSlug}` : null, workspaceSlug ? () => fetchRecentSticky(workspaceSlug.toString()) : null ); useOutsideClickDetector(ref, () => { setNewSticky(false); setShowRecentSticky(false); setIsExpanded(false); }); const recentStickyButton = ( ); return (