import { createSlice } from "@reduxjs/toolkit";

const initialState = {
  age: [18, 70],
  height: [4.0, 7.11],
  maritalStatus: "All Profile",
  motherTongue: [],
  religion: "Hindu",
  matchesWithHoroscope: false,
  caste: [],
  subCaste: [],
  star: "Any",
  dasham: "Doesn't matter",
  occupation: "Any",
  annualIncome: "Any",
  employeeType: "Any",
  education: "Any",
  state: "Any",
  country: "Any",
  citizenship: "Any",
  eatingHabits: "Any",
  smokingHabits: "Doesn't matter",
  drinkingHabits: "Doesn't matter",
  familyType: "Any",
  familyStatus: "Any",
  familyValue: "Any",
};

const filterSlice = createSlice({
  name: "filters",
  initialState,
  reducers: {
    setAge: (state, action) => {
      state.age = action.payload;
    },
    setHeight: (state, action) => {
      state.height = action.payload;
    },
    setMaritalStatus: (state, action) => {
      state.maritalStatus = action.payload;
    },
    setMotherTongue: (state, action) => {
      state.motherTongue = action.payload;
    },
    setReligion: (state, action) => {
      state.religion = action.payload;
    },
    setMatchesWithHoroscope: (state, action) => {
      state.matchesWithHoroscope = action.payload;
    },
    setCaste: (state, action) => {
      state.caste = action.payload;
    },
    setSubCaste: (state, action) => {
      state.subCaste = action.payload;
    },
    setStar: (state, action) => {
      state.star = action.payload;
    },
    setDasham: (state, action) => {
      state.dasham = action.payload;
    },
    setOccupation: (state, action) => {
      state.occupation = action.payload;
    },
    setAnnualIncome: (state, action) => {
      state.annualIncome = action.payload;
    },
    setEmployeeType: (state, action) => {
      state.employeeType = action.payload;
    },
    setEducation: (state, action) => {
      state.education = action.payload;
    },
    setState: (state, action) => {
      state.state = action.payload;
    },
    setCountry: (state, action) => {
      state.country = action.payload;
    },
    setCitizenship: (state, action) => {
      state.citizenship = action.payload;
    },
    setEatingHabits: (state, action) => {
      state.eatingHabits = action.payload;
    },
    setSmokingHabits: (state, action) => {
      state.smokingHabits = action.payload;
    },
    setDrinkingHabits: (state, action) => {
      state.drinkingHabits = action.payload;
    },
    setFamilyType: (state, action) => {
      state.familyType = action.payload;
    },
    setFamilyStatus: (state, action) => {
      state.familyStatus = action.payload;
    },
    setFamilyValue: (state, action) => {
      state.familyValue = action.payload;
    },

    // universal update
    updateFilter: (state, action) => {
      return { ...state, ...action.payload };
    },

    resetFilters: () => initialState,
  },
});

export const {
  setAge,
  setHeight,
  setMaritalStatus,
  setMotherTongue,
  setReligion,
  setMatchesWithHoroscope,
  setCaste,
  setSubCaste,
  setStar,
  setDasham,
  setOccupation,
  setAnnualIncome,
  setEmployeeType,
  setEducation,
  setState,
  setCountry,
  setCitizenship,
  setEatingHabits,
  setSmokingHabits,
  setDrinkingHabits,
  setFamilyType,
  setFamilyStatus,
  setFamilyValue,
  updateFilter,
  resetFilters,
} = filterSlice.actions;

export default filterSlice.reducer;
