I want to update my state using a ngrx reducer but I'm getting an compilation error.
For context. The user submits a worklog on a form, and I want this worklog to be added to the worklogs array on the state.
Here is the structure of my state:
export declare interface Outreach {
outreach: CaseState|null;
}
export declare interface CaseState {
outreachCaseId: string;
worklogs: WorklogCase[]; // <- I want to add the new worklog here
}
export declare interface WorklogCase {
worklogId: string;
username: string;
details: string;
}
The reducer:
const initialState: OutreachState = {
outreach: null,
}
export const outreachDetailsReducers = createReducer<OutreachState>(
initialState,
on(outreachActions.addWoklogSuccess,
state, {worklog}) => ({...state, worklogs: [...worklog]})),
I think I have the sintax wrong some how on the last line of the reducer. Any help?