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

// Type Imports

// Data Imports
import { PaymentMethod } from '../../types/services/paymentMethod'

const initialState: { currentPaymentMethod: PaymentMethod } = {
  currentPaymentMethod: {
      id: '',
      organization_id: '',
      name: '',
      type: '',
      is_active: true,
      created_at: '',
      updated_at: ''
  }
}

export const paymentMethodSlice = createSlice({
  name: 'paymentMethod',
  initialState,
  reducers: {
    setPaymentMethod: (state, action: PayloadAction<PaymentMethod>) => {
      state.currentPaymentMethod = action.payload
    },
    resetPaymentMethod: state => {
      state.currentPaymentMethod = initialState.currentPaymentMethod
    }
  }
})

export const { setPaymentMethod, resetPaymentMethod } = paymentMethodSlice.actions

export default paymentMethodSlice.reducer
