import { create } from 'zustand'

export const FILTER_OPTIONS = [
  {
    id: 'all',
    label: '全体',
  },
  {
    id: 'completed',
    label: '回答完了',
  },
  {
    id: 'waiting',
    label: '回答待ち',
  },
]
export type FILTER_OPTIONS_ENUM = (typeof FILTER_OPTIONS)[number]['id']

type InquiryFilterState = {
  keyword: string
  filter: FILTER_OPTIONS_ENUM
  isMySurvey: string | null
  offset: number
  setKeyword: (keyword: string) => void
  setFilter: (filter: FILTER_OPTIONS_ENUM) => void
  setIsMySurvey: (isMySurvey: string | null) => void
  setOffset: (offset: number) => void
  reset: () => void
}

export const useInquiryFilterStore = create<InquiryFilterState>((set) => ({
  keyword: '',
  filter: 'all',
  isMySurvey: null,
  offset: 0,
  setKeyword: (keyword) => set({ keyword }),
  setFilter: (filter) => set({ filter }),
  setIsMySurvey: (isMySurvey) => set({ isMySurvey }),
  setOffset: (offset) => set({ offset }),
  reset: () => set({ keyword: '', filter: 'all', isMySurvey: null, offset: 0 }),
}))
