import { InMemoryDbService } from 'angular-in-memory-web-api' ; import * as _ from "lodash" ; import { USERS } from "./user" ; import { GROUPS } from './groups' ; import { REQUESTS } from "./requests" ; export class InMemoryDataService implements InMemoryDbService { createDb ( ) { return { LOGIN_RESPONSE : [ { id : 0 } ] , CREATE_USER : [ { id : 0 } ] , USERS : { data : USERS } , GET_USER : { data : _ . find ( USERS , { id : 1 } ) } , GROUPS : { data : GROUPS } , USER_PROPOSALS : { data : _ . filter ( REQUESTS , ( req ) => { let ownedGroups = _ . filter ( GROUPS , ( group ) => { return ! ! _ . find ( group . owners , ( id ) => { return id == 1 ; } ) ; } ) ; let targetInGroups = _ . find ( ownedGroups , ( group ) => { return group . id === req . object ; } ) ; return ! ! targetInGroups ; } ) } , PATCH_PROPOSAL : [ { id : 0 } ] , ADD_MEMBER : [ { id : 0 } ] , PROPOSALS : REQUESTS } ; } }