Files
mnote/wolai-frontend/src/store/comments-ui.ts
T
2026-02-01 08:47:40 +08:00

35 lines
858 B
TypeScript

"use client";
import { create } from "zustand";
export type CommentTarget = {
workspaceId: string;
documentId: string;
blockId: string | null;
};
interface CommentsUiState {
open: boolean;
target: CommentTarget | null;
openForPage: (args: { workspaceId: string; documentId: string }) => void;
openForBlock: (args: { workspaceId: string; documentId: string; blockId: string }) => void;
close: () => void;
}
export const useCommentsUiStore = create<CommentsUiState>((set) => ({
open: false,
target: null,
openForPage: ({ workspaceId, documentId }) =>
set({
open: true,
target: { workspaceId, documentId, blockId: null },
}),
openForBlock: ({ workspaceId, documentId, blockId }) =>
set({
open: true,
target: { workspaceId, documentId, blockId },
}),
close: () => set({ open: false }),
}));