{ "version": 3, "sources": ["src/app/store/orders/orders-item/orders-item.actions.ts", "src/app/store/orders/orders-item/orders-item.state.ts"], "sourcesContent": ["export class GetOrderById {\n public static readonly type = '[OrdersItem] Get order by id';\n constructor(public id: string) {\n }\n}\n\n\n", "import {Action, Selector, State, StateContext} from '@ngxs/store';\nimport {Injectable} from '@angular/core';\nimport {IOrder} from 'src/app/interfaces/general/profile-definitions/order.interface';\nimport {OrdersService} from 'src/app/modules/orders/orders.service';\nimport {GetOrderById} from './orders-item.actions';\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 IOrdersItemState {\n order: IOrder;\n loading: boolean;\n hasValue: boolean;\n error: any;\n}\n\n@State({\n name: 'ordersItem',\n defaults: {\n order: null,\n loading: false,\n hasValue: false,\n error: null,\n },\n})\n@Injectable()\nexport class OrdersItemState {\n private readonly _errorHandlerArgsInit: IErrorHandlerArgs = {\n error: null,\n appInsightsSrv: this.insights,\n scope: 'OrdersItemState',\n };\n constructor(\n private ticketsService: OrdersService,\n private insights: AppInsightsService,\n ) { }\n\n @Selector()\n public static order(state: IOrdersItemState): IOrder {\n return state.order;\n }\n\n @Selector()\n public static loading(state: IOrdersItemState): boolean {\n return state.loading;\n }\n\n @Selector()\n public static hasValue(state: IOrdersItemState): boolean {\n return state.hasValue;\n }\n\n @Selector()\n public static error(state: IOrdersItemState): any {\n return state.error;\n }\n\n @Action(GetOrderById)\n public async getOrderById(\n ctx: StateContext,\n {id}: GetOrderById\n ): Promise {\n ctx.patchState({loading: true, error: null});\n try {\n const order: IOrder = await firstValueFrom(this.ticketsService.getOrderById(id));\n ctx.patchState({\n order,\n hasValue: !!order,\n loading: false,\n error: null,\n });\n } catch (error) {\n errorHandler({...this._errorHandlerArgsInit, error});\n ctx.patchState({\n loading: false,\n error: error.error ?? error.message ?? error,\n });\n }\n }\n}\n"], "mappings": "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A,CADbG,EAAQ,CAAE,EAAA/B,EAAA,QAAA,IAAA,EAMG4B,EAAA,CADbG,EAAQ,CAAE,EAAA/B,EAAA,UAAA,IAAA,EAMG4B,EAAA,CADbG,EAAQ,CAAE,EAAA/B,EAAA,WAAA,IAAA,EAMG4B,EAAA,CADbG,EAAQ,CAAE,EAAA/B,EAAA,QAAA,IAAA,EA1BFA,EAAe4B,EAAA,CAV3BI,EAAwB,CACrBC,KAAM,aACNC,SAAU,CACN1B,MAAO,KACPE,QAAS,GACTC,SAAU,GACVN,MAAO,MAEd,CAAC,EAEWL,CAAe", "names": ["GetOrderById", "type", "constructor", "id", "OrdersItemState", "constructor", "ticketsService", "insights", "_errorHandlerArgsInit", "error", "appInsightsSrv", "scope", "order", "state", "loading", "hasValue", "getOrderById", "ctx", "_1", "__async", "id", "patchState", "firstValueFrom", "errorHandler", "__spreadProps", "__spreadValues", "message", "\u0275\u0275inject", "OrdersService", "AppInsightsService", "factory", "\u0275fac", "__decorate", "Action", "GetOrderById", "Selector", "State", "name", "defaults"] }