{ "version": 3, "sources": ["src/app/store/activities/activities.actions.ts", "src/app/interfaces/general/activities-type.enum.ts", "src/app/modules/activities/activities.service.ts", "src/app/store/activities/activities.state.ts"], "sourcesContent": ["export class GetActivities {\n public static readonly type = '[Activities] Get activities';\n constructor(public partnerParam?: string, public typeParam?: string, public inTimeline?: boolean) {}\n}\n\nexport class GetNextActivities {\n public static readonly type = '[Activities] Get next activities';\n}\n", "export enum ActivitiesType {\n OBJECT_CHANGED = 'Object changed',\n ORDER = 'Order',\n ACCOUNT_SIGN_IN = 'Account sign in',\n ACCOUNT_SIGN_UP = 'Account sign up',\n GENERAL_TERM_ACCEPTED = 'General term accepted',\n ORDERING_TERM_ACCEPTED = 'Ordering term accepted',\n PROFILE_DATA_CHANGED = 'Profile data changed',\n PROFILE_DATA_CREATED = 'Profile data created',\n PROFILE_DATA_DELETED = 'Profile data deleted',\n PARTY_CREATED = 'Party created',\n PARTY_UPDATED = 'Party updated',\n PARTY_DELETED = 'Party deleted',\n}\n", "import {Injectable} from '@angular/core';\nimport {HttpClient, HttpParams} from '@angular/common/http';\nimport {from, Observable, of} from 'rxjs';\nimport {ConfigurationService} from '../../core/config/configuration.service';\nimport {IBusinessTrail} from '../../interfaces/general/profile-definitions/business-trail.interface';\nimport {ParamsEncoder} from 'src/app/core/config/params-encoder';\nimport {ActivitiesState, IActivitiesState} from \"src/app/store/activities/activities.state\";\nimport {map, mergeMap, shareReplay, switchMap, toArray} from \"rxjs/operators\";\nimport {ActivitiesType} from \"src/app/interfaces/general/activities-type.enum\";\nimport {Store} from \"@ngxs/store\";\nimport {ProfileService} from \"src/app/modules/profile/profile.service\";\n\nexport interface IBusinessTrailRequest {\n continuationToken?: string;\n partnerParam?: string;\n typeParam?: string;\n inTimeline?: boolean;\n}\n\nexport interface IBusinessTrailResponse {\n data: IBusinessTrail[];\n continuationToken: string | null;\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ActivitiesService {\n constructor(\n private config: ConfigurationService,\n private http: HttpClient,\n private store: Store,\n private profileService: ProfileService,\n ) {}\n\n public getBusinessTrail(queryParams?: IBusinessTrailRequest): Observable {\n let params = new HttpParams({encoder: new ParamsEncoder()});\n if (queryParams?.continuationToken) {\n params = params.append('continuationToken', queryParams.continuationToken);\n }\n if (queryParams?.partnerParam) {\n params = params.append('partner', queryParams.partnerParam);\n }\n if (queryParams?.typeParam) {\n params = params.append('type', queryParams.typeParam);\n }\n if (typeof queryParams?.inTimeline === 'boolean') {\n params = params.append('inTimeline', queryParams.inTimeline);\n }\n return this.http.get(`${this.config.get('profileApiUrl')}/businesstrail`, {params});\n }\n\n public createBusinessTrail(payload: IBusinessTrail): Observable {\n return this.http.post(`${this.config.get('profileApiUrl')}/businesstrail`, payload);\n }\n\n public getActivitiesStateWithDetails(): Observable {\n return this.store.select(ActivitiesState).pipe(\n switchMap(state => {\n let activities = state.activities;\n if (activities?.length) {\n const cache = new Map>();\n return from(activities).pipe(\n mergeMap((activity: any) => {\n if (activity.title === ActivitiesType.GENERAL_TERM_ACCEPTED ||\n activity.title === ActivitiesType.ORDERING_TERM_ACCEPTED) {\n const termCode = activity.termCode;\n const request$ = this.profileService.getTerms(activity.termCode).pipe(\n map(resp => {\n return {...activity, details: resp};\n }),\n shareReplay(1),\n );\n if (!cache.has(termCode)) {\n cache.set(termCode, request$);\n }\n return cache.get(termCode);\n } else {\n return of(activity);\n }\n }),\n toArray(),\n map((activitiesRes) => {\n return {\n ...state,\n activities: activitiesRes\n }\n })\n );\n } else {\n return of(state);\n }\n })\n );\n }\n}\n", "import {Action, Selector, State, StateContext} from '@ngxs/store';\nimport {Injectable} from '@angular/core';\nimport {GetActivities, GetNextActivities} from './activities.actions';\nimport {\n ActivitiesService,\n IBusinessTrailRequest,\n IBusinessTrailResponse,\n} from '../../modules/activities/activities.service';\nimport {firstValueFrom} from 'rxjs';\nimport {errorHandler, IErrorHandlerArgs} from 'src/app/shared/helpers/error-handler';\nimport {AppInsightsService} from 'src/app/core/app-insights/app-insights.service';\n\nexport interface IActivitiesState {\n activities: any[];\n loading: boolean;\n hasValue: boolean;\n error: any;\n queryParams?: IBusinessTrailRequest;\n}\n\n@State({\n name: 'activities',\n defaults: {\n activities: [],\n loading: false,\n hasValue: false,\n error: null,\n },\n})\n@Injectable()\nexport class ActivitiesState {\n private readonly _errorHandlerArgs: IErrorHandlerArgs = {\n error: null,\n appInsightsSrv: this.insights,\n scope: 'ActivitiesState',\n };\n constructor(\n private activitiesService: ActivitiesService,\n private insights: AppInsightsService,\n ) { }\n\n @Selector()\n public static activities(state: IActivitiesState): any[] {\n return state.activities;\n }\n\n @Selector()\n public static loading(state: IActivitiesState): boolean {\n return state.loading;\n }\n\n @Selector()\n public static hasValue(state: IActivitiesState): boolean {\n return state.hasValue;\n }\n\n @Action(GetActivities)\n public async getActivities(\n ctx: StateContext,\n {partnerParam, typeParam, inTimeline}: GetActivities\n ): Promise {\n ctx.patchState({loading: true});\n\n try {\n const {data, continuationToken}: IBusinessTrailResponse = await firstValueFrom(\n this.activitiesService.getBusinessTrail({\n partnerParam,\n typeParam,\n inTimeline,\n })\n );\n ctx.patchState({\n activities: data,\n hasValue: !!data.length,\n loading: false,\n queryParams: {\n continuationToken,\n partnerParam,\n typeParam,\n inTimeline,\n },\n });\n } catch (error) {\n errorHandler({...this._errorHandlerArgs, error});\n ctx.patchState({\n hasValue: false,\n loading: false,\n error,\n });\n }\n }\n\n @Action(GetNextActivities)\n public async getNextActivities(ctx: StateContext): Promise {\n const queryParams = ctx.getState().queryParams;\n const preservedData = ctx.getState().activities;\n\n if (queryParams?.continuationToken) {\n ctx.patchState({loading: true});\n try {\n const response: IBusinessTrailResponse = await firstValueFrom(\n this.activitiesService.getBusinessTrail(queryParams)\n );\n ctx.patchState({\n activities: [...preservedData, ...response?.data],\n hasValue: !!response?.data?.length,\n loading: false,\n queryParams: {\n ...queryParams,\n continuationToken: response?.continuationToken,\n },\n });\n } catch (error) {\n errorHandler({...this._errorHandlerArgs, error});\n ctx.patchState({\n hasValue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,WAAW,CACXX,WAAY,CAAC,GAAGuB,EAAe,GAAGC,GAAUZ,IAAI,EAChDT,SAAU,CAAC,CAACqB,GAAUZ,MAAMI,OAC5Bd,QAAS,GACTe,YAAaE,EAAAC,EAAA,GACNH,GADM,CAETJ,kBAAmBW,GAAUX,oBAEpC,CACL,OAAShB,EAAO,CACZqB,EAAaC,EAAAC,EAAA,GAAI,KAAKxB,mBAAT,CAA4BC,MAAAA,CAAK,EAAC,EAC/CQ,EAAIM,WAAW,CACXR,SAAU,GACVD,QAAS,GACTL,MAAAA,EACH,CACL,CACJ,CACJ,mDA3FSL,GAAeiC,EAAAC,CAAA,EAAAD,EAAAE,CAAA,CAAA,CAAA,CAAA,iCAAfnC,EAAeoC,QAAfpC,EAAeqC,SAAA,CAAA,CAAA,GA2BXC,EAAA,CADZC,EAAOC,CAAa,CAAC,EAAAxC,EAAA,UAAA,gBAAA,IAAA,EAqCTsC,EAAA,CADZC,EAAOE,CAAiB,CAAC,EAAAzC,EAAA,UAAA,oBAAA,IAAA,EAlDZsC,EAAA,CADbI,EAAQ,CAAE,EAAA1C,EAAA,aAAA,IAAA,EAMGsC,EAAA,CADbI,EAAQ,CAAE,EAAA1C,EAAA,UAAA,IAAA,EAMGsC,EAAA,CADbI,EAAQ,CAAE,EAAA1C,EAAA,WAAA,IAAA,EArBFA,EAAesC,EAAA,CAV3BK,EAAwB,CACrBC,KAAM,aACNC,SAAU,CACNrC,WAAY,CAAA,EACZE,QAAS,GACTC,SAAU,GACVN,MAAO,MAEd,CAAC,EAEWL,CAAe", "names": ["GetActivities", "type", "constructor", "partnerParam", "typeParam", "inTimeline", "GetNextActivities", "ActivitiesType", "ActivitiesService", "constructor", "config", "http", "store", "profileService", "getBusinessTrail", "queryParams", "params", "HttpParams", "encoder", "ParamsEncoder", "continuationToken", "append", "partnerParam", "typeParam", "inTimeline", "get", "createBusinessTrail", "payload", "post", "getActivitiesStateWithDetails", "select", "ActivitiesState", "pipe", "switchMap", "state", "activities", "length", "cache", "Map", "from", "mergeMap", "activity", "title", "ActivitiesType", "GENERAL_TERM_ACCEPTED", "ORDERING_TERM_ACCEPTED", "termCode", "request$", "getTerms", "map", "resp", "__spreadProps", "__spreadValues", "details", "shareReplay", "has", "set", "of", "toArray", "activitiesRes", "\u0275\u0275inject", "ConfigurationService", "HttpClient", "Store", "ProfileService", "factory", "\u0275fac", "providedIn", "ActivitiesState", "constructor", "activitiesService", "insights", "_errorHandlerArgs", "error", "appInsightsSrv", "scope", "activities", "state", "loading", "hasValue", "getActivities", "ctx", "_1", "__async", "partnerParam", "typeParam", "inTimeline", "patchState", "data", "continuationToken", "firstValueFrom", "getBusinessTrail", "length", "queryParams", "errorHandler", "__spreadProps", "__spreadValues", "getNextActivities", "getState", "preservedData", "response", "\u0275\u0275inject", "ActivitiesService", "AppInsightsService", "factory", "\u0275fac", "__decorate", "Action", "GetActivities", "GetNextActivities", "Selector", "State", "name", "defaults"] }