import { create } from 'zustand'; import type { MailProvider } from '../hooks/useMailConnect'; type ProviderSnapshot = { id: MailProvider; labelKey: string; icon: string; color: string; guideKey: string; guideUrl: string; disabled?: boolean; disabledLabelKey?: string; }; type MailConnectDraftState = { view: 'consent' | 'grid' | 'form'; consentGiven: boolean; selectedProvider: ProviderSnapshot | null; email: string; title: string; setView: (view: 'consent' | 'grid' | 'form') => void; setConsentGiven: (v: boolean) => void; setSelectedProvider: (p: ProviderSnapshot | null) => void; setEmail: (email: string) => void; setTitle: (title: string) => void; reset: () => void; }; const INITIAL: Pick< MailConnectDraftState, 'view' | 'consentGiven' | 'selectedProvider' | 'email' | 'title' > = { view: 'consent', consentGiven: false, selectedProvider: null, email: '', title: '', }; export const useMailConnectDraft = create((set) => ({ ...INITIAL, setView: (view) => set({ view }), setConsentGiven: (consentGiven) => set({ consentGiven }), setSelectedProvider: (selectedProvider) => set({ selectedProvider }), setEmail: (email) => set({ email }), setTitle: (title) => set({ title }), reset: () => set(INITIAL), }));