{ "version": 3, "sources": ["src/app/store/e-tickets/tickets.actions.ts", "src/app/modules/tickets/tickets.service.ts", "src/app/store/e-tickets/tickets.state.ts"], "sourcesContent": ["export class GetTickets {\n public static readonly type = '[Tickets] Get tickets';\n}\n\nexport class GetValidTickets {\n public static readonly type = '[Tickets] Get valid tickets';\n}\n\nexport class GetPastTickets {\n public static readonly type = '[Tickets] Get past tickets';\n}\n\nexport class GetNextTickets {\n public static readonly type = '[Tickets] Get next tickets';\n}\n\nexport class GetNextTicket {\n public static readonly type = '[Tickets] Get next ticket';\n constructor(public id: string) {\n }\n}\n\nexport class GetPrevTicket {\n public static readonly type = '[Tickets] Get prev ticket';\n constructor(public id: string) {\n }\n}\n", "import {Injectable} from '@angular/core';\nimport {HttpClient, HttpParams} from '@angular/common/http';\nimport {Observable} from 'rxjs';\nimport {ConfigurationService} from 'src/app/core/config/configuration.service';\nimport {ITicket} from 'src/app/interfaces/general/profile-definitions/ticket.interface';\nimport {ItemPayload} from 'src/app/interfaces/general/responses/item-payload.interface';\nimport {ParamsEncoder} from 'src/app/core/config/params-encoder';\nimport {map} from 'rxjs/operators';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class TicketsService {\n private nextPageToken = null;\n constructor(\n private http: HttpClient,\n private config: ConfigurationService\n ) {}\n\n public getTickets(scope: 'CurrentAndFuture' | 'Past' | 'All' = 'All', nextPageToken?: string): Observable> {\n let params = new HttpParams({\n encoder: new ParamsEncoder()\n }).append('scope', scope).append('top', 10000);\n if (nextPageToken) {\n params = params.append('continuationToken', nextPageToken);\n }\n return this.http.get>(\n `${this.config.get('profileApiUrl')}/tickets`,\n {params}\n ).pipe(\n map((res) => {\n const data = [...res.data ?? []].sort((a, b) => {\n const aDate = new Date(a.createdDateTime).getTime();\n const bDate = new Date(b.createdDateTime).getTime();\n return bDate - aDate;\n });\n return {...res, data};\n })\n );\n }\n\n public getValidTickets(nextPageToken?: string): Observable> {\n return this.getTickets('CurrentAndFuture', nextPageToken);\n }\n\n public getPastTickets(nextPageToken?: string): Observable> {\n return this.getTickets('Past', nextPageToken);\n }\n\n public getTicketById(id: string): Observable {\n return this.http.get(\n `${this.config.get('profileApiUrl')}/tickets/${id}`\n );\n }\n\n public getToken(): Observable {\n return this.http.post(\n `${this.config.get('profileApiUrl')}/token?grant_type=guest`,\n {}\n );\n }\n}\n", "import {Action, createSelector, Selector, State, StateContext, Store} from '@ngxs/store';\nimport {Injectable} from '@angular/core';\nimport {\n GetNextTicket,\n GetPastTickets,\n GetPrevTicket,\n GetTickets,\n GetValidTickets,\n GetNextTickets,\n} from './tickets.actions';\nimport {ITicket} from 'src/app/interfaces/general/profile-definitions/ticket.interface';\nimport {TicketsService} from 'src/app/modules/tickets/tickets.service';\nimport {ItemPayload} from 'src/app/interfaces/general/responses/item-payload.interface';\nimport {Navigate} from '@ngxs/router-plugin';\nimport {firstValueFrom} from 'rxjs';\nimport {AppInsightsService} from 'src/app/core/app-insights/app-insights.service';\nimport {errorHandler, IErrorHandlerArgs} from 'src/app/shared/helpers/error-handler';\n\nexport interface ITicketsState {\n tickets: ITicket[];\n loading: boolean;\n nextPageToken: string;\n hasValue: boolean;\n scope?: 'All' | 'CurrentAndFuture' | 'Past';\n error: any,\n}\n\n@State({\n name: 'tickets',\n defaults: {\n tickets: [],\n loading: false,\n nextPageToken: null,\n hasValue: false,\n scope: null,\n error: null,\n },\n})\n@Injectable()\nexport class TicketsState {\n private readonly _errorHandlerArgsInit: IErrorHandlerArgs = {\n error: null,\n appInsightsSrv: this.insights,\n scope: 'TicketsState',\n };\n constructor(\n private ticketsService: TicketsService,\n private store: Store,\n private insights: AppInsightsService,\n ) { }\n\n @Selector()\n public static tickets(state: ITicketsState): ITicket[] {\n return state.tickets;\n }\n\n @Selector()\n public static loading(state: ITicketsState): boolean {\n return state.loading;\n }\n\n @Selector()\n public static hasValue(state: ITicketsState): boolean {\n return !!state.tickets?.length;\n }\n\n public static hasPrevValue(id: string) {\n return createSelector([TicketsState], (state: ITicketsState) => {\n return state.tickets?.findIndex((ticket) => ticket.identifier === id) > 0;\n });\n }\n\n public static hasNextValue(id: string) {\n return createSelector([TicketsState], (state: ITicketsState) => {\n return (\n state.tickets.findIndex((ticket) => ticket.identifier === id) <\n state.tickets.length - 1\n );\n });\n }\n\n @Action(GetTickets)\n public async getTickets(ctx: StateContext): Promise {\n ctx.patchState({loading: true, error: null});\n try {\n const ticketsState: ItemPayload = await firstValueFrom(\n this.ticketsService.getTickets()\n );\n ctx.patchState({\n tickets: ticketsState.data,\n hasValue: !!ticketsState.data.length,\n nextPageToken: ticketsState.nextPageToken,\n loading: false,\n });\n } catch (error) {\n errorHandler({...this._errorHandlerArgsInit, error});\n ctx.patchState({\n loading: false,\n error,\n });\n }\n\n }\n\n @Action(GetValidTickets)\n public async getValidTickets(ctx: StateContext): Promise {\n ctx.patchState({loading: true, tickets: [], error: null});\n try {\n const ticketsState: ItemPayload = await firstValueFrom(\n this.ticketsService.getValidTickets()\n );\n ctx.patchState({\n tickets: ticketsState.data,\n hasValue: !!ticketsState.data.length,\n nextPageToken: ticketsState.nextPageToken,\n loading: false,\n scope: 'CurrentAndFuture',\n });\n } catch (error) {\n errorHandler({...this._errorHandlerArgsInit, error});\n ctx.patchState({\n loading: false,\n error,\n });\n }\n }\n\n @Action(GetPastTickets)\n public async getPastTickets(ctx: StateContext): Promise {\n ctx.patchState({loading: true, tickets: [], error: null});\n try {\n const ticketsState: ItemPayload = await firstValueFrom(\n this.ticketsService.getPastTickets()\n );\n ctx.patchState({\n tickets: ticketsState.data,\n hasValue: !!ticketsState.data.length,\n nextPageToken: ticketsState.nextPageToken,\n loading: false,\n scope: 'Past',\n });\n } catch (error) {\n errorHandler({...this._errorHandlerArgsInit, error});\n ctx.patchState({\n loading: false,\n error,\n });\n }\n }\n\n @Action(GetNextTickets)\n public async getNextTickets(ctx: StateContext): Promise {\n const tickets = ctx.getState().tickets;\n const nextPageToken = ctx.getState().nextPageToken;\n const scope = ctx.getState().scope ?? 'All';\n if (nextPageToken) {\n ctx.patchState({loading: true, error: null});\n try {\n const ticketsState: ItemPayload = await firstValueFrom(\n this.ticketsService.getTickets(scope, nextPageToken)\n );\n ctx.patchState({\n tickets: [...tickets, ...ticketsState.data],\n nextPageToken: ticketsState.nextPageToken,\n loading: false,\n scope,\n });\n } catch (error) {\n errorHandler({...this._errorHandlerArgsInit, error});\n ctx.patchState({\n loading: false,\n error,\n });\n }\n }\n }\n\n @Action(GetPrevTicket)\n public async getPrevTicket(\n ctx: StateContext,\n {id}: GetPrevTicket\n ): Promise {\n const state = ctx.getState();\n const tickets = state.tickets;\n const index = tickets?.findIndex((order) => order.identifier === id);\n if (index > 0) {\n this.store.dispatch(new Navigate(['/', 'tickets', tickets[index - 1].identifier]));\n }\n }\n\n @Action(GetNextTicket)\n public async getNextTicket(\n ctx: StateContext,\n {id}: GetNextTicket\n ): Promise {\n const state = ctx.getState();\n const tickets = state.tickets;\n const index = tickets.findIndex((order) => order.identifier === id);\n if (index === tickets.length - 2) {\n this.store.dispatch(new GetNextTickets());\n this.store.dispatch(new Navigate(['/', 'tickets', tickets[index + 1].identifier]));\n }\n\n if (index < tickets.length - 2) {\n this.store.dispatch(new Navigate(['/', 'tickets', tickets[index + 1].identifier]));\n }\n }\n}\n"], "mappings": "oVAAA,IAAaA,GAAU,IAAA,CAAjB,MAAOA,CAAU,QACI,KAAAC,KAAO,uBAAwB,SAD7CD,CAAU,GAAA,EAIVE,GAAe,IAAA,CAAtB,MAAOA,CAAe,QACD,KAAAD,KAAO,6BAA8B,SADnDC,CAAe,GAAA,EAIfC,GAAc,IAAA,CAArB,MAAOA,CAAc,QACA,KAAAF,KAAO,4BAA6B,SADlDE,CAAc,GAAA,EAIdC,GAAc,IAAA,CAArB,MAAOA,CAAc,QACA,KAAAH,KAAO,4BAA6B,SADlDG,CAAc,GAAA,EAIdC,GAAa,IAAA,CAApB,MAAOA,CAAa,QACC,KAAAJ,KAAO,2BAA4B,CAC1DK,YAAmBC,EAAU,CAAV,KAAAA,G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OAAS,GACzB,KAAKV,MAAMsC,SAAS,IAAIC,EAAS,CAAC,IAAK,UAAWjC,EAAQ8B,EAAQ,CAAC,EAAEnB,UAAU,CAAC,CAAC,CAEzF,mDAvKSpB,GAAY6C,EAAAC,CAAA,EAAAD,EAAAE,CAAA,EAAAF,EAAAG,CAAA,CAAA,CAAA,CAAA,iCAAZhD,EAAYiD,QAAZjD,EAAYkD,SAAA,CAAA,CAAA,GA2CRC,EAAA,CADZC,EAAOC,CAAU,CAAC,EAAArD,EAAA,UAAA,aAAA,IAAA,EAwBNmD,EAAA,CADZC,EAAOE,CAAe,CAAC,EAAAtD,EAAA,UAAA,kBAAA,IAAA,EAwBXmD,EAAA,CADZC,EAAOG,CAAc,CAAC,EAAAvD,EAAA,UAAA,iBAAA,IAAA,EAwBVmD,EAAA,CADZC,EAAOR,CAAc,CAAC,EAAA5C,EAAA,UAAA,iBAAA,IAAA,EA4BVmD,EAAA,CADZC,EAAOI,CAAa,CAAC,EAAAxD,EAAA,UAAA,gBAAA,IAAA,EAcTmD,EAAA,CADZC,EAAOK,CAAa,CAAC,EAAAzD,EAAA,UAAA,gBAAA,IAAA,EA1IRmD,EAAA,CADbO,EAAQ,CAAE,EAAA1D,EAAA,UAAA,IAAA,EAMGmD,EAAA,CADbO,EAAQ,CAAE,EAAA1D,EAAA,UAAA,IAAA,EAMGmD,EAAA,CADbO,EAAQ,CAAE,EAAA1D,EAAA,WAAA,IAAA,EAtBFA,EAAYiB,EAAAkC,EAAA,CAZxBQ,EAAqB,CAClBC,KAAM,UACNC,SAAU,CACNpD,QAAS,CAAA,EACTE,QAAS,GACTkB,cAAe,KACfjB,SAAU,GACVJ,MAAO,KACPF,MAAO,MAEd,CAAC,EAEWN,CAAY", "names": ["GetTickets", "type", "GetValidTickets", "GetPastTickets", "GetNextTickets", "GetNextTicket", "constructor", "id", "GetPrevTicket", "TicketsService", "constructor", "http", "config", "nextPageToken", "getTickets", "scope", "params", "HttpParams", "encoder", "ParamsEncoder", "append", "get", "pipe", "map", "res", "data", "sort", "a", "b", "aDate", "Date", "createdDateTime", "getTime", "__spreadProps", "__spreadValues", "getValidTickets", "getPastTickets", "getTicketById", "id", "getToken", "post", "\u0275\u0275inject", "HttpClient", "ConfigurationService", "factory", "\u0275fac", "providedIn", "TicketsState", "constructor", "ticketsService", "store", "insights", "_errorHandlerArgsInit", "error", "appInsightsSrv", "scope", "tickets", "state", "loading", "hasValue", "length", "hasPrevValue", "id", "createSelector", "TicketsState_1", "findIndex", "ticket", "identifier", "hasNextValue", "getTickets", "ctx", "__async", "patchState", "ticketsState", "firstValueFrom", "data", "nextPageToken", "errorHandler", "__spreadProps", "__spreadValues", "getValidTickets", "getPastTickets", "getNextTickets", "getState", "getPrevTicket", "_1", "index", "order", "dispatch", "Navigate", "getNextTicket", "GetNextTickets", "\u0275\u0275inject", "TicketsService", "Store", "AppInsightsService", "factory", "\u0275fac", "__decorate", "Action", "GetTickets", "GetValidTickets", "GetPastTickets", "GetPrevTicket", "GetNextTicket", "Selector", "State", "name", "defaults"] }