{ "version": 3, "sources": ["src/app/store/partner-data/partner-data.actions.ts", "src/app/store/partner-data/partner-data-items.state.ts"], "sourcesContent": ["export class GetPartnerDataItems {\n public static readonly type = '[PartnerData] Get partner data items';\n\n constructor(public additionalType?: string) {}\n}\n\nexport class GetPartnerDataItem {\n public static readonly type = '[PartnerData] Get partner data item';\n\n constructor(public name?: string) {}\n}\n\nexport class CreatePartnerDataItem {\n public static readonly type = '[PartnerData] Create partner data item';\n}\n\nexport class EditPartnerDataItem {\n public static readonly type = '[PartnerData] Edit partner data item';\n\n constructor(public name: string) {}\n}\n\nexport class DeletePartnerDataItem {\n public static readonly type = '[PartnerData] Delete partner data item';\n\n constructor(public name: string) {}\n}\n\nexport class DeletePartnerDataItemSharing {\n public static readonly type = '[PartnerData] Delete partner data item sharing';\n\n constructor(public name: string) {}\n}\n", "import {Action, Selector, State, StateContext, Store} from '@ngxs/store';\nimport {Injectable} from '@angular/core';\nimport {IPartnerData} from 'src/app/interfaces/general/profile-definitions/partner-data.interface';\nimport {ProfileService} from 'src/app/modules/profile/profile.service';\nimport {\n DeletePartnerDataItemSharing,\n GetPartnerDataItems,\n} from 'src/app/store/partner-data/partner-data.actions';\nimport {ItemPayload} from 'src/app/interfaces/general/responses/item-payload.interface';\nimport {firstValueFrom, Observable, of} from 'rxjs';\nimport {catchError, tap} from 'rxjs/operators';\n\nexport interface IPartnerDataItemsState {\n partnerDataItems: IPartnerData[];\n loading: boolean;\n hasValue: boolean;\n error: any;\n}\n\n@State({\n name: 'partnerDataItemsState',\n defaults: {\n partnerDataItems: [],\n loading: false,\n hasValue: false,\n error: null,\n },\n})\n@Injectable()\nexport class PartnerDataItemsState {\n constructor(\n private profileService: ProfileService,\n private store: Store,\n ) {}\n\n @Selector()\n public static partnerDataItems(state: IPartnerDataItemsState): IPartnerData[] {\n return state.partnerDataItems;\n }\n\n @Selector()\n public static loading(state: IPartnerDataItemsState): boolean {\n return state.loading;\n }\n\n @Selector()\n public static hasValue(state: IPartnerDataItemsState): boolean {\n return state.hasValue;\n }\n\n @Action(GetPartnerDataItems)\n public async getPartnerDataItems(\n ctx: StateContext,\n {additionalType}: GetPartnerDataItems,\n ): Promise {\n try {\n ctx.patchState({loading: true});\n const typeParameter = additionalType === 'all' ? undefined : additionalType;\n const partnerData: ItemPayload = await firstValueFrom(\n this.profileService.getPartnerData(10000, typeParameter),\n );\n ctx.patchState({\n partnerDataItems: partnerData.data,\n hasValue: partnerData.data.length > 0,\n loading: false,\n error: null,\n });\n } catch (e) {\n console.error(e);\n ctx.patchState({\n partnerDataItems: [],\n hasValue: false,\n loading: false,\n error: e.error ?? e.message ?? e.statusText,\n });\n }\n }\n\n @Action(DeletePartnerDataItemSharing)\n public deletePartnerDataSharing(\n ctx: StateContext,\n {name}: IPartnerData,\n ): Observable {\n ctx.patchState({loading: true});\n return this.profileService.removePartnerDataSharing(name).pipe(\n catchError((err) => {\n console.error(err);\n return of(null);\n }),\n tap(() => {\n this.store.dispatch(new GetPartnerDataItems());\n }),\n );\n }\n}\n"], "mappings": "+NAAA,IAAaA,GAAmB,IAAA,CAA1B,MAAOA,CAAmB,QACL,KAAAC,KAAO,sCAAuC,CAErEC,YAAmBC,EAAuB,CAAvB,KAAAA,eAAAA,CAA0B,SAHpCH,CAAmB,GAAA,EA4BhC,IAAaI,GAA4B,IAAA,CAAnC,MAAOA,CAA4B,QACd,KAAAC,KAAO,gDAAiD,CAE/EC,YAAmBC,EAAY,CAAZ,KAAAA,KAAAA,CAAe,SAHzBH,CAA4B,GAAA,ECClC,IAAMI,EAAN,MAAMA,CAAqB,CAC9BC,YACYC,EACAC,EAAY,CADZ,KAAAD,eAAAA,EACA,KAAAC,MAAAA,CACT,CAGW,OAAAC,iBAAiBC,EAA6B,CACxD,OAAOA,EAAMD,gBACjB,CAGc,OAAAE,QAAQD,EAA6B,CAC/C,OAAOA,EAAMC,OACjB,CAGc,OAAAC,SAASF,EAA6B,CAChD,OAAOA,EAAME,QACjB,CAGaC,oBACTC,EACAC,EA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AAE,EAAA5C,EAAA,WAAA,IAAA,EAhBFA,EAAqByC,EAAA,CAVjCI,EAA8B,CAC3BlB,KAAM,wBACNmB,SAAU,CACN1C,iBAAkB,CAAA,EAClBE,QAAS,GACTC,SAAU,GACVc,MAAO,MAEd,CAAC,EAEWrB,CAAqB", "names": ["GetPartnerDataItems", "type", "constructor", "additionalType", "DeletePartnerDataItemSharing", "type", "constructor", "name", "PartnerDataItemsState", "constructor", "profileService", "store", "partnerDataItems", "state", "loading", "hasValue", "getPartnerDataItems", "ctx", "_1", "__async", "additionalType", "patchState", "typeParameter", "undefined", "partnerData", "firstValueFrom", "getPartnerData", "data", "length", "error", "e", "console", "message", "statusText", "deletePartnerDataSharing", "name", "removePartnerDataSharing", "pipe", "catchError", "err", "of", "tap", "dispatch", "GetPartnerDataItems", "\u0275\u0275inject", "ProfileService", "Store", "factory", "\u0275fac", "__decorate", "Action", "DeletePartnerDataItemSharing", "Selector", "State", "defaults"] }