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

const registrationformSlice = createSlice({
  name: "registerform",
  initialState: {
    personalDetails: {
      name: "",
      mobileNumber: "",
      gender: "",
      dob: "",
      height: "",
      weight: "",
      maritalStatus: "",
      religion: "",
      caste: "",
      subCaste: "",
      gothram: "",
      bloodGroup: "",
      email: "",
      state: "",
      city: "",
      pincode: "",
      profiles: [],
    },
    educationalDetails: {
      qualification: "",
      fieldOfStudy: "",
      occupation: "",
      organization: "",
      income: "",
      workLocation: "",
    },
    familyDetails: {
      fatherName: "",
      fatherOccupation: "",
      motherName: "",
      motherOccupation: "",
      siblings: "",
      siblingsStatus: "",
     
    },
    lifestyleDetails: {
      diet: "",
      drinking: "",
      smoking: "",
      hobbies: "",
    },
    partnerPreferences: {
      ageRange: "",
      religionCaste: "",
      occupationPref: "",
      lifestylePref: "",
      qualificationPref: "",
      occupationText: "",
      incomePref: "",
      locationPref: "",
    },
  },

  reducers: {
    updatePersonalDetails: (state, action) => {
      state.personalDetails = { ...state.personalDetails, ...action.payload };
    },
    updateEducationalDetails: (state, action) => {
      state.educationalDetails = { ...state.educationalDetails, ...action.payload };
    },
    updateFamilyDetails: (state, action) => {
      state.familyDetails = { ...state.familyDetails, ...action.payload };
    },
    updateLifestyleDetails: (state, action) => {
      state.lifestyleDetails = { ...state.lifestyleDetails, ...action.payload };
    },
    updatePartnerPreferences: (state, action) => {
      state.partnerPreferences = { ...state.partnerPreferences, ...action.payload };
    },

    submitForm: (state) => {
      console.log("Form Submitted:", {
        personalDetails: state.personalDetails,
        educationalDetails: state.educationalDetails,
        familyDetails: state.familyDetails,
        lifestyleDetails: state.lifestyleDetails,
        partnerPreferences: state.partnerPreferences,
      });
    },


preloadDummyProfile: (state) => {
      state.personalDetails = {
        ...state.personalDetails,
        name: "John Doe",
        mobileNumber: "9876543210",
        gender: "Male",
        dob: "1995-05-01",
        height: "175",
        weight: "70",
        maritalStatus: "Single",
        religion: "Hindu",
        caste: "Brahmin",
        email: "john@example.com",
        state: "Tamil Nadu",
        city: "Chennai",
        pincode: "600001",
         profiles: [
          {
            id: 1,
            name: "profile1.jpg",
            url: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200&h=200&fit=crop&crop=face",
            preview: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200&h=200&fit=crop&crop=face",
            size: 245760,
          },
          {
            id: 2,
            name: "profile2.jpg",
            url: "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=200&h=200&fit=crop&crop=face",
            preview: "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=200&h=200&fit=crop&crop=face",
            size: 189440,
          },
          {
            id: 3,
            name: "profile3.jpg",
            url: "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=200&h=200&fit=crop&crop=face",
            preview: "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=200&h=200&fit=crop&crop=face",
            size: 312640,
          },
          {
            id: 4,
            name: "profile4.jpg",
            url: "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=200&h=200&fit=crop&crop=face",
            preview: "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=200&h=200&fit=crop&crop=face",
            size: 267392,
          },
          {
            id: 5,
            name: "profile5.jpg",
            url: "https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?w=200&h=200&fit=crop&crop=face",
            preview: "https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?w=200&h=200&fit=crop&crop=face",
            size: 198656,
          },
        ],
      };
      state.educationalDetails = {
        ...state.educationalDetails,
        qualification: "B.E",
        fieldOfStudy: "CSE",
        occupation: "Software Engineer",
        organization: "ABC Pvt Ltd",
        income: "10 LPA",
        workLocation: "Chennai",
      };
      state.familyDetails = {
        ...state.familyDetails,
        fatherName: "Father Name",
        fatherOccupation: "Business",
        motherName: "Mother Name",
        motherOccupation: "Homemaker",
        siblings: "1",
        siblingsStatus: "Married",
      };
      state.lifestyleDetails = {
        ...state.lifestyleDetails,
        diet: "Veg",
        drinking: "No",
        smoking: "No",
        hobbies: "Reading, Music",
      };
      state.partnerPreferences = {
        ...state.partnerPreferences,
        ageRange: "24-30",
        religionCaste: "Hindu / Brahmin",
        occupationPref: "IT / Software",
        lifestylePref: "Non-smoker, Non-drinker",
        qualificationPref: "Degree",
        occupationText: "IT, Banking",
        incomePref: "10-20 LPA",
        locationPref: "Chennai, Bengaluru",
      };
    },




  },
});

export const {
  updatePersonalDetails,
  updateEducationalDetails,
  updateFamilyDetails,
  updateLifestyleDetails,
  updatePartnerPreferences,
  submitForm,
   preloadDummyProfile,
} = registrationformSlice.actions;

export default registrationformSlice.reducer;
