@flarehr/apollo-super-selection 4.57.45667 → 4.59.46171

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -284,7 +284,7 @@ class TapSubscriber extends datoramaAkita.Subscriber {
284
284
  }
285
285
  }
286
286
 
287
- const AppVersion = '4.57.45667';
287
+ const AppVersion = '4.59.46171';
288
288
 
289
289
  // -------------------------------------------------------------------------------------
290
290
  // guards
@@ -3520,6 +3520,22 @@ class SuperSelectionApi {
3520
3520
  }
3521
3521
  const superSelectionApi = new SuperSelectionApi();
3522
3522
 
3523
+ class SuperCampaignState {
3524
+ constructor(funds) {
3525
+ this.promotedFundsShown = funds;
3526
+ }
3527
+ get PromotedFundIds() {
3528
+ return this.promotedFundsShown.map((p) => p.fundId);
3529
+ }
3530
+ get DefaultFundPosition() {
3531
+ this.promotedFundsShown.filter((value, index) => {
3532
+ if (value.fundType == 'promoted-default') {
3533
+ return index;
3534
+ }
3535
+ });
3536
+ return undefined;
3537
+ }
3538
+ }
3523
3539
  const initialState = {
3524
3540
  apiBaseUrl: Option.none,
3525
3541
  appBaseUrl: Option.none,
@@ -3536,9 +3552,7 @@ const initialState = {
3536
3552
  isDefinedBenefitsEligible: Option.none,
3537
3553
  campaignConnect: Option.none,
3538
3554
  superCampaignEnabled: false,
3539
- superCampaignState: {
3540
- promotedFundsShown: []
3541
- }
3555
+ superCampaignState: undefined
3542
3556
  };
3543
3557
 
3544
3558
  class SuperSelectionAppService {
@@ -3575,6 +3589,9 @@ class SuperSelectionAppService {
3575
3589
  return this._state.appBaseUrl.value;
3576
3590
  }
3577
3591
  get promotedFunds() {
3592
+ if (this.state.superCampaignEnabled && this.superCampaignState !== undefined) {
3593
+ return this.superCampaignState.PromotedFundIds;
3594
+ }
3578
3595
  if (this._state.campaignConnectEnabled && Option.isSome(this._state.campaignConnect)) {
3579
3596
  return this._state.campaignConnect.value.promotedFunds.map((v) => v.fundId);
3580
3597
  }
@@ -3584,6 +3601,9 @@ class SuperSelectionAppService {
3584
3601
  return this._state.promotedFunds.value;
3585
3602
  }
3586
3603
  get promotedDefaultFundPosition() {
3604
+ if (this.state.superCampaignEnabled && this.superCampaignState !== undefined) {
3605
+ return Option.fromNullable(this.superCampaignState.DefaultFundPosition);
3606
+ }
3587
3607
  if (this._state.campaignConnectEnabled && Option.isSome(this._state.campaignConnect)) {
3588
3608
  const index = this._state.campaignConnect.value.promotedFunds.findIndex((v) => (v.type = 'promoted-default'));
3589
3609
  if (index == -1) {
@@ -3599,9 +3619,11 @@ class SuperSelectionAppService {
3599
3619
  return {
3600
3620
  shownFunds: this.promotedFunds,
3601
3621
  promotedDefaultFundPosition: Option.toUndefined(this.promotedDefaultFundPosition),
3602
- promotedFundsConfigSource: Option.isSome(this._state.campaignConnect)
3603
- ? 'campaignConnect'
3604
- : 'superSelection'
3622
+ promotedFundsConfigSource: this.isUsingSuperCampaign
3623
+ ? 'superCampaign'
3624
+ : Option.isSome(this._state.campaignConnect)
3625
+ ? 'campaignConnect'
3626
+ : 'superSelection'
3605
3627
  };
3606
3628
  }
3607
3629
  get definedBenefitsFundId() {
@@ -3665,12 +3687,15 @@ class SuperSelectionAppService {
3665
3687
  this._state.campaignConnect = Option.fromNullable(campaignConnect);
3666
3688
  }
3667
3689
  }
3668
- setSuperCampaignPromotedFundsShown(shownFund) {
3669
- this._state.superCampaignState.promotedFundsShown = shownFund;
3690
+ setSuperCampaignPromotedFundsShown(shownFunds) {
3691
+ this._state.superCampaignState = new SuperCampaignState(shownFunds);
3670
3692
  }
3671
3693
  get superCampaignState() {
3672
3694
  return this._state.superCampaignState;
3673
3695
  }
3696
+ get isUsingSuperCampaign() {
3697
+ return this.state.superCampaignEnabled && this.superCampaignState !== undefined;
3698
+ }
3674
3699
  }
3675
3700
  const superSelectionAppService = new SuperSelectionAppService();
3676
3701
 
@@ -16830,6 +16855,12 @@ class MiscService {
16830
16855
  }
16831
16856
  const miscService = new MiscService();
16832
16857
 
16858
+ const Usi = {
16859
+ clean: (usi) => {
16860
+ return usi.replace(/ /g, '');
16861
+ }
16862
+ };
16863
+
16833
16864
  const SuperCampaignHost = class {
16834
16865
  constructor(hostRef) {
16835
16866
  index.registerInstance(this, hostRef);
@@ -16867,7 +16898,7 @@ const SuperCampaignHost = class {
16867
16898
  // eslint-disable-next-line no-console
16868
16899
  console.log(`$handling super-campaign event: ${(_a = event.detail) === null || _a === void 0 ? void 0 : _a.type}`);
16869
16900
  const promotedFundsShown = event.detail.shownFunds.map((f) => f.fundId);
16870
- superSelectionAppService.setSuperCampaignPromotedFundsShown(promotedFundsShown);
16901
+ superSelectionAppService.setSuperCampaignPromotedFundsShown(event.detail.shownFunds);
16871
16902
  await EventTrackingService.Instance.TrackSuperFundPanelViewedAsync({
16872
16903
  promotedFundsShown,
16873
16904
  defaultFundUsiSet: Option.toUndefined(superSelectionAppService.defaultFundUsi),
@@ -16881,10 +16912,10 @@ const SuperCampaignHost = class {
16881
16912
  if (eventDetails.sender == 'super-campaign') {
16882
16913
  // eslint-disable-next-line no-console
16883
16914
  console.log(`$handling super-campaign event: ${(_a = event.detail) === null || _a === void 0 ? void 0 : _a.type}`);
16884
- const promotedFundsShown = superSelectionAppService.superCampaignState.promotedFundsShown;
16915
+ const promotedFundsShown = this.SuperCampaignState.PromotedFundIds;
16885
16916
  const defaultFundUsiSet = Option.toUndefined(superSelectionAppService.defaultFundUsi);
16886
16917
  await Promise.all([
16887
- eventDetails.fundType == 'PromotedDefault'
16918
+ eventDetails.fundType == 'promoted-default'
16888
16919
  ? await EventTrackingService.Instance.TrackPromotedDefaultSuperFundDetailViewedAsync({
16889
16920
  fundUsi: (_b = eventDetails.fundUsi) !== null && _b !== void 0 ? _b : '',
16890
16921
  fundName: eventDetails.fundName,
@@ -16901,7 +16932,7 @@ const SuperCampaignHost = class {
16901
16932
  defaultFundUsiSet,
16902
16933
  superCampaignEnabled: true
16903
16934
  }),
16904
- miscService.trackClickPromotedTileAsync(eventDetails.fundType == 'PromotedDefault'
16935
+ miscService.trackClickPromotedTileAsync(eventDetails.fundType == 'promoted-default'
16905
16936
  ? {
16906
16937
  promotedDefault: {
16907
16938
  fundId: eventDetails.fundId
@@ -16946,13 +16977,127 @@ const SuperCampaignHost = class {
16946
16977
  });
16947
16978
  }
16948
16979
  };
16980
+ this.promotedFundJoined = async (event) => {
16981
+ var _a;
16982
+ if (event.detail.sender == 'super-campaign') {
16983
+ // eslint-disable-next-line no-console
16984
+ console.log(`$handling super-campaign event: ${(_a = event.detail) === null || _a === void 0 ? void 0 : _a.type}`);
16985
+ const fundJoinInfo = event.detail.fundJoinInfo;
16986
+ switch (fundJoinInfo.fundType) {
16987
+ case 'Promoted':
16988
+ this.handlePromotedFundJoined(fundJoinInfo);
16989
+ break;
16990
+ case 'DefinedBenefits':
16991
+ await this.handleDefinedBenefitsJoined(fundJoinInfo);
16992
+ break;
16993
+ case 'PromotedDefault':
16994
+ this.handlePromotedDefaultFundJoined(fundJoinInfo);
16995
+ break;
16996
+ case 'PromotedDefaultWithJoin':
16997
+ this.handlePromotedDefaultFundWithJoinWasJoined(fundJoinInfo);
16998
+ break;
16999
+ }
17000
+ }
17001
+ return Promise.resolve();
17002
+ };
17003
+ this.getFundName = (fundId) => {
17004
+ return _function.pipe(getFundNameByFundId(fundId), Option.getOrElse(() => ''));
17005
+ };
17006
+ this.stringIsNullOrEmtpty = (s) => {
17007
+ return !(typeof s === 'string' && s.trim().length > 0);
17008
+ };
17009
+ this.handlePromotedFundJoined = (data) => {
17010
+ if (this.stringIsNullOrEmtpty(data.memberNumber) || this.stringIsNullOrEmtpty(data.usi)) {
17011
+ appInsights.trackErrorTrace('Super Campaign did not return (Promoted) memberNumber and/or usi');
17012
+ navigationService.navigateInternally(this.history, SuperSelectionAppRoutes.ChoicePage);
17013
+ return;
17014
+ }
17015
+ const usi = Usi.clean(data.usi);
17016
+ const fundName = this.getFundName(data.fundId);
17017
+ const defaultFundUsiSet = Option.toUndefined(superSelectionAppService.defaultFundUsi);
17018
+ navigationService.navigateInternallyToStandardChoice({
17019
+ history: this.history,
17020
+ fundName,
17021
+ promotedFundId: data.fundId,
17022
+ fundDetails: {
17023
+ type: 'promoted',
17024
+ fundName,
17025
+ fundUsi: usi,
17026
+ memberNumber: data.memberNumber,
17027
+ promotedFundId: data.fundId
17028
+ },
17029
+ handleSubmitFn: async (standardChoiceFormSignature) => {
17030
+ if (data.fundId == fund$8.fundId) {
17031
+ await slateChoiceApi.submitSlateChoiceAsync(Object.assign({ memberNumber: data.memberNumber, memberFirstName: data.memberFirstName, memberFamilyName: data.memberFamilyName, standardChoiceFormSignature,
17032
+ defaultFundUsiSet }, this.PromotedFundsConfig));
17033
+ }
17034
+ else {
17035
+ await promotedFundChoiceApi.submitChoiceAsync(Object.assign({ fundId: data.fundId, memberNumber: data.memberNumber, memberFirstName: data.memberFirstName, memberFamilyName: data.memberFamilyName, usi,
17036
+ standardChoiceFormSignature,
17037
+ defaultFundUsiSet }, this.PromotedFundsConfig));
17038
+ }
17039
+ }
17040
+ });
17041
+ };
17042
+ this.handlePromotedDefaultFundJoined = (data) => {
17043
+ if (this.stringIsNullOrEmtpty(data.usi)) {
17044
+ appInsights.trackErrorTrace('Super Campaign did not return (PromotedDefault) usi');
17045
+ return;
17046
+ }
17047
+ const usi = Usi.clean(data.usi);
17048
+ const fundName = this.getFundName(data.fundId);
17049
+ navigationService.navigateInternallyToStandardChoice({
17050
+ history: this.history,
17051
+ fundName,
17052
+ promotedFundId: data.fundId,
17053
+ fundDetails: {
17054
+ type: 'promotedDefault',
17055
+ fundName,
17056
+ fundUsi: usi,
17057
+ promotedFundId: data.fundId
17058
+ },
17059
+ handleSubmitFn: (standardChoiceFormSignature) => promotedFundChoiceApi.submitDefaultChoiceAsync(Object.assign({ fundId: data.fundId, usi,
17060
+ standardChoiceFormSignature, defaultFundUsiSet: Option.toUndefined(superSelectionAppService.defaultFundUsi) }, this.PromotedFundsConfig))
17061
+ });
17062
+ };
17063
+ this.handlePromotedDefaultFundWithJoinWasJoined = (data) => {
17064
+ if (this.stringIsNullOrEmtpty(data.memberNumber) || this.stringIsNullOrEmtpty(data.usi)) {
17065
+ appInsights.trackErrorTrace('Super Campaign did not return (PromotedDefaultWithJoin) memberNumber and/or usi');
17066
+ return;
17067
+ }
17068
+ const usi = Usi.clean(data.usi);
17069
+ const fundName = this.getFundName(data.fundId);
17070
+ navigationService.navigateInternallyToStandardChoice({
17071
+ history: this.history,
17072
+ fundName,
17073
+ promotedFundId: data.fundId,
17074
+ fundDetails: {
17075
+ type: 'promotedDefaultWithJoin',
17076
+ fundName,
17077
+ fundUsi: usi,
17078
+ memberNumber: data.memberNumber,
17079
+ promotedFundId: data.fundId
17080
+ },
17081
+ handleSubmitFn: (standardChoiceFormSignature) => promotedFundChoiceApi.submitDefaultChoiceWithJoinAsync(Object.assign({ fundId: data.fundId, memberNumber: data.memberNumber, memberFirstName: data.memberFirstName, memberFamilyName: data.memberFamilyName, usi,
17082
+ standardChoiceFormSignature, defaultFundUsiSet: Option.toUndefined(superSelectionAppService.defaultFundUsi) }, this.PromotedFundsConfig))
17083
+ });
17084
+ };
17085
+ this.handleDefinedBenefitsJoined = async (data) => {
17086
+ if (this.stringIsNullOrEmtpty(data.memberNumber) || this.stringIsNullOrEmtpty(data.usi)) {
17087
+ appInsights.trackErrorTrace('Super Campaign did not return (DefinedBenefits) memberNumber and/or usi');
17088
+ return;
17089
+ }
17090
+ await customFundChoiceApi.submitDefinedBenefitsChoiceAsync(Object.assign({ fundUsi: Usi.clean(data.usi), fundId: data.fundId, memberNumber: data.memberNumber, memberElectContributionRatePreTax: data.memberElectContributionRatePreTax, memberElectContributionRatePostTax: data.memberElectContributionRatePostTax }, this.PromotedFundsConfig));
17091
+ superSelectionAppService.markSuperSelectionAsSubmitted();
17092
+ };
16949
17093
  this.superCampaignEventHandlers = {
16950
17094
  'choose-another-fund-requested': this.chooseAnotherFundRequested.bind(this),
16951
17095
  'fund-panel-shown': this.fundPanelShown.bind(this),
16952
17096
  'fund-tile-clicked': this.fundTileClicked.bind(this),
16953
17097
  'fund-pds-viewed': this.fundPdsViewed.bind(this),
16954
17098
  'disclaimer-viewed': this.disclaimerViewed.bind(this),
16955
- 'disclaimer-accepted': this.disclaimerAccepted.bind(this)
17099
+ 'disclaimer-accepted': this.disclaimerAccepted.bind(this),
17100
+ 'promoted-fund-joined': this.promotedFundJoined.bind(this)
16956
17101
  };
16957
17102
  }
16958
17103
  async componentWillLoad() {
@@ -16989,6 +17134,14 @@ const SuperCampaignHost = class {
16989
17134
  const parsedUrl = new URL(url);
16990
17135
  return `${parsedUrl.protocol}//${parsedUrl.hostname}${parsedUrl.port.length > 0 ? `:${parsedUrl.port}` : ''}`;
16991
17136
  }
17137
+ get SuperCampaignState() {
17138
+ if (superSelectionAppService.superCampaignState != undefined)
17139
+ return superSelectionAppService.superCampaignState;
17140
+ throw new Error('Super campaign state has not been initialized');
17141
+ }
17142
+ get PromotedFundsConfig() {
17143
+ return superSelectionAppService.promotedFundsConfig;
17144
+ }
16992
17145
  };
16993
17146
  injectHistory(SuperCampaignHost);
16994
17147
 
@@ -1 +1,5 @@
1
- export {};
1
+ export const Usi = {
2
+ clean: (usi) => {
3
+ return usi.replace(/ /g, '');
4
+ }
5
+ };
@@ -1,13 +1,21 @@
1
1
  import { Component, h, Prop, State } from '@stencil/core';
2
2
  import { injectHistory } from '@stencil/router';
3
+ import { pipe } from 'fp-ts/lib/function';
3
4
  import * as O from 'fp-ts/lib/Option';
4
5
  import { isSome } from 'fp-ts/lib/Option';
6
+ import appInsightsService from '../app-host/services/appinsights.service';
5
7
  import { SuperFundDisclaimerViewedDetail } from '../super-selection-app/api/super-selection-events.model';
8
+ import { getFundNameByFundId } from '../super-selection-app/funds/constants';
9
+ import customFundChoiceApi from '../super-selection-app/funds/custom-fund/api/custom-fund-choice.api';
10
+ import promotedFundChoiceApi from '../super-selection-app/funds/promoted-fund/api/promoted-fund-choice.api';
11
+ import slate from '../super-selection-app/funds/promoted-fund/funds/slate';
12
+ import slateChoiceApi from '../super-selection-app/funds/slate-super/api/slate-choice.api';
6
13
  import { EventTrackingService } from '../super-selection-app/services/event-tracking.service';
7
14
  import miscService from '../super-selection-app/services/misc.service';
8
15
  import navigationService from '../super-selection-app/services/navigation.service';
9
16
  import { SuperSelectionAppRoutes } from '../super-selection-app/services/super-selection-app.routes';
10
17
  import superSelectionAppService from '../super-selection-app/services/super-selection-app.service';
18
+ import { Usi } from './super-campaign-types';
11
19
  export class SuperCampaignHost {
12
20
  constructor() {
13
21
  this.componentLoaded = false;
@@ -44,7 +52,7 @@ export class SuperCampaignHost {
44
52
  // eslint-disable-next-line no-console
45
53
  console.log(`$handling super-campaign event: ${(_a = event.detail) === null || _a === void 0 ? void 0 : _a.type}`);
46
54
  const promotedFundsShown = event.detail.shownFunds.map((f) => f.fundId);
47
- superSelectionAppService.setSuperCampaignPromotedFundsShown(promotedFundsShown);
55
+ superSelectionAppService.setSuperCampaignPromotedFundsShown(event.detail.shownFunds);
48
56
  await EventTrackingService.Instance.TrackSuperFundPanelViewedAsync({
49
57
  promotedFundsShown,
50
58
  defaultFundUsiSet: O.toUndefined(superSelectionAppService.defaultFundUsi),
@@ -58,10 +66,10 @@ export class SuperCampaignHost {
58
66
  if (eventDetails.sender == 'super-campaign') {
59
67
  // eslint-disable-next-line no-console
60
68
  console.log(`$handling super-campaign event: ${(_a = event.detail) === null || _a === void 0 ? void 0 : _a.type}`);
61
- const promotedFundsShown = superSelectionAppService.superCampaignState.promotedFundsShown;
69
+ const promotedFundsShown = this.SuperCampaignState.PromotedFundIds;
62
70
  const defaultFundUsiSet = O.toUndefined(superSelectionAppService.defaultFundUsi);
63
71
  await Promise.all([
64
- eventDetails.fundType == 'PromotedDefault'
72
+ eventDetails.fundType == 'promoted-default'
65
73
  ? await EventTrackingService.Instance.TrackPromotedDefaultSuperFundDetailViewedAsync({
66
74
  fundUsi: (_b = eventDetails.fundUsi) !== null && _b !== void 0 ? _b : '',
67
75
  fundName: eventDetails.fundName,
@@ -78,7 +86,7 @@ export class SuperCampaignHost {
78
86
  defaultFundUsiSet,
79
87
  superCampaignEnabled: true
80
88
  }),
81
- miscService.trackClickPromotedTileAsync(eventDetails.fundType == 'PromotedDefault'
89
+ miscService.trackClickPromotedTileAsync(eventDetails.fundType == 'promoted-default'
82
90
  ? {
83
91
  promotedDefault: {
84
92
  fundId: eventDetails.fundId
@@ -123,13 +131,127 @@ export class SuperCampaignHost {
123
131
  });
124
132
  }
125
133
  };
134
+ this.promotedFundJoined = async (event) => {
135
+ var _a;
136
+ if (event.detail.sender == 'super-campaign') {
137
+ // eslint-disable-next-line no-console
138
+ console.log(`$handling super-campaign event: ${(_a = event.detail) === null || _a === void 0 ? void 0 : _a.type}`);
139
+ const fundJoinInfo = event.detail.fundJoinInfo;
140
+ switch (fundJoinInfo.fundType) {
141
+ case 'Promoted':
142
+ this.handlePromotedFundJoined(fundJoinInfo);
143
+ break;
144
+ case 'DefinedBenefits':
145
+ await this.handleDefinedBenefitsJoined(fundJoinInfo);
146
+ break;
147
+ case 'PromotedDefault':
148
+ this.handlePromotedDefaultFundJoined(fundJoinInfo);
149
+ break;
150
+ case 'PromotedDefaultWithJoin':
151
+ this.handlePromotedDefaultFundWithJoinWasJoined(fundJoinInfo);
152
+ break;
153
+ }
154
+ }
155
+ return Promise.resolve();
156
+ };
157
+ this.getFundName = (fundId) => {
158
+ return pipe(getFundNameByFundId(fundId), O.getOrElse(() => ''));
159
+ };
160
+ this.stringIsNullOrEmtpty = (s) => {
161
+ return !(typeof s === 'string' && s.trim().length > 0);
162
+ };
163
+ this.handlePromotedFundJoined = (data) => {
164
+ if (this.stringIsNullOrEmtpty(data.memberNumber) || this.stringIsNullOrEmtpty(data.usi)) {
165
+ appInsightsService.trackErrorTrace('Super Campaign did not return (Promoted) memberNumber and/or usi');
166
+ navigationService.navigateInternally(this.history, SuperSelectionAppRoutes.ChoicePage);
167
+ return;
168
+ }
169
+ const usi = Usi.clean(data.usi);
170
+ const fundName = this.getFundName(data.fundId);
171
+ const defaultFundUsiSet = O.toUndefined(superSelectionAppService.defaultFundUsi);
172
+ navigationService.navigateInternallyToStandardChoice({
173
+ history: this.history,
174
+ fundName,
175
+ promotedFundId: data.fundId,
176
+ fundDetails: {
177
+ type: 'promoted',
178
+ fundName,
179
+ fundUsi: usi,
180
+ memberNumber: data.memberNumber,
181
+ promotedFundId: data.fundId
182
+ },
183
+ handleSubmitFn: async (standardChoiceFormSignature) => {
184
+ if (data.fundId == slate.fundId) {
185
+ await slateChoiceApi.submitSlateChoiceAsync(Object.assign({ memberNumber: data.memberNumber, memberFirstName: data.memberFirstName, memberFamilyName: data.memberFamilyName, standardChoiceFormSignature,
186
+ defaultFundUsiSet }, this.PromotedFundsConfig));
187
+ }
188
+ else {
189
+ await promotedFundChoiceApi.submitChoiceAsync(Object.assign({ fundId: data.fundId, memberNumber: data.memberNumber, memberFirstName: data.memberFirstName, memberFamilyName: data.memberFamilyName, usi,
190
+ standardChoiceFormSignature,
191
+ defaultFundUsiSet }, this.PromotedFundsConfig));
192
+ }
193
+ }
194
+ });
195
+ };
196
+ this.handlePromotedDefaultFundJoined = (data) => {
197
+ if (this.stringIsNullOrEmtpty(data.usi)) {
198
+ appInsightsService.trackErrorTrace('Super Campaign did not return (PromotedDefault) usi');
199
+ return;
200
+ }
201
+ const usi = Usi.clean(data.usi);
202
+ const fundName = this.getFundName(data.fundId);
203
+ navigationService.navigateInternallyToStandardChoice({
204
+ history: this.history,
205
+ fundName,
206
+ promotedFundId: data.fundId,
207
+ fundDetails: {
208
+ type: 'promotedDefault',
209
+ fundName,
210
+ fundUsi: usi,
211
+ promotedFundId: data.fundId
212
+ },
213
+ handleSubmitFn: (standardChoiceFormSignature) => promotedFundChoiceApi.submitDefaultChoiceAsync(Object.assign({ fundId: data.fundId, usi,
214
+ standardChoiceFormSignature, defaultFundUsiSet: O.toUndefined(superSelectionAppService.defaultFundUsi) }, this.PromotedFundsConfig))
215
+ });
216
+ };
217
+ this.handlePromotedDefaultFundWithJoinWasJoined = (data) => {
218
+ if (this.stringIsNullOrEmtpty(data.memberNumber) || this.stringIsNullOrEmtpty(data.usi)) {
219
+ appInsightsService.trackErrorTrace('Super Campaign did not return (PromotedDefaultWithJoin) memberNumber and/or usi');
220
+ return;
221
+ }
222
+ const usi = Usi.clean(data.usi);
223
+ const fundName = this.getFundName(data.fundId);
224
+ navigationService.navigateInternallyToStandardChoice({
225
+ history: this.history,
226
+ fundName,
227
+ promotedFundId: data.fundId,
228
+ fundDetails: {
229
+ type: 'promotedDefaultWithJoin',
230
+ fundName,
231
+ fundUsi: usi,
232
+ memberNumber: data.memberNumber,
233
+ promotedFundId: data.fundId
234
+ },
235
+ handleSubmitFn: (standardChoiceFormSignature) => promotedFundChoiceApi.submitDefaultChoiceWithJoinAsync(Object.assign({ fundId: data.fundId, memberNumber: data.memberNumber, memberFirstName: data.memberFirstName, memberFamilyName: data.memberFamilyName, usi,
236
+ standardChoiceFormSignature, defaultFundUsiSet: O.toUndefined(superSelectionAppService.defaultFundUsi) }, this.PromotedFundsConfig))
237
+ });
238
+ };
239
+ this.handleDefinedBenefitsJoined = async (data) => {
240
+ if (this.stringIsNullOrEmtpty(data.memberNumber) || this.stringIsNullOrEmtpty(data.usi)) {
241
+ appInsightsService.trackErrorTrace('Super Campaign did not return (DefinedBenefits) memberNumber and/or usi');
242
+ return;
243
+ }
244
+ await customFundChoiceApi.submitDefinedBenefitsChoiceAsync(Object.assign({ fundUsi: Usi.clean(data.usi), fundId: data.fundId, memberNumber: data.memberNumber, memberElectContributionRatePreTax: data.memberElectContributionRatePreTax, memberElectContributionRatePostTax: data.memberElectContributionRatePostTax }, this.PromotedFundsConfig));
245
+ superSelectionAppService.markSuperSelectionAsSubmitted();
246
+ };
126
247
  this.superCampaignEventHandlers = {
127
248
  'choose-another-fund-requested': this.chooseAnotherFundRequested.bind(this),
128
249
  'fund-panel-shown': this.fundPanelShown.bind(this),
129
250
  'fund-tile-clicked': this.fundTileClicked.bind(this),
130
251
  'fund-pds-viewed': this.fundPdsViewed.bind(this),
131
252
  'disclaimer-viewed': this.disclaimerViewed.bind(this),
132
- 'disclaimer-accepted': this.disclaimerAccepted.bind(this)
253
+ 'disclaimer-accepted': this.disclaimerAccepted.bind(this),
254
+ 'promoted-fund-joined': this.promotedFundJoined.bind(this)
133
255
  };
134
256
  }
135
257
  async componentWillLoad() {
@@ -166,6 +288,14 @@ export class SuperCampaignHost {
166
288
  const parsedUrl = new URL(url);
167
289
  return `${parsedUrl.protocol}//${parsedUrl.hostname}${parsedUrl.port.length > 0 ? `:${parsedUrl.port}` : ''}`;
168
290
  }
291
+ get SuperCampaignState() {
292
+ if (superSelectionAppService.superCampaignState != undefined)
293
+ return superSelectionAppService.superCampaignState;
294
+ throw new Error('Super campaign state has not been initialized');
295
+ }
296
+ get PromotedFundsConfig() {
297
+ return superSelectionAppService.promotedFundsConfig;
298
+ }
169
299
  static get is() { return "sss-super-campaign-host"; }
170
300
  static get properties() { return {
171
301
  "history": {
@@ -3,7 +3,7 @@ import { pipe } from 'fp-ts/lib/function';
3
3
  import * as O from 'fp-ts/lib/Option';
4
4
  import jwtDecode from 'jwt-decode';
5
5
  import superSelectionApi from '../api/super-selection.api';
6
- import { initialState } from './super-selection.store';
6
+ import { initialState, SuperCampaignState } from './super-selection.store';
7
7
  export class SuperSelectionAppService {
8
8
  constructor() {
9
9
  const { state, onChange } = createStore(initialState);
@@ -38,6 +38,9 @@ export class SuperSelectionAppService {
38
38
  return this._state.appBaseUrl.value;
39
39
  }
40
40
  get promotedFunds() {
41
+ if (this.state.superCampaignEnabled && this.superCampaignState !== undefined) {
42
+ return this.superCampaignState.PromotedFundIds;
43
+ }
41
44
  if (this._state.campaignConnectEnabled && O.isSome(this._state.campaignConnect)) {
42
45
  return this._state.campaignConnect.value.promotedFunds.map((v) => v.fundId);
43
46
  }
@@ -47,6 +50,9 @@ export class SuperSelectionAppService {
47
50
  return this._state.promotedFunds.value;
48
51
  }
49
52
  get promotedDefaultFundPosition() {
53
+ if (this.state.superCampaignEnabled && this.superCampaignState !== undefined) {
54
+ return O.fromNullable(this.superCampaignState.DefaultFundPosition);
55
+ }
50
56
  if (this._state.campaignConnectEnabled && O.isSome(this._state.campaignConnect)) {
51
57
  const index = this._state.campaignConnect.value.promotedFunds.findIndex((v) => (v.type = 'promoted-default'));
52
58
  if (index == -1) {
@@ -62,9 +68,11 @@ export class SuperSelectionAppService {
62
68
  return {
63
69
  shownFunds: this.promotedFunds,
64
70
  promotedDefaultFundPosition: O.toUndefined(this.promotedDefaultFundPosition),
65
- promotedFundsConfigSource: O.isSome(this._state.campaignConnect)
66
- ? 'campaignConnect'
67
- : 'superSelection'
71
+ promotedFundsConfigSource: this.isUsingSuperCampaign
72
+ ? 'superCampaign'
73
+ : O.isSome(this._state.campaignConnect)
74
+ ? 'campaignConnect'
75
+ : 'superSelection'
68
76
  };
69
77
  }
70
78
  get definedBenefitsFundId() {
@@ -128,11 +136,14 @@ export class SuperSelectionAppService {
128
136
  this._state.campaignConnect = O.fromNullable(campaignConnect);
129
137
  }
130
138
  }
131
- setSuperCampaignPromotedFundsShown(shownFund) {
132
- this._state.superCampaignState.promotedFundsShown = shownFund;
139
+ setSuperCampaignPromotedFundsShown(shownFunds) {
140
+ this._state.superCampaignState = new SuperCampaignState(shownFunds);
133
141
  }
134
142
  get superCampaignState() {
135
143
  return this._state.superCampaignState;
136
144
  }
145
+ get isUsingSuperCampaign() {
146
+ return this.state.superCampaignEnabled && this.superCampaignState !== undefined;
147
+ }
137
148
  }
138
149
  export default new SuperSelectionAppService();
@@ -1,4 +1,20 @@
1
1
  import * as O from 'fp-ts/lib/Option';
2
+ export class SuperCampaignState {
3
+ constructor(funds) {
4
+ this.promotedFundsShown = funds;
5
+ }
6
+ get PromotedFundIds() {
7
+ return this.promotedFundsShown.map((p) => p.fundId);
8
+ }
9
+ get DefaultFundPosition() {
10
+ this.promotedFundsShown.filter((value, index) => {
11
+ if (value.fundType == 'promoted-default') {
12
+ return index;
13
+ }
14
+ });
15
+ return undefined;
16
+ }
17
+ }
2
18
  export const initialState = {
3
19
  apiBaseUrl: O.none,
4
20
  appBaseUrl: O.none,
@@ -15,7 +31,5 @@ export const initialState = {
15
31
  isDefinedBenefitsEligible: O.none,
16
32
  campaignConnect: O.none,
17
33
  superCampaignEnabled: false,
18
- superCampaignState: {
19
- promotedFundsShown: []
20
- }
34
+ superCampaignState: undefined
21
35
  };