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

const registrationformSlice = createSlice({
  name: "registerform",
  initialState: {
    personalDetails: {
      name: "",
      mobileNumber: "",
      gender: "",
      dob: "",
      height: "",
      weight: "",
      maritalStatus: "",
      religion: "",
      profileFor: "",
      caste: "",
      subCaste: "",
      gothram: "",
      raasi: "",
      star: "",
      bloodGroup: "",
      email: "",
      password: "",
      confirmPassword: "",
      state: "",
      city: "",
      pincode: "",
      profiles: [],
    },
    educationalDetails: {
      collegeName: "",
      employeeType: "",
      qualification: "",
      fieldOfStudy: "",
      occupation: "",
      organization: "",
      income: "",
      workLocation: "",
    },
    familyDetails: {
      fatherName: "",
      fatherOccupation: "",
      motherName: "",
      motherOccupation: "",
      brotherCount: 0,
      sisterCount: 0,
      brothers: [],
      sisters: [],
      familyStatus: "",
      nativePlace: "",
    },
    lifestyleDetails: {
      diets: [],
      hobbies: [],
      dob: "",
      tob: "",
      placeOfBirth: "",
      graha: {
        1: [],
        2: [],
        3: [],
        4: [],
        5: [],
        6: [],
        7: [],
        8: [],
        9: [],
        10: [],
        11: [],
        12: [],
      },
      amsam: {
        1: [],
        2: [],
        3: [],
        4: [],
        5: [],
        6: [],
        7: [],
        8: [],
        9: [],
        10: [],
        11: [],
        12: [],
      },
    },
    partnerPreferences: {
      ageRange: "",
      castes: [],
      subCastes: [],
      occupations: [],
      educations: [],
      hobbies: [],
      annualIncome: "",
      states: [],
      districts: [],
    },
  },

  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",
        collegeName: "ABC Engineering College",
        occupation: "Software Engineer",
        organization: "ABC Pvt Ltd",
        employeeType: "Private",
        income: "10 LPA",
        workLocation: "Chennai",
      };
      state.familyDetails = {
        ...state.familyDetails,
        fatherName: "Father Name",
        fatherOccupation: "Business",
        motherName: "Mother Name",
        motherOccupation: "Homemaker",
        brotherCount: 1,
        sisterCount: 1,
        brothers: [
          {
            name: "Rahul",
            occupation: "Engineer",
            maritalStatus: "Married",
            haveChildrens: 1,
          },
        ],
        sisters: [
          {
            name: "Rohini",
            occupation: "Teacher",
            maritalStatus: "Married",
            haveChildrens: 0,
          },
        ],
        familyStatus: 3,
        nativePlace: "Chennai",
      };
      state.lifestyleDetails = {
        ...state.lifestyleDetails,
        diets: [1],
        hobbies: [1, 3],
        dob: "1995-05-01",
        tob: "09:30",
        placeOfBirth: "Chennai",
        graha: {
          1: ["LAGNAM", "SURIYAN"],
          2: [],
          3: [],
          4: ["CHANDRAN", "CHEVVAI"],
          5: [],
          6: ["BUDHAN", "GURU"],
          7: [],
          8: ["SUKRAN", "SANI"],
          9: [],
          10: ["RAHU", "KETHU"],
          11: [],
          12: ["MANDHI"],
        },
        amsam: {
          1: ["LAGNAM", "SURIYAN"],
          2: [],
          3: [],
          4: ["CHANDRAN", "CHEVVAI"],
          5: [],
          6: ["BUDHAN", "GURU"],
          7: [],
          8: ["SUKRAN", "SANI"],
          9: [],
          10: ["RAHU", "KETHU"],
          11: [],
          12: ["MANDHI"],
        },
      };
      state.partnerPreferences = {
        ...state.partnerPreferences,
        ageRange: 2,
        castes: [1],
        subCastes: [1],
        occupations: [57],
        educations: [14],
        hobbies: [1, 3],
        annualIncome: 1,
        states: [31],
        districts: [1],
      };
    },




  },
});

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

export default registrationformSlice.reducer;
