import { CustomerResponse } from '@interfaces'; import { createReducer } from '@reduxjs/toolkit'; import { fetchCustomerDetails } from './thunk'; export interface CustomerProfileState { customerDetails: CustomerResponse | null; error: string | null; isLoading: boolean; } const initialState: CustomerProfileState = { customerDetails: null, error: null, isLoading: false, }; const customerProfileReducer = createReducer(initialState, builder => { builder .addCase(fetchCustomerDetails.pending, state => { state.isLoading = true; state.error = null; }) .addCase(fetchCustomerDetails.fulfilled, (state, action) => { state.isLoading = false; state.customerDetails = action.payload; }) .addCase(fetchCustomerDetails.rejected, (state, action) => { state.isLoading = false; state.error = action.payload as string; }); }); export default customerProfileReducer;