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

// Type Imports

// Data Imports
import { Organization } from '../../types/services/organization'

const initialState: { currentOrganization: Organization } = {
  currentOrganization: {
      id: '',
      name: '',
      email: '',
      phone_number: '',
      plan_type: 'basic',
      created_at: '',
      updated_at: ''
  }
}

export const organizationSlice = createSlice({
  name: 'organization',
  initialState,
  reducers: {
    setOrganization: (state, action: PayloadAction<Organization>) => {
      state.currentOrganization = action.payload
    },
    resetOrganization: state => {
      state.currentOrganization = initialState.currentOrganization
    }
  }
})

export const { setOrganization, resetOrganization } = organizationSlice.actions

export default organizationSlice.reducer
