Skip to content
Snippets Groups Projects
Commit 067cfacb authored by jvanboxtel@wisc.edu's avatar jvanboxtel@wisc.edu
Browse files

Adds populate state action

parent 3e312328
No related branches found
No related tags found
No related merge requests found
...@@ -7,11 +7,14 @@ export enum DarsActionTypes { ...@@ -7,11 +7,14 @@ export enum DarsActionTypes {
ErrorLoadingMetadata = '[DARS] Error Loading Metadata', ErrorLoadingMetadata = '[DARS] Error Loading Metadata',
StartLoadingMetadata = '[DARS] Start Loading Metadata', StartLoadingMetadata = '[DARS] Start Loading Metadata',
DoneLoadingMetadata = '[DARS] Done Loading Metadata', DoneLoadingMetadata = '[DARS] Done Loading Metadata',
ErrorLoadingAudit = '[DARS] Error Loading Audit',
AddAuditMetadata = '[DARS] Add Audit Metadata', AddAuditMetadata = '[DARS] Add Audit Metadata',
ErrorLoadingAudit = '[DARS] Error Loading Audit',
StartLoadingAudit = '[DARS] Start Loading Audit', StartLoadingAudit = '[DARS] Start Loading Audit',
DoneLoadingAudit = '[DARS] Done Loading Audit', DoneLoadingAudit = '[DARS] Done Loading Audit',
CloseAudit = '[DARS] Close Audit', CloseAudit = '[DARS] Close Audit',
PopulateDarsState = '[DARS] Done Loading state',
} }
export class ErrorLoadingMetadata implements Action { export class ErrorLoadingMetadata implements Action {
...@@ -43,6 +46,11 @@ export class AddAuditMetadata implements Action { ...@@ -43,6 +46,11 @@ export class AddAuditMetadata implements Action {
) {} ) {}
} }
export class PopulateDarsState implements Action {
public readonly type = DarsActionTypes.PopulateDarsState;
constructor(public payload: Partial<DARSState>) {}
}
export class StartLoadingAudit implements Action { export class StartLoadingAudit implements Action {
public readonly type = DarsActionTypes.StartLoadingAudit; public readonly type = DarsActionTypes.StartLoadingAudit;
constructor(public payload: AuditMetadata) {} constructor(public payload: AuditMetadata) {}
......
...@@ -67,9 +67,13 @@ export class DARSEffects { ...@@ -67,9 +67,13 @@ export class DARSEffects {
} }
}); });
return new darsActions.AddAuditMetadata({ return new darsActions.PopulateDarsState({
programMetadata, metadata: {
whatIfMetadata, status: 'Loaded',
programMetadata,
whatIfMetadata,
},
alerts,
}); });
}), }),
......
import { DARSState, INITIAL_DARS_STATE } from '@app/dars/store/state'; import { DARSState, INITIAL_DARS_STATE } from '@app/dars/store/state';
import { DarsActionTypes } from './actions'; import { DarsActionTypes, AddAuditMetadata } from './actions';
import * as darsActions from './actions'; import * as darsActions from './actions';
type SupportedActions = type SupportedActions =
| darsActions.ErrorLoadingMetadata | darsActions.ErrorLoadingMetadata
| darsActions.AddAuditMetadata | darsActions.AddAuditMetadata
| darsActions.PopulateDarsState
| darsActions.StartLoadingAudit | darsActions.StartLoadingAudit
| darsActions.DoneLoadingAudit | darsActions.DoneLoadingAudit
| darsActions.CloseAudit; | darsActions.CloseAudit;
...@@ -14,6 +15,9 @@ export function darsReducer( ...@@ -14,6 +15,9 @@ export function darsReducer(
action: SupportedActions, action: SupportedActions,
): DARSState { ): DARSState {
switch (action.type) { switch (action.type) {
case DarsActionTypes.PopulateDarsState: {
return { ...state, ...action.payload };
}
case DarsActionTypes.ErrorLoadingMetadata: { case DarsActionTypes.ErrorLoadingMetadata: {
return { return {
...state, ...state,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment