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

export interface ICompatibilityV4Answers {
    whatAspects: string;
    relationshipStatus: string;
    calculateInAdvance: string;
    elementResonates: string;
    favoriteColor: string;
    headOrHeart: string;
    dateEvent: string;
    romanticGestures: string;
    checkingPhone: string;
    partnerPassword: string;
    yourFear: string;
    yourInclination: string;
    complexRelationshipAspect: string;
    birthplace: string;
    birthplacePartner: string;
    potentialPartnerName: string;
    potentialPartnerBirthdate: string;
    formerPartnerName: string;
    formerPartnerBirthdate: string;
    birthtime: string;
    resultAnalysis: string;
    partnerSimilarity: string;
    stressResponse: string;
    whatAddToAnalysis: string;
}

const initialState: ICompatibilityV4Answers = {
    whatAspects: "",
    relationshipStatus: "",
    calculateInAdvance: "",
    elementResonates: "",
    favoriteColor: "",
    headOrHeart: "",
    dateEvent: "",
    romanticGestures: "",
    checkingPhone: "",
    partnerPassword: "",
    yourFear: "",
    yourInclination: "",
    complexRelationshipAspect: "",
    birthplace: "",
    birthplacePartner: "",
    potentialPartnerName: "",
    potentialPartnerBirthdate: "",
    formerPartnerName: "",
    formerPartnerBirthdate: "",
    birthtime: "12:00",
    resultAnalysis: "",
    partnerSimilarity: "",
    stressResponse: "",
    whatAddToAnalysis: "",
};

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

export const { actions } = compatibilityV4AnswersSlice;
export const selectCompatibilityV4Answers = createSelector(
    (state: { compatibilityV4Answers: ICompatibilityV4Answers }) => state.compatibilityV4Answers,
    (compatibilityV4Answers) => compatibilityV4Answers
);
export default compatibilityV4AnswersSlice.reducer;
