0

I have an object maintained in ngrx store like shown below -

{
 .
 .
 callStatus: ClientStatus;
 .
 .
}

and ClientStatus is a further nested interface like -

interface ClientStatus {
 status: boolean;
 csrObject: csrStatus;
}

now in an API response I am getting updated values of csrStatus for a single user type which I need to update. but when I try to -

adapter.updateOne(
{
  id: client.id,
  changes: { callStatus.csrObject: action.response }
})

I am getting error as I am not allowed to access a sub-property of a given key while updating.

Does anybody know how can I approach this problem?

samar taj Shaikh
  • 1,165
  • 11
  • 18

1 Answers1

0

I think you need to correct your code a bit:

adapter.updateOne({
    id: client.id,
    csrObject: action.response
  },
  state,
})

ngrx doc says the first argument is a Partial entity object the second argument is the state of the entity:

  on(UserActions.updateUser, (state, { update }) => {
    return adapter.updateOne(update, state);
  }),
satanTime
  • 12,631
  • 1
  • 25
  • 73