// Third-party Imports
import type { PayloadAction } from '@reduxjs/toolkit'
import { createSlice } from '@reduxjs/toolkit'

// Type Imports

// Data Imports
import { Customer } from '../../types/services/customer'

const initialState: { currentCustomer: Customer } = {
  currentCustomer: {
      id: '',
      name: '',
      email: '',
      phone: '',
      address: '',
      is_active: true,
      organization_id: '',
      is_default: false,
      metadata: {},
      created_at: '',
      updated_at: ''
  }
}

export const customerSlice = createSlice({
  name: 'customer',
  initialState,
  reducers: {
    setCustomer: (state, action: PayloadAction<Customer>) => {
      state.currentCustomer = action.payload
    },
    resetCustomer: state => {
      state.currentCustomer = initialState.currentCustomer
    }
  }
})

export const { setCustomer, resetCustomer } = customerSlice.actions

export default customerSlice.reducer
