Skip to content

Turn meetings into live agent loops. Record, transcribe, and analyze meetings with real-time AI intelligence — before, during, and after calls.

2.4 KB
Raw Blame
import { create } from 'zustand';
import type { ProbingQuestion } from '../../shared/types/meeting-setup.types';

export type MeetingSetupStep = 'sources' | 'info' | 'questions' | 'checklist' | 'ready';

interface MeetingSetupState {
  step: MeetingSetupStep;
  name: string;
  description: string;
  questions: ProbingQuestion[];
  checklist: string[];
  isGenerating: boolean;
  error: string | null;

  // Actions
  setStep: (step: MeetingSetupStep) => void;
  setInfo: (name: string, description: string) => void;
  setQuestions: (questions: ProbingQuestion[]) => void;
  setQuestionAnswer: (index: number, answer: string, customAnswer?: string) => void;
  setChecklist: (checklist: string[]) => void;
  setIsGenerating: (isGenerating: boolean) => void;
  setError: (error: string | null) => void;
  reset: () => void;

  // Computed helpers
  isSetupComplete: () => boolean;
  getMeetingSetupData: () => {
    name: string;
    description: string;
    questions: ProbingQuestion[];
    checklist: string[];
  };
}

const initialState = {
  step: 'sources' as MeetingSetupStep,
  name: '',
  description: '',
  questions: [] as ProbingQuestion[],
  checklist: [] as string[],
  isGenerating: false,
  error: null as string | null,
};

export const useMeetingSetupStore = create<MeetingSetupState>((set, get) => ({
  ...initialState,

  setStep: (step) => set({ step, error: null }),

  setInfo: (name, description) => set({ name, description }),

  setQuestions: (questions) => set({ questions }),

  setQuestionAnswer: (index, answer, customAnswer) => {
    const questions = [...get().questions];
    if (questions[index]) {
      questions[index] = {
        ...questions[index],
        answer,
        customAnswer,
      };
      set({ questions });
    }
  },

  setChecklist: (checklist) => set({ checklist }),

  setIsGenerating: (isGenerating) => set({ isGenerating }),

  setError: (error) => set({ error }),

  reset: () => set(initialState),

  isSetupComplete: () => {
    const state = get();
    return (
      state.name.trim().length > 0 &&
      state.description.trim().length > 0 &&
      state.questions.length > 0 &&
      state.checklist.length > 0
    );
  },

  getMeetingSetupData: () => {
    const state = get();
    return {
      name: state.name,
      description: state.description,
      questions: state.questions,
      checklist: state.checklist,
    };
  },
}));