mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-16 22:59:04 +02:00
- Add zustand draft store with localStorage persistence - Restore draft fields when reopening create-issue modal - Clear draft only on successful submission - Show brand-colored dot on sidebar new-issue button when draft exists Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { create } from "zustand";
|
|
import { persist } from "zustand/middleware";
|
|
import type { IssueStatus, IssuePriority, IssueAssigneeType } from "@/shared/types";
|
|
|
|
interface IssueDraft {
|
|
title: string;
|
|
description: string;
|
|
status: IssueStatus;
|
|
priority: IssuePriority;
|
|
assigneeType?: IssueAssigneeType;
|
|
assigneeId?: string;
|
|
dueDate: string | null;
|
|
}
|
|
|
|
const EMPTY_DRAFT: IssueDraft = {
|
|
title: "",
|
|
description: "",
|
|
status: "todo",
|
|
priority: "none",
|
|
assigneeType: undefined,
|
|
assigneeId: undefined,
|
|
dueDate: null,
|
|
};
|
|
|
|
interface IssueDraftStore {
|
|
draft: IssueDraft;
|
|
setDraft: (patch: Partial<IssueDraft>) => void;
|
|
clearDraft: () => void;
|
|
hasDraft: () => boolean;
|
|
}
|
|
|
|
export const useIssueDraftStore = create<IssueDraftStore>()(
|
|
persist(
|
|
(set, get) => ({
|
|
draft: { ...EMPTY_DRAFT },
|
|
setDraft: (patch) =>
|
|
set((s) => ({ draft: { ...s.draft, ...patch } })),
|
|
clearDraft: () => set({ draft: { ...EMPTY_DRAFT } }),
|
|
hasDraft: () => {
|
|
const { draft } = get();
|
|
return !!(draft.title || draft.description);
|
|
},
|
|
}),
|
|
{ name: "multica_issue_draft" },
|
|
),
|
|
);
|