import { create } from 'zustand';

export type PendingConsentConnection = {
  id: string;
  email: string;
};

type MailConsentState = {
  visible: boolean;
  connections: PendingConsentConnection[];
  show: (connections: PendingConsentConnection[]) => void;
  hide: () => void;
  markConsented: () => void;
  reset: () => void;
};

export const useMailConsentStore = create<MailConsentState>((set) => ({
  visible: false,
  connections: [],

  show: (connections) => set({ visible: true, connections }),
  hide: () => set({ visible: false }),
  markConsented: () => set({ visible: false, connections: [] }),
  reset: () => set({ visible: false, connections: [] }),
}));
