import { UniformitySlice } from '@/types/stores';
import { StateCreator } from 'zustand';

export const createUniformitySlice: StateCreator<
  UniformitySlice,
  [],
  [],
  UniformitySlice
> = (set) => ({
  // Initial state
  uniformityStep: 'preview',
  verifyUniformityResult: null,
  uniformityFormData: null,
  isSuccess: false,
  createdUniformity: null,

  // Actions
  setUniformityStep: (step) => set({ uniformityStep: step }),

  setVerifyUniformityResult: (result) =>
    set({ verifyUniformityResult: result }),

  setUniformityFormData: (data) => set({ uniformityFormData: data }),

  setIsSuccess: (success) => set({ isSuccess: success }),

  setCreatedUniformity: (data) => set({ createdUniformity: data }),

  resetUniformity: () =>
    set({
      uniformityStep: 'preview',
      verifyUniformityResult: null,
      uniformityFormData: null,
      isSuccess: false,
      createdUniformity: null,
    }),
});
