import { createSlice, createSelector } from "@reduxjs/toolkit";
import type { PayloadAction } from "@reduxjs/toolkit";

export interface ICompatibilityV3Answers {
    whatAspects: string;
    relationshipStatus: string;
    elementResonates: string;
    favoriteColor: string;
    headOrHeart: string;
    dateEvent: string;
    romanticGestures: string;
    checkingPhone: string;
}

const initialState: ICompatibilityV3Answers = {
    whatAspects: "",
    relationshipStatus: "",
    elementResonates: "",
    favoriteColor: "",
    headOrHeart: "",
    dateEvent: "",
    romanticGestures: "",
    checkingPhone: "",
};

const compatibilityV3AnswersSlice = createSlice({
    name: "compatibilityV3Answers",
    initialState,
    reducers: {
        update(state, action: PayloadAction<Partial<ICompatibilityV3Answers>>) {
            return { ...state, ...action.payload };
        },
    },
    extraReducers: (builder) => builder.addCase("reset", () => initialState),
});

export const { actions } = compatibilityV3AnswersSlice;
export const selectCompatibilityV3Answers = createSelector(
    (state: { compatibilityV3Answers: ICompatibilityV3Answers }) => state.compatibilityV3Answers,
    (compatibilityV3Answers) => compatibilityV3Answers
);
export default compatibilityV3AnswersSlice.reducer;
