Hey there, I'm encountering an issue while trying to display a modal upon button click. The error message I receive is "ERROR TypeError: Cannot destructure property 'event id' of 'this.store.selectSnapshot (...)' as it is undefined." What might be causing this problem?
https://i.sstatic.net/eL6UZ.png
This function is supposed to trigger the modal:
handleListar(item: IGeneral) {
this.store.dispatch(new FormActividadSolContainerActions.ListarDatosHistorial({ IdEvento: item.nro }));
const dialogRef = this.dialogService.openXL(ModalHistorialCambiosComponent);
}
The line triggering the error:
private loadGridHistorial = () => {
const { IdEvento: IdEvento } = this.store.selectSnapshot(CONTAINER_STATE_TOKEN);
this.store.dispatch(new ContainerActions.ListarDatosHistorial({ IdEvento }));
}
Here's my model:
export class FormHistorialModel {
title = 'Detalle Del Historial';
gridHistorial: { loading: boolean; definition: IDataGridDefinition; source: IDataGridSource<any> } = {
loading: false,
definition: {
columns: [
{ label: 'Numero de Evento', field: 'idEvento' },
{ label: 'Nombre de Evento', field: 'nombreEvento' },
{ label: 'Tipo de Evento', field: 'tipoEvento' },
{ label: 'Fecha del Cambio', field: 'fechaCambio' },
{ label: 'Cambio y Motivo', field: 'cambioyMotivo' },
{ label: 'Usuario', field: 'usuario' },
]
},
source: {
items: [],
page: 1,
pageSize: 10,
total: 0
}
};
formType = FormType.CONSULTAR;
IdEvento: number = null;
}
Action:
export class ListarDatosHistorial {
static readonly type = '[FORM-ACTIVIDAD-SOL-CONTAINER] ListarDatosHistorial';
constructor(public payload: { IdEvento: number } ) { }
}
State:
listarHistorialSolicitudesBegin = (
ctx: StateContext<FormHistorialModel>
) => {
const state = ctx.getState();
ctx.patchState({
gridHistorial: {
...state.gridHistorial,
loading: true
},
});
}
...
(remaining content unchanged)
...
@Action(ContainerActions.ListarDatosHistorial)
asynclistarHistorial(
ctx: StateContext<FormHistorialModel>,
{ payload }: ContainerActions.ListarDatosHistorial
) {
this.listarHistorialSolicitudesBegin(ctx);
return this.historialService.ListarHistorial(payload.IdEvento).pipe(
tap(response => {
this.listarHistorialSolicitudesSuccess(ctx)(
response.data || []
);
}),
catchError(err => {
this.listarHistorialSolicitudesError(ctx)(err);
return throwError(err);
})
);
}
Service: https://i.sstatic.net/t7xOp.png