@mx-cartographer/experiences 9.6.10 → 9.6.12
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.
- package/CHANGELOG.md +12 -0
- package/dist/core/stores/FinstrongStore.d.ts +1 -0
- package/dist/core/stores/FinstrongStore.es.js +42 -38
- package/dist/core/stores/FinstrongStore.es.js.map +1 -1
- package/dist/core/stores/GoalStore.d.ts +1 -0
- package/dist/core/stores/GoalStore.es.js +104 -100
- package/dist/core/stores/GoalStore.es.js.map +1 -1
- package/dist/core/stores/HelpStore.d.ts +1 -0
- package/dist/core/stores/HelpStore.es.js +10 -6
- package/dist/core/stores/HelpStore.es.js.map +1 -1
- package/dist/core/stores/InsightsV2Store.d.ts +1 -1
- package/dist/core/stores/InsightsV2Store.es.js.map +1 -1
- package/dist/core/stores/NetWorthStore.d.ts +1 -0
- package/dist/core/stores/NetWorthStore.es.js +12 -8
- package/dist/core/stores/NetWorthStore.es.js.map +1 -1
- package/dist/core/stores/NotificationStore.d.ts +1 -0
- package/dist/core/stores/NotificationStore.es.js +11 -7
- package/dist/core/stores/NotificationStore.es.js.map +1 -1
- package/dist/core/stores/SettingsStore.d.ts +1 -0
- package/dist/core/stores/SettingsStore.es.js +23 -19
- package/dist/core/stores/SettingsStore.es.js.map +1 -1
- package/dist/core/stores/UserStore.d.ts +1 -0
- package/dist/core/stores/UserStore.es.js +10 -6
- package/dist/core/stores/UserStore.es.js.map +1 -1
- package/dist/core/types/Insights.d.ts +17 -0
- package/dist/core/types/Insights.es.js.map +1 -1
- package/dist/core/types/index.d.ts +1 -1
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js +21 -21
- package/dist/insights-v2/actionBlocks/ActionBlockLayer.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +63 -61
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +2 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +59 -38
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/util.d.ts +2 -2
- package/dist/insights-v2/actionBlocks/util.es.js +3 -3
- package/dist/insights-v2/actionBlocks/util.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js +57 -55
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/AccountBlock.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.d.ts +4 -2
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.es.js +54 -23
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/IconComponent.es.js.map +1 -1
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.d.ts +2 -0
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js +14 -10
- package/dist/insights-v2/blocks/ComponentBlocks/AccountBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/components/BaseLayout.es.js +119 -99
- package/dist/insights-v2/components/BaseLayout.es.js.map +1 -1
- package/dist/insights-v2/components/statusIcon.d.ts +7 -0
- package/dist/insights-v2/components/statusIcon.es.js +10 -0
- package/dist/insights-v2/components/statusIcon.es.js.map +1 -0
- package/dist/microinsights/cards/InsightCard.es.js +78 -73
- package/dist/microinsights/cards/InsightCard.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoalStore.es.js","names":[],"sources":["../../../src/core/stores/GoalStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { GoalApi } from '../api'\nimport { upsertByGuid } from '../utils/upsertByGuid'\n\nimport {\n type Goal,\n type MonthlyCashFlowProfile,\n type RetirementGoalAccount,\n TrackType,\n} from '../types'\nimport { getProjectedRetirementDate } from '../utils/GoalsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class GoalStore {\n globalStore: GlobalStore\n api = new GoalApi('/', '')\n\n goals: Goal[] = []\n goalsLoaded: boolean = false\n retirementGoals: Goal[] = []\n retirementGoalsLoaded: boolean = false\n retirementGoalAccounts: RetirementGoalAccount[] = []\n retirementGoalAccountsLoaded: boolean = false\n monthlyCashFlowProfile: MonthlyCashFlowProfile | undefined = undefined\n monthlyCashFlowProfileLoaded: boolean = false\n\n newRetirementGoalAccounts: RetirementGoalAccount[] = []\n\n alert: string = ''\n selectedGoal: Goal | undefined = undefined\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new GoalApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n get allGoals(): Goal[] {\n if (!this.isAllGoalDataLoaded) return []\n\n const goalsCopy = this.globalStore.copyStore.copy.goals\n const userBirthday = this.globalStore.userStore.user.birthday\n return [\n ...this.goals,\n ...this.retirementGoals.map((goal: Goal) => ({\n ...goal,\n amount: goal.target_amount,\n name: goalsCopy.retirement,\n track_type: TrackType.RETIREMENT_TRACK,\n projected_to_complete_at:\n goal.retirement_age && userBirthday\n ? getProjectedRetirementDate(goal.retirement_age, userBirthday)\n : undefined,\n })),\n ] as Goal[]\n }\n\n get orderedGoals(): Goal[] {\n return this.allGoals.slice().sort((a, b) => a.position - b.position)\n }\n\n get debtGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.DEBT_TRACK)\n }\n\n get retirmentGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.RETIREMENT_TRACK)\n }\n\n get savingGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.SAVINGS_TRACK)\n }\n\n get ongoingGoalsForMicroWidget() {\n const ongoingGoals = this.allGoals.filter(\n (goal) =>\n !goal.is_complete &&\n goal.track_type !== TrackType.EMERGENCY_FUND_TRACK &&\n goal.track_type !== null,\n )\n const priorityOrder = [\n TrackType.SAVINGS_TRACK,\n TrackType.DEBT_TRACK,\n TrackType.RETIREMENT_TRACK,\n ]\n return ongoingGoals\n .sort((a, b) => {\n const aIndex = a.track_type ? priorityOrder.indexOf(a.track_type) : -1\n const bIndex = b.track_type ? priorityOrder.indexOf(b.track_type) : -1\n return aIndex - bIndex\n })\n .slice(0, 3)\n }\n\n get isAllGoalDataLoaded() {\n return (\n this.goalsLoaded &&\n this.retirementGoalsLoaded &&\n this.retirementGoalAccountsLoaded &&\n this.monthlyCashFlowProfileLoaded\n )\n }\n\n setGoals = (goals: Goal[]) => {\n this.goals = goals\n this.goalsLoaded = true\n }\n\n setRetirementGoals = (goals: Goal[]) => {\n this.retirementGoals = goals\n this.retirementGoalsLoaded = true\n }\n\n setRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.retirementGoalAccounts = accounts\n this.retirementGoalAccountsLoaded = true\n }\n\n setMonthlyCashFlowProfile = (profile: MonthlyCashFlowProfile) => {\n this.monthlyCashFlowProfile = profile\n this.monthlyCashFlowProfileLoaded = true\n }\n\n loadGoalData = async () => {\n await Promise.all([\n this.loadGoals(),\n this.loadRetirementGoals(),\n this.loadRetirementGoalAccounts(),\n this.loadMonthlyCashFlowProfile(),\n ])\n }\n\n loadGoals = async () => {\n try {\n const goals = await this.api.getGoals()\n this.setGoals(goals)\n } catch (error) {\n console.error('Error occurred while getting goals:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n loadRetirementGoals = async () => {\n try {\n const retirementGoals = await this.api.getRetirementGoals()\n this.setRetirementGoals(retirementGoals)\n } catch (error) {\n console.error('Error occurred while loading retirement goals:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n loadRetirementGoalAccounts = async () => {\n try {\n const retirementGoalAccounts = await this.api.getRetirementGoalAccounts()\n this.setRetirementGoalAccounts(retirementGoalAccounts)\n } catch (error) {\n console.error('Error occurred while loading retirement goal accounts:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n loadMonthlyCashFlowProfile = async () => {\n try {\n const monthlyCashFlowProfile = await this.api.getMonthlyCashFlowProfile()\n this.setMonthlyCashFlowProfile(monthlyCashFlowProfile)\n } catch (error) {\n console.error('Error occurred while loading monthly cash flow profile:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n addGoal = async (goal: Goal) => {\n try {\n const newGoal = await this.api.addGoal(goal)\n this.setGoals(upsertByGuid(this.goals, newGoal))\n } catch (error) {\n console.error('Error occurred while adding goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n addRetirementGoal = async (goal: Goal) => {\n try {\n const newGoal: Goal = await this.api.addRetirementGoal(goal)\n const newAccounts = [] as RetirementGoalAccount[]\n for (const account of this.newRetirementGoalAccounts) {\n const newAccount = await this.api.addRetirementGoalAccount({\n ...account,\n retirement_goal_guid: newGoal.guid,\n })\n newAccounts.push(newAccount)\n }\n this.setNewRetirementGoalAccounts([])\n\n runInAction(() => {\n this.setRetirementGoals(upsertByGuid(this.retirementGoals, newGoal))\n this.setRetirementGoalAccounts(\n newAccounts.reduce((acc, a) => upsertByGuid(acc, a), this.retirementGoalAccounts),\n )\n })\n } catch (error) {\n console.error('Error occurred while adding retirement goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n addRetirementGoalAccount = async (account: RetirementGoalAccount) => {\n try {\n const newAccount = await this.api.addRetirementGoalAccount(account)\n\n runInAction(() => {\n this.retirementGoalAccounts = upsertByGuid(this.retirementGoalAccounts, newAccount)\n })\n } catch (error) {\n console.error('Error occurred while adding retirement goal account:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n deleteGoal = async (guid: string) => {\n try {\n await this.api.removeGoal(guid)\n\n const index = this.goals.findIndex((g) => g.guid === guid)\n if (index >= 0) {\n this.goals.splice(index, 1)\n }\n } catch (error) {\n console.error('Error occurred while deleting goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n deleteRetirementGoal = async (goal: Goal) => {\n try {\n const accounts = this.retirementGoalAccounts.filter(\n (g) => g.retirement_goal_guid === goal.guid,\n )\n for (const account of accounts) {\n await this.deleteRetirementGoalAccount(account.guid)\n }\n await this.api.removeRetirementGoal(goal.guid)\n\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals.splice(index, 1)\n }\n } catch (error) {\n console.error('Error deleting retirement goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n deleteRetirementGoalAccount = async (guid: string) => {\n try {\n await this.api.removeRetirementGoalAccount(guid)\n\n const index = this.retirementGoalAccounts.findIndex((rga) => rga.guid === guid)\n if (index >= 0) {\n this.retirementGoalAccounts.splice(index, 1)\n }\n } catch (error) {\n console.error('Error deleting retirement goal account:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n reorderGoals = async (goals: Goal[]) => {\n try {\n const reordered = (await this.api.reorderGoals(goals)) as Goal[]\n\n runInAction(() => {\n for (const goal of reordered) {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index].position = goal.position\n }\n }\n })\n } catch (error) {\n console.error('Error reordering goals:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n setAlert = (alert: string) => (this.alert = alert)\n\n setNewRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.newRetirementGoalAccounts = accounts\n }\n\n setSelectedGoal = (goal: Goal | undefined) => (this.selectedGoal = goal)\n\n updateGoal = async (goal: Goal) => {\n try {\n const updatedGoal = await this.api.updateGoal(goal)\n\n runInAction(() => {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index] = updatedGoal\n }\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(updatedGoal)\n }\n })\n } catch (error) {\n console.error('Error occurred while updating goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n updateRetirementGoal = async (goal: Goal) => {\n try {\n const updatedRetirementGoal = await this.api.updateRetirementGoal({\n ...goal,\n target_amount: goal.amount,\n })\n\n runInAction(() => {\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals[index] = updatedRetirementGoal\n }\n\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(this.allGoals.find((g) => g.guid === goal.guid))\n }\n })\n } catch (error) {\n console.error('Error occurred while updating retirement goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n updateMonthlyCashFlowProfile = async (profile: MonthlyCashFlowProfile) => {\n try {\n const updatedProfile = await this.api.updateMonthlyCashFlowProfile(profile)\n this.setMonthlyCashFlowProfile(updatedProfile)\n } catch (error) {\n console.error('Error occurred while updating monthly cash flow profile:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n}\n"],"mappings":";;;;;AAeA,IAAa,IAAb,MAAuB;AAAA,EACrB;AAAA,EACA,MAAM,IAAI,EAAQ,KAAK,EAAE;AAAA,EAEzB,QAAgB,CAAC;AAAA,EACjB,cAAuB;AAAA,EACvB,kBAA0B,CAAC;AAAA,EAC3B,wBAAiC;AAAA,EACjC,yBAAkD,CAAC;AAAA,EACnD,+BAAwC;AAAA,EACxC,yBAA6D;AAAA,EAC7D,+BAAwC;AAAA,EAExC,4BAAqD,CAAC;AAAA,EAEtD,QAAgB;AAAA,EAChB,eAAiC;AAAA,EAEjC,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAQ,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAE1F,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,IAAI,WAAmB;AACrB,QAAI,CAAC,KAAK,oBAAqB,QAAO,CAAC;AAEvC,UAAM,IAAY,KAAK,YAAY,UAAU,KAAK,OAC5C,IAAe,KA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AAC;AAAA,IACjE;AAAA,EACF;AAAA,EAEA,uBAAuB,OAAO,MAAe;AAC3C,QAAI;AACF,YAAM,IAAwB,MAAM,KAAK,IAAI,qBAAqB;AAAA,QAChE,GAAG;AAAA,QACH,eAAe,EAAK;AAAA,MACtB,CAAC;AAED,MAAA,EAAA,MAAkB;AAChB,cAAM,IAAQ,KAAK,gBAAgB,UAAA,CAAW,MAAM,EAAE,SAAS,EAAK,IAAI;AACxE,QAAI,KAAS,MACX,KAAK,gBAAgB,CAAA,IAAS,IAG5B,KAAK,cAAc,SAAS,EAAK,QACnC,KAAK,gBAAgB,KAAK,SAAS,KAAA,CAAM,MAAM,EAAE,SAAS,EAAK,IAAI,CAAC;AAAA,MAExE,CAAC;AAAA,IACH,SAAS,GAAO;AACd,cAAQ,MAAM,kDAAkD,CAAK,GACrE,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,YAAY,CAAC;AAAA,IACjE;AAAA,EACF;AAAA,EAEA,+BAA+B,OAAO,MAAoC;AACxE,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,6BAA6B,CAAO;AAC1E,WAAK,0BAA0B,CAAc;AAAA,IAC/C,SAAS,GAAO;AACd,cAAQ,MAAM,4DAA4D,CAAK,GAC/E,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,YAAY,CAAC;AAAA,IACjE;AAAA,EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"GoalStore.es.js","names":[],"sources":["../../../src/core/stores/GoalStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { GoalApi } from '../api'\nimport { upsertByGuid } from '../utils/upsertByGuid'\n\nimport {\n type Goal,\n type MonthlyCashFlowProfile,\n type RetirementGoalAccount,\n TrackType,\n} from '../types'\nimport { getProjectedRetirementDate } from '../utils/GoalsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class GoalStore {\n globalStore: GlobalStore\n api = new GoalApi('/', '')\n\n goals: Goal[] = []\n goalsLoaded: boolean = false\n retirementGoals: Goal[] = []\n retirementGoalsLoaded: boolean = false\n retirementGoalAccounts: RetirementGoalAccount[] = []\n retirementGoalAccountsLoaded: boolean = false\n monthlyCashFlowProfile: MonthlyCashFlowProfile | undefined = undefined\n monthlyCashFlowProfileLoaded: boolean = false\n\n newRetirementGoalAccounts: RetirementGoalAccount[] = []\n\n alert: string = ''\n selectedGoal: Goal | undefined = undefined\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new GoalApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n get allGoals(): Goal[] {\n if (!this.isAllGoalDataLoaded) return []\n\n const goalsCopy = this.globalStore.copyStore.copy.goals\n const userBirthday = this.globalStore.userStore.user.birthday\n return [\n ...this.goals,\n ...this.retirementGoals.map((goal: Goal) => ({\n ...goal,\n amount: goal.target_amount,\n name: goalsCopy.retirement,\n track_type: TrackType.RETIREMENT_TRACK,\n projected_to_complete_at:\n goal.retirement_age && userBirthday\n ? getProjectedRetirementDate(goal.retirement_age, userBirthday)\n : undefined,\n })),\n ] as Goal[]\n }\n\n get orderedGoals(): Goal[] {\n return this.allGoals.slice().sort((a, b) => a.position - b.position)\n }\n\n get debtGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.DEBT_TRACK)\n }\n\n get retirmentGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.RETIREMENT_TRACK)\n }\n\n get savingGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.SAVINGS_TRACK)\n }\n\n get ongoingGoalsForMicroWidget() {\n const ongoingGoals = this.allGoals.filter(\n (goal) =>\n !goal.is_complete &&\n goal.track_type !== TrackType.EMERGENCY_FUND_TRACK &&\n goal.track_type !== null,\n )\n const priorityOrder = [\n TrackType.SAVINGS_TRACK,\n TrackType.DEBT_TRACK,\n TrackType.RETIREMENT_TRACK,\n ]\n return ongoingGoals\n .sort((a, b) => {\n const aIndex = a.track_type ? priorityOrder.indexOf(a.track_type) : -1\n const bIndex = b.track_type ? priorityOrder.indexOf(b.track_type) : -1\n return aIndex - bIndex\n })\n .slice(0, 3)\n }\n\n get isAllGoalDataLoaded() {\n return (\n this.goalsLoaded &&\n this.retirementGoalsLoaded &&\n this.retirementGoalAccountsLoaded &&\n this.monthlyCashFlowProfileLoaded\n )\n }\n\n setGoals = (goals: Goal[]) => {\n this.goals = goals\n this.goalsLoaded = true\n }\n\n setRetirementGoals = (goals: Goal[]) => {\n this.retirementGoals = goals\n this.retirementGoalsLoaded = true\n }\n\n setRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.retirementGoalAccounts = accounts\n this.retirementGoalAccountsLoaded = true\n }\n\n setMonthlyCashFlowProfile = (profile: MonthlyCashFlowProfile) => {\n this.monthlyCashFlowProfile = profile\n this.monthlyCashFlowProfileLoaded = true\n }\n\n loadGoalData = async () => {\n await Promise.all([\n this.loadGoals(),\n this.loadRetirementGoals(),\n this.loadRetirementGoalAccounts(),\n this.loadMonthlyCashFlowProfile(),\n ])\n }\n\n loadGoals = async () => {\n try {\n const goals = await this.api.getGoals()\n this.setGoals(goals)\n } catch (error) {\n this.captureError('loadGoals', error)\n }\n }\n\n loadRetirementGoals = async () => {\n try {\n const retirementGoals = await this.api.getRetirementGoals()\n this.setRetirementGoals(retirementGoals)\n } catch (error) {\n this.captureError('loadRetirementGoals', error)\n }\n }\n\n loadRetirementGoalAccounts = async () => {\n try {\n const retirementGoalAccounts = await this.api.getRetirementGoalAccounts()\n this.setRetirementGoalAccounts(retirementGoalAccounts)\n } catch (error) {\n this.captureError('loadRetirementGoalAccounts', error)\n }\n }\n\n loadMonthlyCashFlowProfile = async () => {\n try {\n const monthlyCashFlowProfile = await this.api.getMonthlyCashFlowProfile()\n this.setMonthlyCashFlowProfile(monthlyCashFlowProfile)\n } catch (error) {\n this.captureError('loadMonthlyCashFlowProfile', error)\n }\n }\n\n addGoal = async (goal: Goal) => {\n try {\n const newGoal = await this.api.addGoal(goal)\n this.setGoals(upsertByGuid(this.goals, newGoal))\n } catch (error) {\n this.captureError('addGoal', error)\n }\n }\n\n addRetirementGoal = async (goal: Goal) => {\n try {\n const newGoal: Goal = await this.api.addRetirementGoal(goal)\n const newAccounts = [] as RetirementGoalAccount[]\n for (const account of this.newRetirementGoalAccounts) {\n const newAccount = await this.api.addRetirementGoalAccount({\n ...account,\n retirement_goal_guid: newGoal.guid,\n })\n newAccounts.push(newAccount)\n }\n this.setNewRetirementGoalAccounts([])\n\n runInAction(() => {\n this.setRetirementGoals(upsertByGuid(this.retirementGoals, newGoal))\n this.setRetirementGoalAccounts(\n newAccounts.reduce((acc, a) => upsertByGuid(acc, a), this.retirementGoalAccounts),\n )\n })\n } catch (error) {\n this.captureError('addRetirementGoal', error)\n }\n }\n\n addRetirementGoalAccount = async (account: RetirementGoalAccount) => {\n try {\n const newAccount = await this.api.addRetirementGoalAccount(account)\n\n runInAction(() => {\n this.retirementGoalAccounts = upsertByGuid(this.retirementGoalAccounts, newAccount)\n })\n } catch (error) {\n this.captureError('addRetirementGoalAccount', error)\n }\n }\n\n deleteGoal = async (guid: string) => {\n try {\n await this.api.removeGoal(guid)\n\n const index = this.goals.findIndex((g) => g.guid === guid)\n if (index >= 0) {\n this.goals.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteGoal', error)\n }\n }\n\n deleteRetirementGoal = async (goal: Goal) => {\n try {\n const accounts = this.retirementGoalAccounts.filter(\n (g) => g.retirement_goal_guid === goal.guid,\n )\n for (const account of accounts) {\n await this.deleteRetirementGoalAccount(account.guid)\n }\n await this.api.removeRetirementGoal(goal.guid)\n\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteRetirementGoal', error)\n }\n }\n\n deleteRetirementGoalAccount = async (guid: string) => {\n try {\n await this.api.removeRetirementGoalAccount(guid)\n\n const index = this.retirementGoalAccounts.findIndex((rga) => rga.guid === guid)\n if (index >= 0) {\n this.retirementGoalAccounts.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteRetirementGoalAccount', error)\n }\n }\n\n reorderGoals = async (goals: Goal[]) => {\n try {\n const reordered = (await this.api.reorderGoals(goals)) as Goal[]\n\n runInAction(() => {\n for (const goal of reordered) {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index].position = goal.position\n }\n }\n })\n } catch (error) {\n this.captureError('reorderGoals', error)\n }\n }\n\n setAlert = (alert: string) => (this.alert = alert)\n\n setNewRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.newRetirementGoalAccounts = accounts\n }\n\n setSelectedGoal = (goal: Goal | undefined) => (this.selectedGoal = goal)\n\n updateGoal = async (goal: Goal) => {\n try {\n const updatedGoal = await this.api.updateGoal(goal)\n\n runInAction(() => {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index] = updatedGoal\n }\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(updatedGoal)\n }\n })\n } catch (error) {\n this.captureError('updateGoal', error)\n }\n }\n\n updateRetirementGoal = async (goal: Goal) => {\n try {\n const updatedRetirementGoal = await this.api.updateRetirementGoal({\n ...goal,\n target_amount: goal.amount,\n })\n\n runInAction(() => {\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals[index] = updatedRetirementGoal\n }\n\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(this.allGoals.find((g) => g.guid === goal.guid))\n }\n })\n } catch (error) {\n this.captureError('updateRetirementGoal', error)\n }\n }\n\n updateMonthlyCashFlowProfile = async (profile: MonthlyCashFlowProfile) => {\n try {\n const updatedProfile = await this.api.updateMonthlyCashFlowProfile(profile)\n this.setMonthlyCashFlowProfile(updatedProfile)\n } catch (error) {\n this.captureError('updateMonthlyCashFlowProfile', error)\n }\n }\n\n private captureError = (action: string, error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,OAAO,MAAe;AAC3C,QAAI;AACF,YAAM,IAAwB,MAAM,KAAK,IAAI,qBAAqB;AAAA,QAChE,GAAG;AAAA,QACH,eAAe,EAAK;AAAA,MACtB,CAAC;AAED,MAAA,EAAA,MAAkB;AAChB,cAAM,IAAQ,KAAK,gBAAgB,UAAA,CAAW,MAAM,EAAE,SAAS,EAAK,IAAI;AACxE,QAAI,KAAS,MACX,KAAK,gBAAgB,CAAA,IAAS,IAG5B,KAAK,cAAc,SAAS,EAAK,QACnC,KAAK,gBAAgB,KAAK,SAAS,KAAA,CAAM,MAAM,EAAE,SAAS,EAAK,IAAI,CAAC;AAAA,MAExE,CAAC;AAAA,IACH,SAAS,GAAO;AACd,WAAK,aAAa,wBAAwB,CAAK;AAAA,IACjD;AAAA,EACF;AAAA,EAEA,+BAA+B,OAAO,MAAoC;AACxE,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,6BAA6B,CAAO;AAC1E,WAAK,0BAA0B,CAAc;AAAA,IAC/C,SAAS,GAAO;AACd,WAAK,aAAa,gCAAgC,CAAK;AAAA,IACzD;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAa,QAAA;AAAA,EAAO,CAAC;AAC3E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HelpApi as
|
|
1
|
+
import { HelpApi as r } from "../api/HelpApi.es.js";
|
|
2
2
|
import { HelpUtil as s } from "../utils/HelpUtil.es.js";
|
|
3
3
|
import { makeAutoObservable as i } from "mobx";
|
|
4
4
|
var l = class {
|
|
@@ -6,18 +6,18 @@ var l = class {
|
|
|
6
6
|
message: "",
|
|
7
7
|
severity: void 0
|
|
8
8
|
};
|
|
9
|
-
api = new
|
|
9
|
+
api = new r("/", "");
|
|
10
10
|
appConfig;
|
|
11
11
|
globalStore;
|
|
12
12
|
isLoading = !1;
|
|
13
13
|
constructor(t) {
|
|
14
|
-
this.globalStore = t, this.api = new
|
|
14
|
+
this.globalStore = t, this.api = new r(t.endpoint, t.sessionToken, t.onError), i(this);
|
|
15
15
|
}
|
|
16
16
|
createSupportTicket = async (t) => {
|
|
17
17
|
try {
|
|
18
18
|
this.isLoading = !0, await this.api.createSupportTicket(t), this.setAlert(this.copy.request_support_submit_success_message, "success");
|
|
19
19
|
} catch (e) {
|
|
20
|
-
|
|
20
|
+
this.captureError("createSupportTicket", e), this.setAlert(this.copy.request_support_submit_failure_message, "error");
|
|
21
21
|
} finally {
|
|
22
22
|
this.isLoading = !1;
|
|
23
23
|
}
|
|
@@ -30,13 +30,17 @@ var l = class {
|
|
|
30
30
|
return this.globalStore.copyStore.copy.help;
|
|
31
31
|
}
|
|
32
32
|
get helpCategories() {
|
|
33
|
-
const { client_communication_profile: t, client_profile: e } = this.globalStore.appDataStore.appData, { help: { category_list:
|
|
33
|
+
const { client_communication_profile: t, client_profile: e } = this.globalStore.appDataStore.appData, { help: { category_list: o } } = this.globalStore.copyStore.copy;
|
|
34
34
|
return s({
|
|
35
35
|
...t,
|
|
36
36
|
...e,
|
|
37
37
|
...this.globalStore.appConfig.config
|
|
38
|
-
},
|
|
38
|
+
}, o);
|
|
39
39
|
}
|
|
40
|
+
captureError = (t, e) => this.globalStore.captureException(e, {
|
|
41
|
+
store: "HelpStore",
|
|
42
|
+
action: t
|
|
43
|
+
});
|
|
40
44
|
};
|
|
41
45
|
export {
|
|
42
46
|
l as HelpStore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelpStore.es.js","names":[],"sources":["../../../src/core/stores/HelpStore.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport { HelpApi } from '../api'\nimport type { Config, HelpCopy, HelpAlertProps, Ticket } from '../types'\nimport { HelpUtil } from '../utils/HelpUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class HelpStore {\n alert: HelpAlertProps = { message: '', severity: undefined }\n api = new HelpApi('/', '')\n appConfig: Config | undefined\n globalStore: GlobalStore\n isLoading: boolean = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new HelpApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n createSupportTicket = async (ticket: Ticket) => {\n try {\n this.isLoading = true\n await this.api.createSupportTicket(ticket)\n this.setAlert(this.copy.request_support_submit_success_message, 'success')\n } catch (error) {\n
|
|
1
|
+
{"version":3,"file":"HelpStore.es.js","names":[],"sources":["../../../src/core/stores/HelpStore.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport { HelpApi } from '../api'\nimport type { Config, HelpCopy, HelpAlertProps, Ticket } from '../types'\nimport { HelpUtil } from '../utils/HelpUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class HelpStore {\n alert: HelpAlertProps = { message: '', severity: undefined }\n api = new HelpApi('/', '')\n appConfig: Config | undefined\n globalStore: GlobalStore\n isLoading: boolean = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new HelpApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n createSupportTicket = async (ticket: Ticket) => {\n try {\n this.isLoading = true\n await this.api.createSupportTicket(ticket)\n this.setAlert(this.copy.request_support_submit_success_message, 'success')\n } catch (error) {\n this.captureError('createSupportTicket', error)\n this.setAlert(this.copy.request_support_submit_failure_message, 'error')\n } finally {\n this.isLoading = false\n }\n }\n\n setAlert = (message: string, severity: HelpAlertProps['severity'] = undefined) =>\n (this.alert = { message, severity })\n\n get copy(): HelpCopy {\n return this.globalStore.copyStore.copy.help\n }\n\n get helpCategories() {\n const { client_communication_profile, client_profile } = this.globalStore.appDataStore.appData\n\n const {\n help: { category_list },\n } = this.globalStore.copyStore.copy\n\n return HelpUtil(\n {\n ...client_communication_profile,\n ...client_profile,\n ...this.globalStore.appConfig.config,\n },\n category_list,\n )\n }\n\n private captureError = (action: string, error: unknown) =>\n this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a,QAAA;AAAA,EAAO,CAAC;AAC3E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GlobalStore } from './GlobalStore';
|
|
2
|
-
export type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar';
|
|
2
|
+
export type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta';
|
|
3
3
|
export interface ActionDrawerState {
|
|
4
4
|
isDrawerOpen: boolean;
|
|
5
5
|
trigger: ActionDrawerTrigger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InsightsV2Store.es.js","names":[],"sources":["../../../src/core/stores/InsightsV2Store.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport type { GlobalStore } from './GlobalStore'\n\nexport type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar'\n\nexport interface ActionDrawerState {\n isDrawerOpen: boolean\n trigger: ActionDrawerTrigger\n guid: string\n /**\n * Block-specific drilldown data for the current drawer SESSION, opaque to the\n * store. Each action block defines and reads its own shape (via\n * useActionContext<T>()). Chart drilldowns put `{ chartBarIndex, tabIndex }`\n * here; CTAs carry none.\n *\n * This is an accumulating bag, not a single owner's value: a nested drawer\n * (e.g. TransactionDetailsBlock opened from a row inside TransactionHistory\n * Block) adds its own key via `setActionContext` ON TOP of whatever the outer\n * drawer already put here, so the outer block's own context survives while the\n * nested block is open. It resets to a clean slate only when a NEW drawer\n * session starts (`openActionDrawer`/`openCtaDrawer`, which fully replace the\n * envelope) — not on every `setActionContext` call.\n */\n context: unknown\n}\n\nexport const CLOSED_ACTION_DRAWER: ActionDrawerState = {\n isDrawerOpen: false,\n trigger: 'primaryCta',\n guid: '',\n context: undefined,\n}\n\ninterface OpenActionDrawerArgs {\n guid: string\n trigger: ActionDrawerTrigger\n context?: unknown\n}\n\n/** Lifecycle of a beat's CTA action (see insights-v2/ctaActions), keyed by beat guid. */\nexport type CtaStatus = 'pending' | 'done' | 'error'\n\n/**\n * UI state shared across the insights-v2 widget tree. Owns the action drawer so\n * cards, charts, and action blocks coordinate through the store instead of prop\n * drilling. The drawer state is a fixed envelope (isDrawerOpen/guid/trigger) plus\n * an opaque `context` bag, so per-block drilldown data never leaks into this shape.\n */\nexport class InsightsV2Store {\n globalStore: GlobalStore\n\n actionDrawer: ActionDrawerState = CLOSED_ACTION_DRAWER\n\n /**\n * CTA action status per beat guid. Keyed by guid (not block) so a block shared by many\n * insights never reflects another card's pending or error state.\n */\n ctaStatus: Record<string, CtaStatus> = {}\n\n /**\n * Per-beat scratch input collected on the card or in its blocks (e.g. the account a user\n * picked before pressing Save), keyed by beat guid. Unlike `actionDrawer.context`, which is\n * replaced whenever any drawer session starts, this survives other cards' drawers opening.\n * CTA steps read it via `disabledWhen` and their `params` callback (`beatContextOf`). Ships\n * ahead of its first block writer (Designate's account picker) on purpose: it is the layer's\n * only way to keep a pick alive across other cards' drawer sessions.\n */\n beatContext: Record<string, Record<string, unknown>> = {}\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n\n makeAutoObservable(this)\n }\n\n setCtaStatus = (guid: string, status: CtaStatus) => {\n this.ctaStatus = { ...this.ctaStatus, [guid]: status }\n }\n\n /** Merges `values` into the beat's scratch input. */\n setBeatContext = (guid: string, values: Record<string, unknown>) => {\n this.beatContext = { ...this.beatContext, [guid]: { ...this.beatContext[guid], ...values } }\n }\n\n /**\n * Merges keys into the current drawer session's context bag — it does NOT\n * replace it. A nested drawer (e.g. a row click inside TransactionHistoryBlock\n * opening TransactionDetailsBlock) calls this to layer its own key (e.g.\n * `transaction_guid`) on top of whatever context the outer drawer already set\n * (e.g. `chartBarIndex`), so the outer block keeps reading its own keys via\n * useActionContext while the nested block is open. The bag only returns to a\n * clean slate when a new drawer session starts via `openActionDrawer`/\n * `openCtaDrawer`, which fully replace the envelope.\n */\n setActionContext = (context: Record<string, unknown>) => {\n this.actionDrawer = {\n ...this.actionDrawer,\n context: {\n ...(this.actionDrawer.context as Record<string, unknown> | undefined),\n ...context,\n },\n }\n }\n\n /**\n * Generic drawer opener — the only opener a new action block needs. Pass the\n * beat guid, the CTA/source that triggered it, and (optionally) a block-specific\n * context object the block reads back via useActionContext.\n */\n openActionDrawer = ({ guid, trigger, context }: OpenActionDrawerArgs) => {\n this.actionDrawer = { isDrawerOpen: true, trigger, guid, context }\n }\n\n /** Convenience opener for CTA drawers (no drilldown context). */\n openCtaDrawer = (guid: string, trigger: 'primaryCta' | 'secondaryCta') => {\n this.openActionDrawer({ guid, trigger })\n }\n\n closeActionDrawer = () => {\n // Preserve `trigger` + `context` so the drawer keeps its variant-specific\n // title/content through the slide-out animation (ActionBlockLayer stays\n // mounted while closing). Only flip isDrawerOpen off and clear the beat guid.\n this.actionDrawer = { ...this.actionDrawer, isDrawerOpen: false, guid: '' }\n }\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"InsightsV2Store.es.js","names":[],"sources":["../../../src/core/stores/InsightsV2Store.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport type { GlobalStore } from './GlobalStore'\n\n// `inDescriptionCta`: the link inside a card's description (`insights_payload.in_description_cta`).\nexport type ActionDrawerTrigger = 'primaryCta' | 'secondaryCta' | 'chartBar' | 'inDescriptionCta'\n\nexport interface ActionDrawerState {\n isDrawerOpen: boolean\n trigger: ActionDrawerTrigger\n guid: string\n /**\n * Block-specific drilldown data for the current drawer SESSION, opaque to the\n * store. Each action block defines and reads its own shape (via\n * useActionContext<T>()). Chart drilldowns put `{ chartBarIndex, tabIndex }`\n * here; CTAs carry none.\n *\n * This is an accumulating bag, not a single owner's value: a nested drawer\n * (e.g. TransactionDetailsBlock opened from a row inside TransactionHistory\n * Block) adds its own key via `setActionContext` ON TOP of whatever the outer\n * drawer already put here, so the outer block's own context survives while the\n * nested block is open. It resets to a clean slate only when a NEW drawer\n * session starts (`openActionDrawer`/`openCtaDrawer`, which fully replace the\n * envelope) — not on every `setActionContext` call.\n */\n context: unknown\n}\n\nexport const CLOSED_ACTION_DRAWER: ActionDrawerState = {\n isDrawerOpen: false,\n trigger: 'primaryCta',\n guid: '',\n context: undefined,\n}\n\ninterface OpenActionDrawerArgs {\n guid: string\n trigger: ActionDrawerTrigger\n context?: unknown\n}\n\n/** Lifecycle of a beat's CTA action (see insights-v2/ctaActions), keyed by beat guid. */\nexport type CtaStatus = 'pending' | 'done' | 'error'\n\n/**\n * UI state shared across the insights-v2 widget tree. Owns the action drawer so\n * cards, charts, and action blocks coordinate through the store instead of prop\n * drilling. The drawer state is a fixed envelope (isDrawerOpen/guid/trigger) plus\n * an opaque `context` bag, so per-block drilldown data never leaks into this shape.\n */\nexport class InsightsV2Store {\n globalStore: GlobalStore\n\n actionDrawer: ActionDrawerState = CLOSED_ACTION_DRAWER\n\n /**\n * CTA action status per beat guid. Keyed by guid (not block) so a block shared by many\n * insights never reflects another card's pending or error state.\n */\n ctaStatus: Record<string, CtaStatus> = {}\n\n /**\n * Per-beat scratch input collected on the card or in its blocks (e.g. the account a user\n * picked before pressing Save), keyed by beat guid. Unlike `actionDrawer.context`, which is\n * replaced whenever any drawer session starts, this survives other cards' drawers opening.\n * CTA steps read it via `disabledWhen` and their `params` callback (`beatContextOf`). Ships\n * ahead of its first block writer (Designate's account picker) on purpose: it is the layer's\n * only way to keep a pick alive across other cards' drawer sessions.\n */\n beatContext: Record<string, Record<string, unknown>> = {}\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n\n makeAutoObservable(this)\n }\n\n setCtaStatus = (guid: string, status: CtaStatus) => {\n this.ctaStatus = { ...this.ctaStatus, [guid]: status }\n }\n\n /** Merges `values` into the beat's scratch input. */\n setBeatContext = (guid: string, values: Record<string, unknown>) => {\n this.beatContext = { ...this.beatContext, [guid]: { ...this.beatContext[guid], ...values } }\n }\n\n /**\n * Merges keys into the current drawer session's context bag — it does NOT\n * replace it. A nested drawer (e.g. a row click inside TransactionHistoryBlock\n * opening TransactionDetailsBlock) calls this to layer its own key (e.g.\n * `transaction_guid`) on top of whatever context the outer drawer already set\n * (e.g. `chartBarIndex`), so the outer block keeps reading its own keys via\n * useActionContext while the nested block is open. The bag only returns to a\n * clean slate when a new drawer session starts via `openActionDrawer`/\n * `openCtaDrawer`, which fully replace the envelope.\n */\n setActionContext = (context: Record<string, unknown>) => {\n this.actionDrawer = {\n ...this.actionDrawer,\n context: {\n ...(this.actionDrawer.context as Record<string, unknown> | undefined),\n ...context,\n },\n }\n }\n\n /**\n * Generic drawer opener — the only opener a new action block needs. Pass the\n * beat guid, the CTA/source that triggered it, and (optionally) a block-specific\n * context object the block reads back via useActionContext.\n */\n openActionDrawer = ({ guid, trigger, context }: OpenActionDrawerArgs) => {\n this.actionDrawer = { isDrawerOpen: true, trigger, guid, context }\n }\n\n /** Convenience opener for CTA drawers (no drilldown context). */\n openCtaDrawer = (guid: string, trigger: 'primaryCta' | 'secondaryCta') => {\n this.openActionDrawer({ guid, trigger })\n }\n\n closeActionDrawer = () => {\n // Preserve `trigger` + `context` so the drawer keeps its variant-specific\n // title/content through the slide-out animation (ActionBlockLayer stays\n // mounted while closing). Only flip isDrawerOpen off and clear the beat guid.\n this.actionDrawer = { ...this.actionDrawer, isDrawerOpen: false, guid: '' }\n }\n}\n"],"mappings":";AA4BA,IAAa,IAA0C;AAAA,EACrD,cAAc;AAAA,EACd,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AACX,GAiBa,IAAb,MAA6B;AAAA,EAC3B;AAAA,EAEA,eAAkC;AAAA,EAMlC,YAAuC,CAAC;AAAA,EAUxC,cAAuD,CAAC;AAAA,EAExD,YAAY,GAA0B;AACpC,SAAK,cAAc,GAEnB,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,eAAA,CAAgB,GAAc,MAAsB;AAClD,SAAK,YAAY;AAAA,MAAE,GAAG,KAAK;AAAA,MAAY,CAAA,CAAA,GAAO;AAAA,IAAO;AAAA,EACvD;AAAA,EAGA,iBAAA,CAAkB,GAAc,MAAoC;AAClE,SAAK,cAAc;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,CAAA,CAAA,GAAO;AAAA,QAAE,GAAG,KAAK,YAAY,CAAA;AAAA,QAAO,GAAG;AAAA,MAAO;AAAA,IAAE;AAAA,EAC7F;AAAA,EAYA,mBAAA,CAAoB,MAAqC;AACvD,SAAK,eAAe;AAAA,MAClB,GAAG,KAAK;AAAA,MACR,SAAS;AAAA,QACP,GAAI,KAAK,aAAa;AAAA,QACtB,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAOA,mBAAA,CAAoB,EAAE,MAAA,GAAM,SAAA,GAAS,SAAA,EAAA,MAAoC;AACvE,SAAK,eAAe;AAAA,MAAE,cAAc;AAAA,MAAM,SAAA;AAAA,MAAS,MAAA;AAAA,MAAM,SAAA;AAAA,IAAQ;AAAA,EACnE;AAAA,EAGA,gBAAA,CAAiB,GAAc,MAA2C;AACxE,SAAK,iBAAiB;AAAA,MAAE,MAAA;AAAA,MAAM,SAAA;AAAA,IAAQ,CAAC;AAAA,EACzC;AAAA,EAEA,oBAAA,MAA0B;AAIxB,SAAK,eAAe;AAAA,MAAE,GAAG,KAAK;AAAA,MAAc,cAAc;AAAA,MAAO,MAAM;AAAA,IAAG;AAAA,EAC5E;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AccountApi as o } from "../api/AccountApi.es.js";
|
|
2
|
-
import { isFeatureEnabled as
|
|
3
|
-
import { buildAssetsLiabilities as
|
|
2
|
+
import { isFeatureEnabled as n } from "../utils/UserUtils.es.js";
|
|
3
|
+
import { buildAssetsLiabilities as c, buildChartData as i, buildGainsLosses as l, filterAccounts as h, flattenBalances as u, getLatestNetWorthData as s, sortByYearMonthAscending as d, toMonthlyAccountBalance as A } from "../utils/NetWorthUtils.es.js";
|
|
4
4
|
import { makeAutoObservable as g } from "mobx";
|
|
5
|
-
var m = "Historical account balances",
|
|
5
|
+
var m = "Historical account balances", D = class {
|
|
6
6
|
globalStore;
|
|
7
7
|
accountsApi = new o("/", "");
|
|
8
8
|
monthlyAccountBalances = [];
|
|
@@ -39,10 +39,10 @@ var m = "Historical account balances", W = class {
|
|
|
39
39
|
return l(this.selectedData);
|
|
40
40
|
}
|
|
41
41
|
get isHistoricalBalancesEnabled() {
|
|
42
|
-
return
|
|
42
|
+
return n(this.globalStore.userStore.userFeatures, m);
|
|
43
43
|
}
|
|
44
44
|
get assetsLiabilities() {
|
|
45
|
-
const { assets: t, liabilities: e, totalAssets: a, totalLiabilities: r } =
|
|
45
|
+
const { assets: t, liabilities: e, totalAssets: a, totalLiabilities: r } = c(this.netWorthData.accounts);
|
|
46
46
|
return {
|
|
47
47
|
netWorth: s(this.netWorthChartData),
|
|
48
48
|
assets: t,
|
|
@@ -60,14 +60,14 @@ var m = "Historical account balances", W = class {
|
|
|
60
60
|
try {
|
|
61
61
|
return await this.accountsApi.getMonthlyAccountBalances(t);
|
|
62
62
|
} catch (e) {
|
|
63
|
-
return
|
|
63
|
+
return this.captureError("getMonthlyAccountBalances", e), [];
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
getHistoricalAccountBalances = async (t) => {
|
|
67
67
|
try {
|
|
68
68
|
return (await this.accountsApi.getHistoricalAccountBalances(t)).map(A);
|
|
69
69
|
} catch (e) {
|
|
70
|
-
return
|
|
70
|
+
return this.captureError("getHistoricalAccountBalances", e), [];
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
setHoveredIndex = (t) => this.hoveredIndex = t;
|
|
@@ -76,10 +76,14 @@ var m = "Historical account balances", W = class {
|
|
|
76
76
|
};
|
|
77
77
|
setSelectedIndex = (t) => this.selectedIndex = t;
|
|
78
78
|
setTimeframe = (t) => this.timeframe = t;
|
|
79
|
+
captureError = (t, e) => this.globalStore.captureException(e, {
|
|
80
|
+
store: "NetWorthStore",
|
|
81
|
+
action: t
|
|
82
|
+
});
|
|
79
83
|
};
|
|
80
84
|
export {
|
|
81
85
|
m as HISTORICAL_ACCOUNT_BALANCES,
|
|
82
|
-
|
|
86
|
+
D as NetWorthStore
|
|
83
87
|
};
|
|
84
88
|
|
|
85
89
|
//# sourceMappingURL=NetWorthStore.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetWorthStore.es.js","names":[],"sources":["../../../src/core/stores/NetWorthStore.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport { AccountApi } from '../api'\nimport type {\n Account,\n AssetsLiabilities,\n DetailedAccount,\n GainsLosses,\n HistoricalAccountBalance,\n MonthlyAccountBalance,\n NetWorth,\n NetWorthData,\n} from '../types'\nimport {\n filterAccounts,\n flattenBalances,\n buildAssetsLiabilities,\n buildChartData,\n buildGainsLosses,\n getLatestNetWorthData,\n sortByYearMonthAscending,\n toMonthlyAccountBalance,\n} from '../utils/NetWorthUtils'\nimport { isFeatureEnabled } from '../utils/UserUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\n// Looks wrong next to the MD_* flags, but isn't: this is the seeded feature_name. Do not rename.\nexport const HISTORICAL_ACCOUNT_BALANCES = 'Historical account balances'\n\nexport class NetWorthStore {\n globalStore: GlobalStore\n accountsApi: AccountApi = new AccountApi('/', '')\n\n monthlyAccountBalances: MonthlyAccountBalance[] = []\n monthlyAccountBalancesLoaded: boolean = false\n hoveredIndex: number = -1\n selectedIndex: number = -1\n timeframe: number = 6 // default timeframe is 6 months\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.accountsApi = new AccountApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n makeAutoObservable(this)\n }\n\n get isNetWorthDataLoaded(): boolean {\n return this.globalStore.accountStore.isAccountDataLoaded && this.monthlyAccountBalancesLoaded\n }\n\n get netWorthAccounts(): DetailedAccount[] {\n return filterAccounts(\n this.globalStore.globalUiStore.selectedAccounts,\n this.globalStore.accountStore.members,\n )\n }\n\n get netWorthData(): NetWorthData {\n return {\n accounts: this.netWorthAccounts,\n monthlyAccountBalances: this.monthlyAccountBalances,\n }\n }\n\n get netWorthChartData(): NetWorth[] {\n return buildChartData(this.netWorthAccounts, this.monthlyAccountBalances, this.timeframe)\n }\n\n get selectedData(): NetWorth | undefined {\n if (!this.netWorthChartData || this.netWorthChartData.length === 0) return undefined\n return this.selectedIndex === -1\n ? getLatestNetWorthData(this.netWorthChartData)\n : this.netWorthChartData[this.selectedIndex]\n }\n\n get hoveredData(): NetWorth | undefined {\n return this.hoveredIndex >= 0 ? this.netWorthChartData[this.hoveredIndex] : undefined\n }\n\n get gainsLosses(): GainsLosses {\n return buildGainsLosses(this.selectedData)\n }\n\n get isHistoricalBalancesEnabled(): boolean {\n return isFeatureEnabled(this.globalStore.userStore.userFeatures, HISTORICAL_ACCOUNT_BALANCES)\n }\n\n get assetsLiabilities(): AssetsLiabilities {\n const { assets, liabilities, totalAssets, totalLiabilities } = buildAssetsLiabilities(\n this.netWorthData.accounts,\n )\n return {\n netWorth: getLatestNetWorthData(this.netWorthChartData),\n assets,\n liabilities,\n totalAssets,\n totalLiabilities,\n }\n }\n\n loadNetWorthData = async () => {\n if (!this.globalStore.accountStore.isAccountDataLoaded) {\n await this.globalStore.accountStore.loadAccountData()\n }\n\n if (!this.globalStore.userStore.userFeaturesLoaded) {\n await this.globalStore.userStore.loadUserFeatures()\n }\n\n const fetchBalances = this.isHistoricalBalancesEnabled\n ? (guid: string) => this.getHistoricalAccountBalances(guid)\n : (guid: string) => this.getMonthlyAccountBalances(guid)\n\n const accountBalances = await Promise.all(\n this.netWorthAccounts.map((account: Account) => fetchBalances(account.guid)),\n )\n\n const monthlyAccountBalances = accountBalances\n .reduce(flattenBalances, [])\n .sort(sortByYearMonthAscending)\n\n this.setMonthlyAccountBalances(monthlyAccountBalances)\n }\n\n getMonthlyAccountBalances = async (accountGuid: string) => {\n try {\n const balances = await this.accountsApi.getMonthlyAccountBalances(accountGuid)\n return balances as MonthlyAccountBalance[]\n } catch (error) {\n
|
|
1
|
+
{"version":3,"file":"NetWorthStore.es.js","names":[],"sources":["../../../src/core/stores/NetWorthStore.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport { AccountApi } from '../api'\nimport type {\n Account,\n AssetsLiabilities,\n DetailedAccount,\n GainsLosses,\n HistoricalAccountBalance,\n MonthlyAccountBalance,\n NetWorth,\n NetWorthData,\n} from '../types'\nimport {\n filterAccounts,\n flattenBalances,\n buildAssetsLiabilities,\n buildChartData,\n buildGainsLosses,\n getLatestNetWorthData,\n sortByYearMonthAscending,\n toMonthlyAccountBalance,\n} from '../utils/NetWorthUtils'\nimport { isFeatureEnabled } from '../utils/UserUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\n// Looks wrong next to the MD_* flags, but isn't: this is the seeded feature_name. Do not rename.\nexport const HISTORICAL_ACCOUNT_BALANCES = 'Historical account balances'\n\nexport class NetWorthStore {\n globalStore: GlobalStore\n accountsApi: AccountApi = new AccountApi('/', '')\n\n monthlyAccountBalances: MonthlyAccountBalance[] = []\n monthlyAccountBalancesLoaded: boolean = false\n hoveredIndex: number = -1\n selectedIndex: number = -1\n timeframe: number = 6 // default timeframe is 6 months\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.accountsApi = new AccountApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n makeAutoObservable(this)\n }\n\n get isNetWorthDataLoaded(): boolean {\n return this.globalStore.accountStore.isAccountDataLoaded && this.monthlyAccountBalancesLoaded\n }\n\n get netWorthAccounts(): DetailedAccount[] {\n return filterAccounts(\n this.globalStore.globalUiStore.selectedAccounts,\n this.globalStore.accountStore.members,\n )\n }\n\n get netWorthData(): NetWorthData {\n return {\n accounts: this.netWorthAccounts,\n monthlyAccountBalances: this.monthlyAccountBalances,\n }\n }\n\n get netWorthChartData(): NetWorth[] {\n return buildChartData(this.netWorthAccounts, this.monthlyAccountBalances, this.timeframe)\n }\n\n get selectedData(): NetWorth | undefined {\n if (!this.netWorthChartData || this.netWorthChartData.length === 0) return undefined\n return this.selectedIndex === -1\n ? getLatestNetWorthData(this.netWorthChartData)\n : this.netWorthChartData[this.selectedIndex]\n }\n\n get hoveredData(): NetWorth | undefined {\n return this.hoveredIndex >= 0 ? this.netWorthChartData[this.hoveredIndex] : undefined\n }\n\n get gainsLosses(): GainsLosses {\n return buildGainsLosses(this.selectedData)\n }\n\n get isHistoricalBalancesEnabled(): boolean {\n return isFeatureEnabled(this.globalStore.userStore.userFeatures, HISTORICAL_ACCOUNT_BALANCES)\n }\n\n get assetsLiabilities(): AssetsLiabilities {\n const { assets, liabilities, totalAssets, totalLiabilities } = buildAssetsLiabilities(\n this.netWorthData.accounts,\n )\n return {\n netWorth: getLatestNetWorthData(this.netWorthChartData),\n assets,\n liabilities,\n totalAssets,\n totalLiabilities,\n }\n }\n\n loadNetWorthData = async () => {\n if (!this.globalStore.accountStore.isAccountDataLoaded) {\n await this.globalStore.accountStore.loadAccountData()\n }\n\n if (!this.globalStore.userStore.userFeaturesLoaded) {\n await this.globalStore.userStore.loadUserFeatures()\n }\n\n const fetchBalances = this.isHistoricalBalancesEnabled\n ? (guid: string) => this.getHistoricalAccountBalances(guid)\n : (guid: string) => this.getMonthlyAccountBalances(guid)\n\n const accountBalances = await Promise.all(\n this.netWorthAccounts.map((account: Account) => fetchBalances(account.guid)),\n )\n\n const monthlyAccountBalances = accountBalances\n .reduce(flattenBalances, [])\n .sort(sortByYearMonthAscending)\n\n this.setMonthlyAccountBalances(monthlyAccountBalances)\n }\n\n getMonthlyAccountBalances = async (accountGuid: string) => {\n try {\n const balances = await this.accountsApi.getMonthlyAccountBalances(accountGuid)\n return balances as MonthlyAccountBalance[]\n } catch (error) {\n this.captureError('getMonthlyAccountBalances', error)\n return []\n }\n }\n\n getHistoricalAccountBalances = async (accountGuid: string): Promise<MonthlyAccountBalance[]> => {\n try {\n const balances: HistoricalAccountBalance[] =\n await this.accountsApi.getHistoricalAccountBalances(accountGuid)\n return balances.map(toMonthlyAccountBalance)\n } catch (error) {\n this.captureError('getHistoricalAccountBalances', error)\n return []\n }\n }\n\n setHoveredIndex = (index: number) => (this.hoveredIndex = index)\n\n setMonthlyAccountBalances = (balances: MonthlyAccountBalance[]) => {\n this.monthlyAccountBalances = balances\n this.monthlyAccountBalancesLoaded = true\n }\n\n setSelectedIndex = (index: number) => (this.selectedIndex = index)\n setTimeframe = (months: number) => (this.timeframe = months)\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'NetWorthStore', action })\n}\n"],"mappings":";;;;AA4BA,IAAa,IAA8B,+BAE9B,IAAb,MAA2B;AAAA,EACzB;AAAA,EACA,cAA0B,IAAI,EAAW,KAAK,EAAE;AAAA,EAEhD,yBAAkD,CAAC;AAAA,EACnD,+BAAwC;AAAA,EACxC,eAAuB;AAAA,EACvB,gBAAwB;AAAA,EACxB,YAAoB;AAAA,EAEpB,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,cAAc,IAAI,EACrB,EAAY,UACZ,EAAY,cACZ,EAAY,OACd,GACA,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,IAAI,uBAAgC;AAClC,WAAO,KAAK,YAAY,aAAa,uBAAuB,KAAK;AAAA,EACnE;AAAA,EAEA,IAAI,mBAAsC;AACxC,WAAO,EACL,KAAK,YAAY,cAAc,kBAC/B,KAAK,YAAY,aAAa,OAChC;AAAA,EACF;AAAA,EAEA,IAAI,eAA6B;AAC/B,WAAO;AAAA,MACL,UAAU,KAAK;AAAA,MACf,wBAAwB,KAAK;AAAA,IAC/B;AAAA,EACF;AAAA,EAEA,IAAI,oBAAgC;AAClC,WAAO,EAAe,KAAK,kBAAkB,KAAK,wBAAwB,KAAK,SAAS;AAAA,EAC1F;AAAA,EAEA,IAAI,eAAqC;AACvC,QAAI,GAAC,KAAK,qBAAqB,KAAK,kBAAkB,WAAW;AACjE,aAAO,KAAK,kBAAkB,KAC1B,EAAsB,KAAK,iBAAiB,IAC5C,KAAK,kBAAkB,KAAK,aAAA;AAAA,EAClC;AAAA,EAEA,IA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AK,YAAY,6BAA6B,CAAW,GACjD,IAAI,CAAuB;AAAA,IAC7C,SAAS,GAAO;AACd,kBAAK,aAAa,gCAAgC,CAAK,GAChD,CAAC;AAAA,IACV;AAAA,EACF;AAAA,EAEA,kBAAA,CAAmB,MAAmB,KAAK,eAAe;AAAA,EAE1D,4BAAA,CAA6B,MAAsC;AACjE,SAAK,yBAAyB,GAC9B,KAAK,+BAA+B;AAAA,EACtC;AAAA,EAEA,mBAAA,CAAoB,MAAmB,KAAK,gBAAgB;AAAA,EAC5D,eAAA,CAAgB,MAAoB,KAAK,YAAY;AAAA,EAErD,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAiB,QAAA;AAAA,EAAO,CAAC;AAC/E"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { NotificationApi as t } from "../api/NotificationApi.es.js";
|
|
2
|
-
import { filterRecentNotifications as
|
|
3
|
-
import { makeAutoObservable as e, observable as
|
|
4
|
-
var
|
|
2
|
+
import { filterRecentNotifications as a } from "../utils/NotificationUtils.es.js";
|
|
3
|
+
import { makeAutoObservable as e, observable as s, runInAction as n } from "mobx";
|
|
4
|
+
var h = class {
|
|
5
5
|
globalStore;
|
|
6
6
|
api = new t("/", "");
|
|
7
7
|
isLoading = !0;
|
|
8
8
|
notifications = [];
|
|
9
9
|
notificationsLoaded = !1;
|
|
10
10
|
constructor(i) {
|
|
11
|
-
this.globalStore = i, this.api = new t(i.endpoint, i.sessionToken, i.onError), e(this, { notifications:
|
|
11
|
+
this.globalStore = i, this.api = new t(i.endpoint, i.sessionToken, i.onError), e(this, { notifications: s });
|
|
12
12
|
}
|
|
13
13
|
get newNotifications() {
|
|
14
14
|
return this.recentNotifications.filter((i) => !i.has_been_viewed);
|
|
15
15
|
}
|
|
16
16
|
get recentNotifications() {
|
|
17
|
-
return
|
|
17
|
+
return a(this.notifications);
|
|
18
18
|
}
|
|
19
19
|
setNotifications = (i) => {
|
|
20
20
|
this.notifications = i, this.notificationsLoaded = !0;
|
|
@@ -25,7 +25,7 @@ var f = class {
|
|
|
25
25
|
const i = await this.api.getNotifications();
|
|
26
26
|
this.setNotifications(i);
|
|
27
27
|
} catch (i) {
|
|
28
|
-
|
|
28
|
+
this.captureError("loadNotifications", i);
|
|
29
29
|
} finally {
|
|
30
30
|
n(() => {
|
|
31
31
|
this.isLoading = !1;
|
|
@@ -38,9 +38,13 @@ var f = class {
|
|
|
38
38
|
updateNotification = async (i) => {
|
|
39
39
|
i.has_been_viewed = !0, await this.api.updateNotification(i);
|
|
40
40
|
};
|
|
41
|
+
captureError = (i, o) => this.globalStore.captureException(o, {
|
|
42
|
+
store: "NotificationStore",
|
|
43
|
+
action: i
|
|
44
|
+
});
|
|
41
45
|
};
|
|
42
46
|
export {
|
|
43
|
-
|
|
47
|
+
h as NotificationStore
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
//# sourceMappingURL=NotificationStore.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationStore.es.js","names":[],"sources":["../../../src/core/stores/NotificationStore.ts"],"sourcesContent":["import { makeAutoObservable, observable, runInAction } from 'mobx'\n\nimport { NotificationApi } from '../api'\nimport { type Notification } from '../types'\nimport { filterRecentNotifications } from '../utils/NotificationUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class NotificationStore {\n globalStore: GlobalStore\n api = new NotificationApi('/', '')\n\n isLoading: boolean = true\n notifications: Notification[] = []\n notificationsLoaded: boolean = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new NotificationApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n makeAutoObservable(this, { notifications: observable })\n }\n\n // Used in Money Dashboard\n get newNotifications(): Notification[] {\n return this.recentNotifications.filter((n) => !n.has_been_viewed)\n }\n\n get recentNotifications(): Notification[] {\n return filterRecentNotifications(this.notifications)\n }\n\n setNotifications = (notifications: Notification[]) => {\n this.notifications = notifications\n this.notificationsLoaded = true\n }\n\n loadNotifications = async () => {\n this.isLoading = true\n try {\n const notifications = await this.api.getNotifications()\n this.setNotifications(notifications)\n } catch (error) {\n
|
|
1
|
+
{"version":3,"file":"NotificationStore.es.js","names":[],"sources":["../../../src/core/stores/NotificationStore.ts"],"sourcesContent":["import { makeAutoObservable, observable, runInAction } from 'mobx'\n\nimport { NotificationApi } from '../api'\nimport { type Notification } from '../types'\nimport { filterRecentNotifications } from '../utils/NotificationUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class NotificationStore {\n globalStore: GlobalStore\n api = new NotificationApi('/', '')\n\n isLoading: boolean = true\n notifications: Notification[] = []\n notificationsLoaded: boolean = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new NotificationApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n makeAutoObservable(this, { notifications: observable })\n }\n\n // Used in Money Dashboard\n get newNotifications(): Notification[] {\n return this.recentNotifications.filter((n) => !n.has_been_viewed)\n }\n\n get recentNotifications(): Notification[] {\n return filterRecentNotifications(this.notifications)\n }\n\n setNotifications = (notifications: Notification[]) => {\n this.notifications = notifications\n this.notificationsLoaded = true\n }\n\n loadNotifications = async () => {\n this.isLoading = true\n try {\n const notifications = await this.api.getNotifications()\n this.setNotifications(notifications)\n } catch (error) {\n this.captureError('loadNotifications', error)\n } finally {\n runInAction(() => {\n this.isLoading = false\n })\n }\n }\n\n markAllAsViewed = async () => {\n // Update on the server\n await this.api.markAllAsViewed()\n }\n\n updateNotification = async (notification: Notification) => {\n notification.has_been_viewed = true\n await this.api.updateNotification(notification)\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'NotificationStore', action })\n}\n"],"mappings":";;;AAQA,IAAa,IAAb,MAA+B;AAAA,EAC7B;AAAA,EACA,MAAM,IAAI,EAAgB,KAAK,EAAE;AAAA,EAEjC,YAAqB;AAAA,EACrB,gBAAgC,CAAC;AAAA,EACjC,sBAA+B;AAAA,EAE/B,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EACb,EAAY,UACZ,EAAY,cACZ,EAAY,OACd,GAEA,EAAmB,MAAM,EAAE,eAAe,EAAW,CAAC;AAAA,EACxD;AAAA,EAGA,IAAI,mBAAmC;AACrC,WAAO,KAAK,oBAAoB,OAAA,CAAQ,MAAM,CAAC,EAAE,eAAe;AAAA,EAClE;AAAA,EAEA,IAAI,sBAAsC;AACxC,WAAO,EAA0B,KAAK,aAAa;AAAA,EACrD;AAAA,EAEA,mBAAA,CAAoB,MAAkC;AACpD,SAAK,gBAAgB,GACrB,KAAK,sBAAsB;AAAA,EAC7B;AAAA,EAEA,oBAAoB,YAAY;AAC9B,SAAK,YAAY;AACjB,QAAI;AACF,YAAM,IAAgB,MAAM,KAAK,IAAI,iBAAiB;AACtD,WAAK,iBAAiB,CAAa;AAAA,IACrC,SAAS,GAAO;AACd,WAAK,aAAa,qBAAqB,CAAK;AAAA,IAC9C,UAAA;AACE,MAAA,EAAA,MAAkB;AAChB,aAAK,YAAY;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,kBAAkB,YAAY;AAE5B,UAAM,KAAK,IAAI,gBAAgB;AAAA,EACjC;AAAA,EAEA,qBAAqB,OAAO,MAA+B;AACzD,IAAA,EAAa,kBAAkB,IAC/B,MAAM,KAAK,IAAI,mBAAmB,CAAY;AAAA,EAChD;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAqB,QAAA;AAAA,EAAO,CAAC;AACnF"}
|
|
@@ -52,5 +52,6 @@ export declare class SettingsStore {
|
|
|
52
52
|
updateUser: (user: User) => Promise<void>;
|
|
53
53
|
updateUserCommunicationProfile: (profile: UserCommunicationProfile) => Promise<void>;
|
|
54
54
|
verifyPhoneToken: (sms_verification_token: string) => Promise<void>;
|
|
55
|
+
private captureError;
|
|
55
56
|
}
|
|
56
57
|
export {};
|
|
@@ -2,8 +2,8 @@ import { AccountNotificationTypes as r, BudgetNotificationTypes as a, InsightNot
|
|
|
2
2
|
import { SettingsApi as n } from "../api/SettingsApi.es.js";
|
|
3
3
|
import { TransactionApi as c } from "../api/TransactionApi.es.js";
|
|
4
4
|
import { augmentNotificationProfiles as u } from "../utils/SettingsUtil.es.js";
|
|
5
|
-
import { makeAutoObservable as
|
|
6
|
-
var
|
|
5
|
+
import { makeAutoObservable as d, runInAction as o } from "mobx";
|
|
6
|
+
var g = class {
|
|
7
7
|
globalStore;
|
|
8
8
|
api = new n("/", "");
|
|
9
9
|
transactionApi = new c("/", "");
|
|
@@ -16,7 +16,7 @@ var _ = class {
|
|
|
16
16
|
selectedRule = void 0;
|
|
17
17
|
transactionRules = [];
|
|
18
18
|
constructor(t) {
|
|
19
|
-
this.globalStore = t, this.api = new n(t.endpoint, t.sessionToken, t.onError), this.transactionApi = new c(t.endpoint, t.sessionToken, t.onError),
|
|
19
|
+
this.globalStore = t, this.api = new n(t.endpoint, t.sessionToken, t.onError), this.transactionApi = new c(t.endpoint, t.sessionToken, t.onError), d(this);
|
|
20
20
|
}
|
|
21
21
|
get accountProfiles() {
|
|
22
22
|
const t = this.globalStore.appDataStore.clientCommunicationProfile;
|
|
@@ -49,7 +49,7 @@ var _ = class {
|
|
|
49
49
|
this.devices.splice(e, 1);
|
|
50
50
|
}), { success: !0 };
|
|
51
51
|
} catch (e) {
|
|
52
|
-
return
|
|
52
|
+
return this.captureError("deleteDevice", e), { success: !1 };
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
deleteTransactionRule = async () => {
|
|
@@ -57,14 +57,14 @@ var _ = class {
|
|
|
57
57
|
try {
|
|
58
58
|
await this.transactionApi.removeTransactionRule(this.selectedRule?.guid), this.setAlert(this.copy.delete_rule_success, "success"), await this.loadTransactionRules();
|
|
59
59
|
} catch (t) {
|
|
60
|
-
|
|
60
|
+
this.captureError("deleteTransactionRule", t), this.setAlert(this.copy.delete_rule_error, "error");
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
generateDeviceToken = async () => {
|
|
64
64
|
try {
|
|
65
65
|
return await this.api.generateDeviceToken();
|
|
66
66
|
} catch (t) {
|
|
67
|
-
|
|
67
|
+
this.captureError("generateDeviceToken", t);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
loadDevices = async () => {
|
|
@@ -74,7 +74,7 @@ var _ = class {
|
|
|
74
74
|
this.devices = t;
|
|
75
75
|
});
|
|
76
76
|
} catch (t) {
|
|
77
|
-
|
|
77
|
+
this.captureError("loadDevices", t);
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
loadNotificationProfiles = async () => {
|
|
@@ -84,7 +84,7 @@ var _ = class {
|
|
|
84
84
|
this.notificationProfiles = t;
|
|
85
85
|
});
|
|
86
86
|
} catch (t) {
|
|
87
|
-
|
|
87
|
+
this.captureError("loadNotificationProfiles", t);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
loadTransactionRules = async () => {
|
|
@@ -94,21 +94,21 @@ var _ = class {
|
|
|
94
94
|
this.transactionRules = t;
|
|
95
95
|
});
|
|
96
96
|
} catch (t) {
|
|
97
|
-
|
|
97
|
+
this.captureError("loadTransactionRules", t);
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
sendEmailVerification = async () => {
|
|
101
101
|
try {
|
|
102
102
|
await this.api.sendEmailVerification(), this.setAlert(this.copy.verification_sent_success, "success");
|
|
103
103
|
} catch (t) {
|
|
104
|
-
|
|
104
|
+
this.captureError("sendEmailVerification", t), this.setAlert(this.copy.verification_sent_error, "error");
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
sendPhoneVerification = async () => {
|
|
108
108
|
try {
|
|
109
109
|
await this.api.sendPhoneVerification(), this.setAlert(this.copy.verification_sent_success, "success");
|
|
110
110
|
} catch (t) {
|
|
111
|
-
|
|
111
|
+
this.captureError("sendPhoneVerification", t), this.setAlert(this.copy.verification_sent_error, "error");
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
setAlert = (t, e = void 0) => this.alert = {
|
|
@@ -122,7 +122,7 @@ var _ = class {
|
|
|
122
122
|
try {
|
|
123
123
|
await this.api.updatePassword(t), this.setAlert(this.copy.password_updated_success, "success");
|
|
124
124
|
} catch (e) {
|
|
125
|
-
|
|
125
|
+
this.captureError("updatePassword", e), this.setAlert(this.copy.password_updated_error, "error");
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
updateDevice = async (t) => {
|
|
@@ -132,7 +132,7 @@ var _ = class {
|
|
|
132
132
|
this.devices[i] = e;
|
|
133
133
|
}), { success: !0 };
|
|
134
134
|
} catch (e) {
|
|
135
|
-
return
|
|
135
|
+
return this.captureError("updateDevice", e), { success: !1 };
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
138
|
updateNotificationProfile = async (t) => {
|
|
@@ -142,21 +142,21 @@ var _ = class {
|
|
|
142
142
|
this.notificationProfiles[i] = e;
|
|
143
143
|
}), !0;
|
|
144
144
|
} catch (e) {
|
|
145
|
-
return
|
|
145
|
+
return this.captureError("updateNotificationProfile", e), !1;
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
updateRuleCategory = async (t) => {
|
|
149
149
|
try {
|
|
150
150
|
await this.transactionApi.updateTransactionRule(t), await this.loadTransactionRules();
|
|
151
151
|
} catch (e) {
|
|
152
|
-
|
|
152
|
+
this.captureError("updateRuleCategory", e);
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
155
|
updateRulePayee = async (t) => {
|
|
156
156
|
try {
|
|
157
157
|
await this.transactionApi.updateTransactionRule(t), this.setAlert(this.copy.edit_payee_success, "success"), await this.loadTransactionRules();
|
|
158
158
|
} catch (e) {
|
|
159
|
-
|
|
159
|
+
this.captureError("updateRulePayee", e), this.setAlert(this.copy.edit_payee_error, "error");
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
updateUser = async (t) => {
|
|
@@ -171,7 +171,7 @@ var _ = class {
|
|
|
171
171
|
const e = await this.api.updateUserCommunicationProfile(t);
|
|
172
172
|
this.globalStore.appDataStore.setUserCommunicationProfile(e);
|
|
173
173
|
} catch (e) {
|
|
174
|
-
|
|
174
|
+
this.captureError("updateUserCommunicationProfile", e);
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
177
|
verifyPhoneToken = async (t) => {
|
|
@@ -180,12 +180,16 @@ var _ = class {
|
|
|
180
180
|
if (!e) throw new Error();
|
|
181
181
|
this.setAlert(this.copy.verified_phone_success, "success");
|
|
182
182
|
} catch (e) {
|
|
183
|
-
|
|
183
|
+
this.captureError("verifyPhoneToken", e), this.setAlert(this.copy.verified_phone_error, "error");
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
|
+
captureError = (t, e) => this.globalStore.captureException(e, {
|
|
187
|
+
store: "SettingsStore",
|
|
188
|
+
action: t
|
|
189
|
+
});
|
|
186
190
|
};
|
|
187
191
|
export {
|
|
188
|
-
|
|
192
|
+
g as SettingsStore
|
|
189
193
|
};
|
|
190
194
|
|
|
191
195
|
//# sourceMappingURL=SettingsStore.es.js.map
|