@mx-cartographer/experiences 9.7.176 → 9.7.178

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.
Files changed (26) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/dist/core/api/SettingsApi.d.ts +6 -4
  3. package/dist/core/api/SettingsApi.es.js.map +1 -1
  4. package/dist/core/stores/SettingsStore.d.ts +2 -4
  5. package/dist/core/stores/SettingsStore.es.js +13 -8
  6. package/dist/core/stores/SettingsStore.es.js.map +1 -1
  7. package/dist/core/types/User.d.ts +2 -0
  8. package/dist/core/types/localization/SettingsCopy.d.ts +2 -0
  9. package/dist/core/utils/Fetch.d.ts +3 -1
  10. package/dist/core/utils/Fetch.es.js +28 -21
  11. package/dist/core/utils/Fetch.es.js.map +1 -1
  12. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js +75 -74
  13. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/AmountInputModalBlock.es.js.map +1 -1
  14. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js +39 -43
  15. package/dist/insights-v2/actionBlocks/AmountInputModalBlock/CreateBudgetDialog.es.js.map +1 -1
  16. package/dist/insights-v2/actionBlocks/useBlockSave.d.ts +11 -0
  17. package/dist/insights-v2/actionBlocks/useBlockSave.es.js +29 -0
  18. package/dist/insights-v2/actionBlocks/useBlockSave.es.js.map +1 -0
  19. package/dist/settings/components/profile/ProfileTab.es.js +55 -52
  20. package/dist/settings/components/profile/ProfileTab.es.js.map +1 -1
  21. package/dist/settings/components/profile/actions/ResetPasswordAction.es.js +78 -61
  22. package/dist/settings/components/profile/actions/ResetPasswordAction.es.js.map +1 -1
  23. package/dist/settings/constants/Settings.d.ts +2 -0
  24. package/dist/settings/constants/Settings.es.js +13 -11
  25. package/dist/settings/constants/Settings.es.js.map +1 -1
  26. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
+ ## [9.7.178] - 11-17-2026
2
+
3
+ - **ADDED** - Reset Password asks for the current password and shows a specific message when it's wrong (WELL-119)
4
+ - **CHANGED** - Reset Password is hidden for users who don't have a password (WELL-119)
5
+
6
+ ## [9.7.177] - 11-17-2026
7
+
8
+ - **CHANGED** - Insights 2.0 block dialogs (Amount Input, Create Budget) save through one shared hook; no visible change (WEC-2262)
9
+
1
10
  ## [9.7.176] - 11-17-2026
2
11
 
3
- - Disable contribution Save when amount exceeds the maximum (WELL-178)
12
+ - **FIXED** - goal amount validation in the goals widget (WELL-178)
4
13
 
5
14
  ## [9.7.175] - 11-17-2026
6
15
 
@@ -1,5 +1,10 @@
1
1
  import { Fetch } from '../utils';
2
2
  import { UserCommunicationProfile, Device, GlobalErrorHandler, NotificationProfile } from '..';
3
+ export interface UpdatePasswordParams {
4
+ current_password: string;
5
+ new_password: string;
6
+ new_password_again: string;
7
+ }
3
8
  export declare class SettingsApi {
4
9
  fetchInstance: Fetch;
5
10
  constructor(endpoint: string, token: string, onError?: GlobalErrorHandler);
@@ -15,9 +20,6 @@ export declare class SettingsApi {
15
20
  updateDevice: (device: Device) => Promise<any>;
16
21
  updateNotificationProfile: (notificationProfile: NotificationProfile) => Promise<any>;
17
22
  updateUserCommunicationProfile: (userCommunicationProfile: UserCommunicationProfile) => Promise<any>;
18
- updatePassword: (params: {
19
- new_password: string;
20
- new_password_again: string;
21
- }) => Promise<any>;
23
+ updatePassword: (params: UpdatePasswordParams) => Promise<any>;
22
24
  getInsightsNotificationProfiles: () => Promise<any>;
23
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsApi.es.js","names":[],"sources":["../../../src/core/api/SettingsApi.ts"],"sourcesContent":["import { Fetch } from '../utils'\nimport { ApiEndpoints } from '../constants'\nimport { UserCommunicationProfile } from '..'\nimport type { Device, GlobalErrorHandler, NotificationProfile } from '..'\n\nexport class SettingsApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string, onError?: GlobalErrorHandler) {\n this.fetchInstance = new Fetch(endpoint, token, undefined, onError)\n }\n\n deleteDevice = async (guid: string) => {\n return this.fetchInstance.delete(`${ApiEndpoints.DEVICES}/${guid}`).then((data) => data)\n }\n\n generateDeviceToken = async () => {\n return this.fetchInstance\n .get(`${ApiEndpoints.USER}/mobile_token`)\n .then((data) => data.mobile_token)\n }\n\n getDevices = async () => {\n return this.fetchInstance\n .get(ApiEndpoints.DEVICES)\n .then((data) => data.map((item: { device: Device }) => item.device))\n }\n\n getNotificationProfiles = async () => {\n return this.fetchInstance\n .get(ApiEndpoints.NOTIFICATION_PROFILES)\n .then((data) => data.notification_profiles)\n }\n\n // verifications endpoints respond with HTTP status codes; they error otherwise\n sendEmailVerification = async () => {\n return this.fetchInstance.post(ApiEndpoints.EMAIL_VERIFICATIONS)\n }\n\n sendPhoneVerification = async () => {\n return this.fetchInstance.post(ApiEndpoints.PHONE_VERIFICATIONS + '/deliver')\n }\n\n verifyPhoneToken = async (sms_verification_token: string) => {\n return this.fetchInstance\n .post(ApiEndpoints.PHONE_VERIFICATIONS + '/verify', { sms_verification_token })\n .then((res) => ({ verified: res.verified }))\n }\n\n updateDevice = async (device: Device) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.DEVICES}/${device.guid}`, device)\n .then((data) => data.device)\n }\n\n updateNotificationProfile = async (notificationProfile: NotificationProfile) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.NOTIFICATION_PROFILES}/${notificationProfile.guid}`, notificationProfile)\n .then((data) => data.notification_profile)\n }\n\n updateUserCommunicationProfile = async (userCommunicationProfile: UserCommunicationProfile) => {\n return this.fetchInstance\n .put(ApiEndpoints.USER_COMMUNICATION_PROFILE, userCommunicationProfile)\n .then((data) => data.user_communication_profile)\n }\n\n updatePassword = async (params: { new_password: string; new_password_again: string }) => {\n return this.fetchInstance.put(ApiEndpoints.CHANGE_PASSWORD, params)\n }\n\n getInsightsNotificationProfiles = async () => {\n return this.fetchInstance\n .get(`${ApiEndpoints.NOTIFICATION_PROFILES}/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OAAO,MAC/B,KAAK,cACT,IAAI,EAAa,4BAA4B,CAAwB,EACrE,KAAA,CAAM,MAAS,EAAK,0BAA0B;AAAA,EAGnD,iBAAiB,OAAO,MACf,KAAK,cAAc,IAAI,EAAa,iBAAiB,CAAM;AAAA,EAGpE,kCAAkC,YACzB,KAAK,cACT,IAAI,GAAG,EAAa,qBAAA,IAAyB,EAAa,8BAAA,EAAgC,EAC1F,KAAA,CAAM,MAAS,CAAI;AAE1B"}
1
+ {"version":3,"file":"SettingsApi.es.js","names":[],"sources":["../../../src/core/api/SettingsApi.ts"],"sourcesContent":["import { Fetch } from '../utils'\nimport { ApiEndpoints } from '../constants'\nimport { UserCommunicationProfile } from '..'\nimport type { Device, GlobalErrorHandler, NotificationProfile } from '..'\n\nexport interface UpdatePasswordParams {\n current_password: string\n new_password: string\n new_password_again: string\n}\n\nexport class SettingsApi {\n fetchInstance: Fetch\n\n constructor(endpoint: string, token: string, onError?: GlobalErrorHandler) {\n this.fetchInstance = new Fetch(endpoint, token, undefined, onError)\n }\n\n deleteDevice = async (guid: string) => {\n return this.fetchInstance.delete(`${ApiEndpoints.DEVICES}/${guid}`).then((data) => data)\n }\n\n generateDeviceToken = async () => {\n return this.fetchInstance\n .get(`${ApiEndpoints.USER}/mobile_token`)\n .then((data) => data.mobile_token)\n }\n\n getDevices = async () => {\n return this.fetchInstance\n .get(ApiEndpoints.DEVICES)\n .then((data) => data.map((item: { device: Device }) => item.device))\n }\n\n getNotificationProfiles = async () => {\n return this.fetchInstance\n .get(ApiEndpoints.NOTIFICATION_PROFILES)\n .then((data) => data.notification_profiles)\n }\n\n // verifications endpoints respond with HTTP status codes; they error otherwise\n sendEmailVerification = async () => {\n return this.fetchInstance.post(ApiEndpoints.EMAIL_VERIFICATIONS)\n }\n\n sendPhoneVerification = async () => {\n return this.fetchInstance.post(ApiEndpoints.PHONE_VERIFICATIONS + '/deliver')\n }\n\n verifyPhoneToken = async (sms_verification_token: string) => {\n return this.fetchInstance\n .post(ApiEndpoints.PHONE_VERIFICATIONS + '/verify', { sms_verification_token })\n .then((res) => ({ verified: res.verified }))\n }\n\n updateDevice = async (device: Device) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.DEVICES}/${device.guid}`, device)\n .then((data) => data.device)\n }\n\n updateNotificationProfile = async (notificationProfile: NotificationProfile) => {\n return this.fetchInstance\n .put(`${ApiEndpoints.NOTIFICATION_PROFILES}/${notificationProfile.guid}`, notificationProfile)\n .then((data) => data.notification_profile)\n }\n\n updateUserCommunicationProfile = async (userCommunicationProfile: UserCommunicationProfile) => {\n return this.fetchInstance\n .put(ApiEndpoints.USER_COMMUNICATION_PROFILE, userCommunicationProfile)\n .then((data) => data.user_communication_profile)\n }\n\n updatePassword = async (params: UpdatePasswordParams) => {\n return this.fetchInstance.put(ApiEndpoints.CHANGE_PASSWORD, params)\n }\n\n getInsightsNotificationProfiles = async () => {\n return this.fetchInstance\n .get(`${ApiEndpoints.NOTIFICATION_PROFILES}/${ApiEndpoints.INSIGHTS_NOTIFICATION_PROFILES}`)\n .then((data) => data)\n }\n}\n"],"mappings":";;AAWA,IAAa,IAAb,MAAyB;AAAA,EACvB;AAAA,EAEA,YAAY,GAAkB,GAAe,GAA8B;AACzE,SAAK,gBAAgB,IAAI,EAAM,GAAU,GAAO,QAAW,CAAO;AAAA,EACpE;AAAA,EAEA,eAAe,OAAO,MACb,KAAK,cAAc,OAAO,GAAG,EAAa,OAAA,IAAW,CAAA,EAAM,EAAE,KAAA,CAAM,MAAS,CAAI;AAAA,EAGzF,sBAAsB,YACb,KAAK,cACT,IAAI,GAAG,EAAa,IAAA,eAAmB,EACvC,KAAA,CAAM,MAAS,EAAK,YAAY;AAAA,EAGrC,aAAa,YACJ,KAAK,cACT,IAAI,EAAa,OAAO,EACxB,KAAA,CAAM,MAAS,EAAK,IAAA,CAAK,MAA6B,EAAK,MAAM,CAAC;AAAA,EAGvE,0BAA0B,YACjB,KAAK,cACT,IAAI,EAAa,qBAAqB,EACtC,KAAA,CAAM,MAAS,EAAK,qBAAqB;AAAA,EAI9C,wBAAwB,YACf,KAAK,cAAc,KAAK,EAAa,mBAAmB;AAAA,EAGjE,wBAAwB,YACf,KAAK,cAAc,KAAK,EAAa,sBAAsB,UAAU;AAAA,EAG9E,mBAAmB,OAAO,MACjB,KAAK,cACT,KAAK,EAAa,sBAAsB,WAAW,EAAE,wBAAA,EAAuB,CAAC,EAC7E,KAAA,CAAM,OAAS,EAAE,UAAU,EAAI,SAAS,EAAE;AAAA,EAG/C,eAAe,OAAO,MACb,KAAK,cACT,IAAI,GAAG,EAAa,OAAA,IAAW,EAAO,IAAA,IAAQ,CAAM,EACpD,KAAA,CAAM,MAAS,EAAK,MAAM;AAAA,EAG/B,4BAA4B,OAAO,MAC1B,KAAK,cACT,IAAI,GAAG,EAAa,qBAAA,IAAyB,EAAoB,IAAA,IAAQ,CAAmB,EAC5F,KAAA,CAAM,MAAS,EAAK,oBAAoB;AAAA,EAG7C,iCAAiC,OAAO,MAC/B,KAAK,cACT,IAAI,EAAa,4BAA4B,CAAwB,EACrE,KAAA,CAAM,MAAS,EAAK,0BAA0B;AAAA,EAGnD,iBAAiB,OAAO,MACf,KAAK,cAAc,IAAI,EAAa,iBAAiB,CAAM;AAAA,EAGpE,kCAAkC,YACzB,KAAK,cACT,IAAI,GAAG,EAAa,qBAAA,IAAyB,EAAa,8BAAA,EAAgC,EAC1F,KAAA,CAAM,MAAS,CAAI;AAE1B"}
@@ -1,6 +1,7 @@
1
1
  import { AlertProps } from '@mui/material';
2
2
  import { DetailedNotificationProfile, Device, NotificationProfile, SettingsCopy, TransactionRule, User, UserCommunicationProfile } from '../types';
3
3
  import { SettingsApi, TransactionApi } from '../api';
4
+ import { UpdatePasswordParams } from '../api/SettingsApi';
4
5
  import { GlobalStore } from './GlobalStore';
5
6
  interface SettingsAlertProps {
6
7
  message: string;
@@ -38,10 +39,7 @@ export declare class SettingsStore {
38
39
  severity: import('@mui/types').OverridableStringUnion<import('@mui/material').AlertColor, import('@mui/material').AlertPropsColorOverrides> | undefined;
39
40
  };
40
41
  setSelectedRule: (rule?: TransactionRule) => void;
41
- updatePassword: (params: {
42
- new_password: string;
43
- new_password_again: string;
44
- }) => Promise<void>;
42
+ updatePassword: (params: UpdatePasswordParams) => Promise<void>;
45
43
  updateDevice: (device: Device) => Promise<{
46
44
  success: boolean;
47
45
  }>;
@@ -1,9 +1,10 @@
1
- import { AccountNotificationTypes as r, BudgetNotificationTypes as a, InsightNotificationTypes as l } from "../types/Notification.es.js";
1
+ import { ApiError as l } from "../utils/Fetch.es.js";
2
+ import { AccountNotificationTypes as r, BudgetNotificationTypes as a, InsightNotificationTypes as u } from "../types/Notification.es.js";
2
3
  import { SettingsApi as n } from "../api/SettingsApi.es.js";
3
4
  import { TransactionApi as c } from "../api/TransactionApi.es.js";
4
- import { augmentNotificationProfiles as u } from "../utils/SettingsUtil.es.js";
5
- import { makeAutoObservable as d, runInAction as o } from "mobx";
6
- var g = class {
5
+ import { augmentNotificationProfiles as d } from "../utils/SettingsUtil.es.js";
6
+ import { makeAutoObservable as p, runInAction as o } from "mobx";
7
+ var h = (t) => t instanceof l && t.body?.error === "current_password_incorrect", v = class {
7
8
  globalStore;
8
9
  api = new n("/", "");
9
10
  transactionApi = new c("/", "");
@@ -16,7 +17,7 @@ var g = class {
16
17
  selectedRule = void 0;
17
18
  transactionRules = [];
18
19
  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), d(this);
20
+ this.globalStore = t, this.api = new n(t.endpoint, t.sessionToken, t.onError), this.transactionApi = new c(t.endpoint, t.sessionToken, t.onError), p(this);
20
21
  }
21
22
  get accountProfiles() {
22
23
  const t = this.globalStore.appDataStore.clientCommunicationProfile;
@@ -27,7 +28,7 @@ var g = class {
27
28
  return this.detailedNotificationProfiles.filter((e) => e.notification_type === a.BudgetExceeded && t.budget_exceeded_notifications_enabled || e.notification_type === a.BudgetOffTarget && t.budget_off_target_notifications_enabled);
28
29
  }
29
30
  get insightsProfiles() {
30
- return this.detailedNotificationProfiles.filter((t) => Object.values(l).includes(t.notification_type));
31
+ return this.detailedNotificationProfiles.filter((t) => Object.values(u).includes(t.notification_type));
31
32
  }
32
33
  get clientCommunicationProfile() {
33
34
  return this.globalStore.appDataStore.clientCommunicationProfile;
@@ -36,7 +37,7 @@ var g = class {
36
37
  return this.globalStore.copyStore.copy.settings;
37
38
  }
38
39
  get detailedNotificationProfiles() {
39
- return this.globalStore.isInitialized ? u(this.globalStore.accountStore.accounts, this.clientCommunicationProfile, this.copy, this.notificationProfiles, this.userCommunicationsProfile, this.globalStore.userStore.user) : [];
40
+ return this.globalStore.isInitialized ? d(this.globalStore.accountStore.accounts, this.clientCommunicationProfile, this.copy, this.notificationProfiles, this.userCommunicationsProfile, this.globalStore.userStore.user) : [];
40
41
  }
41
42
  get userCommunicationsProfile() {
42
43
  return this.globalStore.appDataStore.userCommunicationProfile;
@@ -122,6 +123,10 @@ var g = class {
122
123
  try {
123
124
  await this.api.updatePassword(t), this.setAlert(this.copy.password_updated_success, "success");
124
125
  } catch (e) {
126
+ if (h(e)) {
127
+ this.setAlert(this.copy.current_password_incorrect, "error");
128
+ return;
129
+ }
125
130
  this.captureError("updatePassword", e), this.setAlert(this.copy.password_updated_error, "error");
126
131
  }
127
132
  };
@@ -189,7 +194,7 @@ var g = class {
189
194
  });
190
195
  };
191
196
  export {
192
- g as SettingsStore
197
+ v as SettingsStore
193
198
  };
194
199
 
195
200
  //# sourceMappingURL=SettingsStore.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsStore.es.js","names":[],"sources":["../../../src/core/stores/SettingsStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { AlertProps } from '@mui/material'\n\nimport {\n AccountNotificationTypes,\n BudgetNotificationTypes,\n InsightNotificationTypes,\n} from '../types'\n\nimport type {\n DetailedNotificationProfile,\n Device,\n NotificationProfile,\n SettingsCopy,\n TransactionRule,\n User,\n UserCommunicationProfile,\n} from '../types'\n\nimport { SettingsApi, TransactionApi } from '../api'\nimport { augmentNotificationProfiles } from '../utils/SettingsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\ninterface SettingsAlertProps {\n message: string\n severity: AlertProps['severity']\n}\n\nexport class SettingsStore {\n globalStore: GlobalStore\n api: SettingsApi = new SettingsApi('/', '')\n transactionApi: TransactionApi = new TransactionApi('/', '')\n\n alert: SettingsAlertProps = { message: '', severity: undefined }\n devices: Device[] = []\n notificationProfiles: NotificationProfile[] = []\n selectedRule: TransactionRule | undefined = undefined\n transactionRules: TransactionRule[] = []\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new SettingsApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n this.transactionApi = new TransactionApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n makeAutoObservable(this)\n }\n\n get accountProfiles() {\n const ccp = this.globalStore.appDataStore.clientCommunicationProfile\n\n // TODO: There has to be a better way to do this, but for now, it works\n return this.detailedNotificationProfiles.filter(\n (np) =>\n (np.notification_type === AccountNotificationTypes.DebtPaymentReminder &&\n ccp.debt_payment_reminder_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountBalanceLow &&\n ccp.low_balance_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountDepositLarge &&\n ccp.large_deposit_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.TransactionExpenseLarge &&\n ccp.large_expense_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.TransactionFeeCharge &&\n ccp.transaction_fee_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.InternationalTransaction &&\n ccp.transaction_is_international_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountDepositLargePosted &&\n ccp.large_deposit_posted_notifications_enabled),\n )\n }\n\n get budgetProfiles() {\n const ccp = this.globalStore.appDataStore.clientCommunicationProfile\n\n // TODO: There has to be a better way to do this, but for now, it works\n return this.detailedNotificationProfiles.filter(\n (np) =>\n (np.notification_type === BudgetNotificationTypes.BudgetExceeded &&\n ccp.budget_exceeded_notifications_enabled) ||\n (np.notification_type === BudgetNotificationTypes.BudgetOffTarget &&\n ccp.budget_off_target_notifications_enabled),\n )\n }\n\n get insightsProfiles() {\n return this.detailedNotificationProfiles.filter((np) =>\n Object.values(InsightNotificationTypes).includes(np.notification_type),\n )\n }\n\n get clientCommunicationProfile() {\n return this.globalStore.appDataStore.clientCommunicationProfile\n }\n\n get copy(): SettingsCopy {\n return this.globalStore.copyStore.copy.settings\n }\n\n get detailedNotificationProfiles(): DetailedNotificationProfile[] {\n // Don't attempt to augment profile if global store is not initialized\n if (!this.globalStore.isInitialized) return []\n\n return augmentNotificationProfiles(\n this.globalStore.accountStore.accounts,\n this.clientCommunicationProfile,\n this.copy,\n this.notificationProfiles,\n this.userCommunicationsProfile,\n this.globalStore.userStore.user,\n )\n }\n\n get userCommunicationsProfile() {\n return this.globalStore.appDataStore.userCommunicationProfile\n }\n\n deleteDevice = async (guid: string) => {\n try {\n await this.api.deleteDevice(guid)\n\n const index = this.devices.findIndex((d) => d.guid === guid)\n if (index >= 0) {\n runInAction(() => {\n this.devices.splice(index, 1)\n })\n }\n\n return { success: true }\n } catch (error) {\n this.captureError('deleteDevice', error)\n return { success: false }\n }\n }\n\n deleteTransactionRule = async () => {\n if (!this.selectedRule) {\n return\n }\n try {\n await this.transactionApi.removeTransactionRule(this.selectedRule?.guid)\n this.setAlert(this.copy.delete_rule_success, 'success')\n await this.loadTransactionRules()\n } catch (error) {\n this.captureError('deleteTransactionRule', error)\n this.setAlert(this.copy.delete_rule_error, 'error')\n }\n }\n\n generateDeviceToken = async () => {\n try {\n return await this.api.generateDeviceToken()\n } catch (error) {\n this.captureError('generateDeviceToken', error)\n }\n return undefined\n }\n\n loadDevices = async () => {\n try {\n const devices = await this.api.getDevices()\n\n runInAction(() => {\n this.devices = devices\n })\n } catch (error) {\n this.captureError('loadDevices', error)\n }\n }\n\n loadNotificationProfiles = async () => {\n try {\n const profiles = await this.api.getNotificationProfiles()\n\n runInAction(() => {\n this.notificationProfiles = profiles\n })\n } catch (error) {\n this.captureError('loadNotificationProfiles', error)\n }\n }\n\n loadTransactionRules = async () => {\n try {\n const rules = await this.transactionApi.getTransactionRules()\n\n runInAction(() => {\n this.transactionRules = rules\n })\n } catch (error) {\n this.captureError('loadTransactionRules', error)\n }\n }\n\n sendEmailVerification = async () => {\n try {\n await this.api.sendEmailVerification()\n this.setAlert(this.copy.verification_sent_success, 'success')\n } catch (error) {\n this.captureError('sendEmailVerification', error)\n this.setAlert(this.copy.verification_sent_error, 'error')\n }\n }\n\n sendPhoneVerification = async () => {\n try {\n await this.api.sendPhoneVerification()\n this.setAlert(this.copy.verification_sent_success, 'success')\n } catch (error) {\n this.captureError('sendPhoneVerification', error)\n this.setAlert(this.copy.verification_sent_error, 'error')\n }\n }\n\n setAlert = (message: string, severity: SettingsAlertProps['severity'] = undefined) =>\n (this.alert = { message, severity })\n\n setSelectedRule = (rule?: TransactionRule) => {\n this.selectedRule = rule\n }\n\n updatePassword = async (params: { new_password: string; new_password_again: string }) => {\n try {\n await this.api.updatePassword(params)\n this.setAlert(this.copy.password_updated_success, 'success')\n } catch (error) {\n this.captureError('updatePassword', error)\n this.setAlert(this.copy.password_updated_error, 'error')\n }\n }\n\n updateDevice = async (device: Device) => {\n try {\n const updatedDevice = await this.api.updateDevice(device)\n\n const index = this.devices.findIndex((d) => d.guid === device.guid)\n if (index >= 0) {\n runInAction(() => {\n this.devices[index] = updatedDevice\n })\n }\n return { success: true }\n } catch (error) {\n this.captureError('updateDevice', error)\n return { success: false }\n }\n }\n\n /** Resolves `true` when the profile was saved, `false` when the API call failed. */\n updateNotificationProfile = async (profile: NotificationProfile): Promise<boolean> => {\n try {\n const updatedProfile = await this.api.updateNotificationProfile(profile)\n\n const index = this.notificationProfiles.findIndex((p) => p.guid === profile.guid)\n if (index >= 0) {\n runInAction(() => {\n this.notificationProfiles[index] = updatedProfile\n })\n }\n return true\n } catch (error) {\n this.captureError('updateNotificationProfile', error)\n return false\n }\n }\n\n updateRuleCategory = async (rule: TransactionRule) => {\n try {\n await this.transactionApi.updateTransactionRule(rule)\n await this.loadTransactionRules()\n } catch (error) {\n this.captureError('updateRuleCategory', error)\n }\n }\n\n updateRulePayee = async (rule: TransactionRule) => {\n try {\n await this.transactionApi.updateTransactionRule(rule)\n this.setAlert(this.copy.edit_payee_success, 'success')\n await this.loadTransactionRules()\n } catch (error) {\n this.captureError('updateRulePayee', error)\n this.setAlert(this.copy.edit_payee_error, 'error')\n }\n }\n\n updateUser = async (user: User) => {\n try {\n await this.globalStore.userStore.updateUser(user)\n this.setAlert(this.copy.information_updated_success, 'success')\n } catch {\n // Error is already logged and captured in UserStore.updateUser\n this.setAlert(this.copy.information_updated_error, 'error')\n }\n }\n\n updateUserCommunicationProfile = async (profile: UserCommunicationProfile) => {\n try {\n const updatedProfile = await this.api.updateUserCommunicationProfile(profile)\n\n this.globalStore.appDataStore.setUserCommunicationProfile(updatedProfile)\n } catch (error) {\n this.captureError('updateUserCommunicationProfile', error)\n }\n }\n\n verifyPhoneToken = async (sms_verification_token: string) => {\n try {\n const { verified } = await this.api.verifyPhoneToken(sms_verification_token)\n if (!verified) {\n throw new Error()\n }\n this.setAlert(this.copy.verified_phone_success, 'success')\n } catch (error) {\n this.captureError('verifyPhoneToken', error)\n this.setAlert(this.copy.verified_phone_error, 'error')\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'SettingsStore', action })\n}\n"],"mappings":";;;;;AA8BA,IAAa,IAAb,MAA2B;AAAA,EACzB;AAAA,EACA,MAAmB,IAAI,EAAY,KAAK,EAAE;AAAA,EAC1C,iBAAiC,IAAI,EAAe,KAAK,EAAE;AAAA,EAE3D,QAA4B;AAAA,IAAE,SAAS;AAAA,IAAI,UAAU;AAAA,EAAU;AAAA,EAC/D,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AAa,mBAAmB,CAAK,GAC1C,KAAK,SAAS,KAAK,KAAK,kBAAkB,OAAO;AAAA,IACnD;AAAA,EACF;AAAA,EAEA,aAAa,OAAO,MAAe;AACjC,QAAI;AACF,YAAM,KAAK,YAAY,UAAU,WAAW,CAAI,GAChD,KAAK,SAAS,KAAK,KAAK,6BAA6B,SAAS;AAAA,IAChE,QAAQ;AAEN,WAAK,SAAS,KAAK,KAAK,2BAA2B,OAAO;AAAA,IAC5D;AAAA,EACF;AAAA,EAEA,iCAAiC,OAAO,MAAsC;AAC5E,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,+BAA+B,CAAO;AAE5E,WAAK,YAAY,aAAa,4BAA4B,CAAc;AAAA,IAC1E,SAAS,GAAO;AACd,WAAK,aAAa,kCAAkC,CAAK;AAAA,IAC3D;AAAA,EACF;AAAA,EAEA,mBAAmB,OAAO,MAAmC;AAC3D,QAAI;AACF,YAAM,EAAE,UAAA,EAAA,IAAa,MAAM,KAAK,IAAI,iBAAiB,CAAsB;AAC3E,UAAI,CAAC,EACH,OAAM,IAAI,MAAM;AAElB,WAAK,SAAS,KAAK,KAAK,wBAAwB,SAAS;AAAA,IAC3D,SAAS,GAAO;AACd,WAAK,aAAa,oBAAoB,CAAK,GAC3C,KAAK,SAAS,KAAK,KAAK,sBAAsB,OAAO;AAAA,IACvD;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAiB,QAAA;AAAA,EAAO,CAAC;AAC/E"}
1
+ {"version":3,"file":"SettingsStore.es.js","names":[],"sources":["../../../src/core/stores/SettingsStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { AlertProps } from '@mui/material'\n\nimport {\n AccountNotificationTypes,\n BudgetNotificationTypes,\n InsightNotificationTypes,\n} from '../types'\n\nimport type {\n DetailedNotificationProfile,\n Device,\n NotificationProfile,\n SettingsCopy,\n TransactionRule,\n User,\n UserCommunicationProfile,\n} from '../types'\n\nimport { SettingsApi, TransactionApi } from '../api'\nimport type { UpdatePasswordParams } from '../api/SettingsApi'\nimport { ApiError } from '../utils/Fetch'\nimport { augmentNotificationProfiles } from '../utils/SettingsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\ninterface SettingsAlertProps {\n message: string\n severity: AlertProps['severity']\n}\n\n// The server rejects a wrong current password with { error: 'current_password_incorrect' } (422).\n// Matching on the code keeps other rejections (e.g. a new password that's too common) generic.\nconst isCurrentPasswordIncorrect = (error: unknown) =>\n error instanceof ApiError &&\n (error.body as { error?: unknown } | undefined)?.error === 'current_password_incorrect'\n\nexport class SettingsStore {\n globalStore: GlobalStore\n api: SettingsApi = new SettingsApi('/', '')\n transactionApi: TransactionApi = new TransactionApi('/', '')\n\n alert: SettingsAlertProps = { message: '', severity: undefined }\n devices: Device[] = []\n notificationProfiles: NotificationProfile[] = []\n selectedRule: TransactionRule | undefined = undefined\n transactionRules: TransactionRule[] = []\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new SettingsApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n this.transactionApi = new TransactionApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n makeAutoObservable(this)\n }\n\n get accountProfiles() {\n const ccp = this.globalStore.appDataStore.clientCommunicationProfile\n\n // TODO: There has to be a better way to do this, but for now, it works\n return this.detailedNotificationProfiles.filter(\n (np) =>\n (np.notification_type === AccountNotificationTypes.DebtPaymentReminder &&\n ccp.debt_payment_reminder_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountBalanceLow &&\n ccp.low_balance_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountDepositLarge &&\n ccp.large_deposit_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.TransactionExpenseLarge &&\n ccp.large_expense_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.TransactionFeeCharge &&\n ccp.transaction_fee_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.InternationalTransaction &&\n ccp.transaction_is_international_notifications_enabled) ||\n (np.notification_type === AccountNotificationTypes.AccountDepositLargePosted &&\n ccp.large_deposit_posted_notifications_enabled),\n )\n }\n\n get budgetProfiles() {\n const ccp = this.globalStore.appDataStore.clientCommunicationProfile\n\n // TODO: There has to be a better way to do this, but for now, it works\n return this.detailedNotificationProfiles.filter(\n (np) =>\n (np.notification_type === BudgetNotificationTypes.BudgetExceeded &&\n ccp.budget_exceeded_notifications_enabled) ||\n (np.notification_type === BudgetNotificationTypes.BudgetOffTarget &&\n ccp.budget_off_target_notifications_enabled),\n )\n }\n\n get insightsProfiles() {\n return this.detailedNotificationProfiles.filter((np) =>\n Object.values(InsightNotificationTypes).includes(np.notification_type),\n )\n }\n\n get clientCommunicationProfile() {\n return this.globalStore.appDataStore.clientCommunicationProfile\n }\n\n get copy(): SettingsCopy {\n return this.globalStore.copyStore.copy.settings\n }\n\n get detailedNotificationProfiles(): DetailedNotificationProfile[] {\n // Don't attempt to augment profile if global store is not initialized\n if (!this.globalStore.isInitialized) return []\n\n return augmentNotificationProfiles(\n this.globalStore.accountStore.accounts,\n this.clientCommunicationProfile,\n this.copy,\n this.notificationProfiles,\n this.userCommunicationsProfile,\n this.globalStore.userStore.user,\n )\n }\n\n get userCommunicationsProfile() {\n return this.globalStore.appDataStore.userCommunicationProfile\n }\n\n deleteDevice = async (guid: string) => {\n try {\n await this.api.deleteDevice(guid)\n\n const index = this.devices.findIndex((d) => d.guid === guid)\n if (index >= 0) {\n runInAction(() => {\n this.devices.splice(index, 1)\n })\n }\n\n return { success: true }\n } catch (error) {\n this.captureError('deleteDevice', error)\n return { success: false }\n }\n }\n\n deleteTransactionRule = async () => {\n if (!this.selectedRule) {\n return\n }\n try {\n await this.transactionApi.removeTransactionRule(this.selectedRule?.guid)\n this.setAlert(this.copy.delete_rule_success, 'success')\n await this.loadTransactionRules()\n } catch (error) {\n this.captureError('deleteTransactionRule', error)\n this.setAlert(this.copy.delete_rule_error, 'error')\n }\n }\n\n generateDeviceToken = async () => {\n try {\n return await this.api.generateDeviceToken()\n } catch (error) {\n this.captureError('generateDeviceToken', error)\n }\n return undefined\n }\n\n loadDevices = async () => {\n try {\n const devices = await this.api.getDevices()\n\n runInAction(() => {\n this.devices = devices\n })\n } catch (error) {\n this.captureError('loadDevices', error)\n }\n }\n\n loadNotificationProfiles = async () => {\n try {\n const profiles = await this.api.getNotificationProfiles()\n\n runInAction(() => {\n this.notificationProfiles = profiles\n })\n } catch (error) {\n this.captureError('loadNotificationProfiles', error)\n }\n }\n\n loadTransactionRules = async () => {\n try {\n const rules = await this.transactionApi.getTransactionRules()\n\n runInAction(() => {\n this.transactionRules = rules\n })\n } catch (error) {\n this.captureError('loadTransactionRules', error)\n }\n }\n\n sendEmailVerification = async () => {\n try {\n await this.api.sendEmailVerification()\n this.setAlert(this.copy.verification_sent_success, 'success')\n } catch (error) {\n this.captureError('sendEmailVerification', error)\n this.setAlert(this.copy.verification_sent_error, 'error')\n }\n }\n\n sendPhoneVerification = async () => {\n try {\n await this.api.sendPhoneVerification()\n this.setAlert(this.copy.verification_sent_success, 'success')\n } catch (error) {\n this.captureError('sendPhoneVerification', error)\n this.setAlert(this.copy.verification_sent_error, 'error')\n }\n }\n\n setAlert = (message: string, severity: SettingsAlertProps['severity'] = undefined) =>\n (this.alert = { message, severity })\n\n setSelectedRule = (rule?: TransactionRule) => {\n this.selectedRule = rule\n }\n\n updatePassword = async (params: UpdatePasswordParams) => {\n try {\n await this.api.updatePassword(params)\n this.setAlert(this.copy.password_updated_success, 'success')\n } catch (error) {\n // A wrong current password is a user mistake, not a failure to report.\n if (isCurrentPasswordIncorrect(error)) {\n this.setAlert(this.copy.current_password_incorrect, 'error')\n return\n }\n this.captureError('updatePassword', error)\n this.setAlert(this.copy.password_updated_error, 'error')\n }\n }\n\n updateDevice = async (device: Device) => {\n try {\n const updatedDevice = await this.api.updateDevice(device)\n\n const index = this.devices.findIndex((d) => d.guid === device.guid)\n if (index >= 0) {\n runInAction(() => {\n this.devices[index] = updatedDevice\n })\n }\n return { success: true }\n } catch (error) {\n this.captureError('updateDevice', error)\n return { success: false }\n }\n }\n\n /** Resolves `true` when the profile was saved, `false` when the API call failed. */\n updateNotificationProfile = async (profile: NotificationProfile): Promise<boolean> => {\n try {\n const updatedProfile = await this.api.updateNotificationProfile(profile)\n\n const index = this.notificationProfiles.findIndex((p) => p.guid === profile.guid)\n if (index >= 0) {\n runInAction(() => {\n this.notificationProfiles[index] = updatedProfile\n })\n }\n return true\n } catch (error) {\n this.captureError('updateNotificationProfile', error)\n return false\n }\n }\n\n updateRuleCategory = async (rule: TransactionRule) => {\n try {\n await this.transactionApi.updateTransactionRule(rule)\n await this.loadTransactionRules()\n } catch (error) {\n this.captureError('updateRuleCategory', error)\n }\n }\n\n updateRulePayee = async (rule: TransactionRule) => {\n try {\n await this.transactionApi.updateTransactionRule(rule)\n this.setAlert(this.copy.edit_payee_success, 'success')\n await this.loadTransactionRules()\n } catch (error) {\n this.captureError('updateRulePayee', error)\n this.setAlert(this.copy.edit_payee_error, 'error')\n }\n }\n\n updateUser = async (user: User) => {\n try {\n await this.globalStore.userStore.updateUser(user)\n this.setAlert(this.copy.information_updated_success, 'success')\n } catch {\n // Error is already logged and captured in UserStore.updateUser\n this.setAlert(this.copy.information_updated_error, 'error')\n }\n }\n\n updateUserCommunicationProfile = async (profile: UserCommunicationProfile) => {\n try {\n const updatedProfile = await this.api.updateUserCommunicationProfile(profile)\n\n this.globalStore.appDataStore.setUserCommunicationProfile(updatedProfile)\n } catch (error) {\n this.captureError('updateUserCommunicationProfile', error)\n }\n }\n\n verifyPhoneToken = async (sms_verification_token: string) => {\n try {\n const { verified } = await this.api.verifyPhoneToken(sms_verification_token)\n if (!verified) {\n throw new Error()\n }\n this.setAlert(this.copy.verified_phone_success, 'success')\n } catch (error) {\n this.captureError('verifyPhoneToken', error)\n this.setAlert(this.copy.verified_phone_error, 'error')\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'SettingsStore', action })\n}\n"],"mappings":";;;;;;AAkCA,IAAM,IAAA,CAA8B,MAClC,aAAiB,KAChB,EAAM,MAA0C,UAAU,8BAEhD,IAAb,MAA2B;AAAA,EACzB;AAAA,EACA,MAAmB,IAAI,EAAY,KAAK,EAAE;AAAA,EAC1C,iBAAiC,IAAI,EAAe,KAAK,EAAE;AAAA,EAE3D,QAA4B;AAAA,IAAE,SAAS;AAAA,IAAI,UAAU;AAAA,EAAU;AAAA,EAC/D,UAAoB,CAAC;AAAA,EACrB,uBAA8C,CAAC;AAAA,EAC/C,eAA4C;AAAA,EAC5C,mBAAsC,CAAC;AAAA,EAEvC,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAY,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAC9F,KAAK,iBAAiB,IAAI,EACxB,EAAY,UACZ,EAAY,cACZ,EAAY,OACd,GAEA,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,IAAI,kBAAkB;AACpB,UAAM,IAAM,KAAK,YAAY,aAAa;AAG1C,WAAO,KAAK,6BAA6B,OAAA,CACtC,MACE,EAAG,sBAAsB,EAAyB,uBACjD,EAAI,+CACL,EAAG,sBAAsB,EAAyB,qBACjD,EAAI,qCACL,EAAG,sBAAsB,EAAyB,uBACjD,EAAI,uCACL,EAAG,sBAAsB,EAAyB,2BACjD,EAAI,uCACL,EAAG,sBAAsB,EAAyB,wBACjD,EAAI,yCACL,EAAG,sBAAsB,EAAyB,4BACjD,EAAI,sDACL,EAAG,sBAAsB,EAAyB,6BACjD,EAAI,0CACV;AAAA,EACF;AAAA,EAEA,IAAI,iBAAiB;AACnB,UAAM,IAAM,KAAK,YAAY,aAAa;AAG1C,WAAO,KAAK,6BAA6B,OAAA,CACtC,MACE,EAAG,sBAAsB,EAAwB,kBAChD,EAAI,yCACL,EAAG,sBA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BAAoB,CAAK,GAC3C,KAAK,SAAS,KAAK,KAAK,sBAAsB,OAAO;AAAA,IACvD;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAiB,QAAA;AAAA,EAAO,CAAC;AAC/E"}
@@ -8,6 +8,8 @@ export interface User {
8
8
  external_guid?: string | null;
9
9
  first_name?: string | null;
10
10
  has_accepted_terms?: boolean;
11
+ /** Whether the user can sign in with a password. Missing means "has a password" (older backends). */
12
+ has_password?: boolean;
11
13
  last_name?: string | null;
12
14
  phone?: string | null;
13
15
  phone_is_verified: boolean;
@@ -12,6 +12,8 @@ export interface SettingsCopy {
12
12
  confirm_your_email: string;
13
13
  confirm_your_phone: string;
14
14
  credit_score: string;
15
+ current_password: string;
16
+ current_password_incorrect: string;
15
17
  delete_rule: string;
16
18
  delete_rule_confirm: string;
17
19
  delete_rule_error: string;
@@ -1,7 +1,9 @@
1
1
  import { GlobalErrorHandler } from '../types';
2
2
  export declare class ApiError extends Error {
3
3
  status: number;
4
- constructor(message: string, status: number);
4
+ /** Parsed JSON error body, when the server sent one (currently read by `put` only). */
5
+ body?: unknown;
6
+ constructor(message: string, status: number, body?: unknown);
5
7
  }
6
8
  export declare class Fetch {
7
9
  endpoint: string;
@@ -1,65 +1,72 @@
1
1
  import { getLocale as h } from "./Localization.es.js";
2
2
  var o = class extends Error {
3
3
  status;
4
- constructor(s, r) {
5
- super(s), this.name = "ApiError", this.status = r;
4
+ body;
5
+ constructor(r, s, t) {
6
+ super(r), this.name = "ApiError", this.status = s, this.body = t;
6
7
  }
7
- }, a = class {
8
+ }, a = async (r) => {
9
+ try {
10
+ return await r.json();
11
+ } catch {
12
+ return;
13
+ }
14
+ }, u = class {
8
15
  endpoint = "/";
9
16
  headers;
10
17
  onError;
11
- constructor(s, r, t, n) {
12
- this.endpoint = s;
18
+ constructor(r, s, t, n) {
19
+ this.endpoint = r;
13
20
  const e = {
14
21
  Accept: "application/json",
15
22
  "Accept-Language": h(),
16
23
  "Content-Type": "application/json",
17
- "MD-Session-Token": r
24
+ "MD-Session-Token": s
18
25
  };
19
26
  this.headers = t || e, this.onError = n;
20
27
  }
21
- get = async (s) => {
22
- const r = {
28
+ get = async (r) => {
29
+ const s = {
23
30
  method: "GET",
24
31
  headers: this.headers
25
32
  };
26
- return fetch(`${this.endpoint}${s}`, r).then((t) => {
33
+ return fetch(`${this.endpoint}${r}`, s).then((t) => {
27
34
  if (!t.ok) throw new o(`ApiGetRequestError: ${t.status} ${t.statusText}`, t.status);
28
35
  return t.text();
29
36
  }).then((t) => t.length ? JSON.parse(t) : {}).then((t) => t).catch((t) => {
30
37
  throw this.onError?.(t, void 0, "ApiGetRequestError"), t;
31
38
  });
32
39
  };
33
- post = async (s, r) => {
34
- const t = r ? JSON.stringify(r) : void 0, n = {
40
+ post = async (r, s) => {
41
+ const t = s ? JSON.stringify(s) : void 0, n = {
35
42
  method: "POST",
36
43
  headers: this.headers,
37
44
  body: t
38
45
  };
39
- return fetch(`${this.endpoint}${s}`, n).then((e) => {
46
+ return fetch(`${this.endpoint}${r}`, n).then((e) => {
40
47
  if (!e.ok) throw new o(`ApiPostRequestError: ${e.status} ${e.statusText}`, e.status);
41
48
  return e.text();
42
49
  }).then((e) => e.length ? JSON.parse(e) : {}).then((e) => e);
43
50
  };
44
- put = async (s, r) => {
45
- const t = JSON.stringify(r), n = {
51
+ put = async (r, s) => {
52
+ const t = JSON.stringify(s), n = {
46
53
  method: "PUT",
47
54
  headers: this.headers,
48
55
  body: t
49
56
  };
50
- return fetch(`${this.endpoint}${s}`, n).then((e) => {
51
- if (!e.ok) throw new o(`ApiPutRequestError: ${e.status} ${e.statusText}`, e.status);
57
+ return fetch(`${this.endpoint}${r}`, n).then(async (e) => {
58
+ if (!e.ok) throw new o(`ApiPutRequestError: ${e.status} ${e.statusText}`, e.status, await a(e));
52
59
  return e.text();
53
60
  }).then((e) => e.length ? JSON.parse(e) : {}).then((e) => e).catch((e) => {
54
61
  throw window?.app?.config?.type === "pulse" && this.onError?.(e, void 0, "ApiPutRequestError"), e;
55
62
  });
56
63
  };
57
- delete = async (s) => {
58
- const r = {
64
+ delete = async (r) => {
65
+ const s = {
59
66
  method: "DELETE",
60
67
  headers: this.headers
61
68
  };
62
- return fetch(`${this.endpoint}${s}`, r).then((t) => {
69
+ return fetch(`${this.endpoint}${r}`, s).then((t) => {
63
70
  if (!t.ok) throw new o(`ApiDeleteRequestError: ${t.status} ${t.statusText}`, t.status);
64
71
  return t.text();
65
72
  }).then((t) => t.length ? JSON.parse(t) : {}).then((t) => t);
@@ -67,8 +74,8 @@ var o = class extends Error {
67
74
  };
68
75
  export {
69
76
  o as ApiError,
70
- a as Fetch,
71
- a as default
77
+ u as Fetch,
78
+ u as default
72
79
  };
73
80
 
74
81
  //# sourceMappingURL=Fetch.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Fetch.es.js","names":[],"sources":["../../../src/core/utils/Fetch.ts"],"sourcesContent":["import { type GlobalErrorHandler } from '../types'\nimport { getLocale } from './Localization'\n\nexport class ApiError extends Error {\n public status: number\n constructor(message: string, status: number) {\n super(message)\n this.name = 'ApiError'\n this.status = status\n }\n}\n\nexport class Fetch {\n endpoint = '/'\n headers: Record<string, string>\n onError?: GlobalErrorHandler\n\n constructor(\n endpoint: string,\n token: string,\n headers?: Record<string, string>,\n onError?: GlobalErrorHandler,\n ) {\n this.endpoint = endpoint\n const defaultHeaders = {\n Accept: 'application/json',\n 'Accept-Language': getLocale(),\n 'Content-Type': 'application/json',\n 'MD-Session-Token': token,\n }\n this.headers = headers || defaultHeaders\n this.onError = onError\n }\n\n get = async (url: string) => {\n const options = {\n method: 'GET',\n headers: this.headers,\n }\n\n return fetch(`${this.endpoint}${url}`, options)\n .then((response) => {\n if (!response.ok) {\n throw new ApiError(\n `ApiGetRequestError: ${response.status} ${response.statusText}`,\n response.status,\n )\n }\n return response.text()\n })\n .then((text) => (text.length ? JSON.parse(text) : {}))\n .then((data) => data)\n .catch((err) => {\n this.onError?.(err, undefined, 'ApiGetRequestError')\n throw err\n })\n }\n\n post = async (url: string, data?: any) => {\n const body = data ? JSON.stringify(data) : undefined\n const options = {\n method: 'POST',\n headers: this.headers,\n body,\n }\n\n return fetch(`${this.endpoint}${url}`, options)\n .then((response) => {\n if (!response.ok) {\n throw new ApiError(\n `ApiPostRequestError: ${response.status} ${response.statusText}`,\n response.status,\n )\n }\n\n return response.text()\n })\n .then((text) => (text.length ? JSON.parse(text) : {}))\n .then((data) => data)\n }\n\n put = async (url: string, data: any) => {\n const body = JSON.stringify(data)\n const options = {\n method: 'PUT',\n headers: this.headers,\n body,\n }\n\n return fetch(`${this.endpoint}${url}`, options)\n .then((response) => {\n if (!response.ok) {\n throw new ApiError(\n `ApiPutRequestError: ${response.status} ${response.statusText}`,\n response.status,\n )\n }\n return response.text()\n })\n .then((text) => (text.length ? JSON.parse(text) : {}))\n .then((data) => data)\n .catch((err) => {\n if (window?.app?.config?.type === 'pulse') {\n this.onError?.(err, undefined, 'ApiPutRequestError')\n }\n throw err\n })\n }\n\n delete = async (url: string) => {\n const options = {\n method: 'DELETE',\n headers: this.headers,\n }\n\n return fetch(`${this.endpoint}${url}`, options)\n .then((response) => {\n if (!response.ok) {\n throw new ApiError(\n `ApiDeleteRequestError: ${response.status} ${response.statusText}`,\n response.status,\n )\n }\n return response.text()\n })\n .then((text) => (text.length ? JSON.parse(text) : {}))\n .then((data) => data)\n }\n}\n\nexport default Fetch\n"],"mappings":";AAGA,IAAa,IAAb,cAA8B,MAAM;AAAA,EAClC;AAAA,EACA,YAAY,GAAiB,GAAgB;AAC3C,UAAM,CAAO,GACb,KAAK,OAAO,YACZ,KAAK,SAAS;AAAA,EAChB;AACF,GAEa,IAAb,MAAmB;AAAA,EACjB,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EAEA,YACE,GACA,GACA,GACA,GACA;AACA,SAAK,WAAW;AAChB,UAAM,IAAiB;AAA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UAAM,IAAO,KAAK,UAAU,CAAI,GAC1B,IAAU;AAAA,MACd,QAAQ;AAAA,MACR,SAAS,KAAK;AAAA,MACd,MAAA;AAAA,IACF;AAEA,WAAO,MAAM,GAAG,KAAK,QAAA,GAAW,CAAA,IAAO,CAAO,EAC3C,KAAA,CAAM,MAAa;AAClB,UAAI,CAAC,EAAS,GACZ,OAAM,IAAI,EACR,uBAAuB,EAAS,MAAA,IAAU,EAAS,UAAA,IACnD,EAAS,MACX;AAEF,aAAO,EAAS,KAAK;AAAA,IACvB,CAAC,EACA,KAAA,CAAM,MAAU,EAAK,SAAS,KAAK,MAAM,CAAI,IAAI,CAAC,CAAE,EACpD,KAAA,CAAM,MAAS,CAAI,EACnB,MAAA,CAAO,MAAQ;AACd,YAAI,QAAQ,KAAK,QAAQ,SAAS,WAChC,KAAK,UAAU,GAAK,QAAW,oBAAoB,GAE/C;AAAA,IACR,CAAC;AAAA,EACL;AAAA,EAEA,SAAS,OAAO,MAAgB;AAC9B,UAAM,IAAU;AAAA,MACd,QAAQ;AAAA,MACR,SAAS,KAAK;AAAA,IAChB;AAEA,WAAO,MAAM,GAAG,KAAK,QAAA,GAAW,CAAA,IAAO,CAAO,EAC3C,KAAA,CAAM,MAAa;AAClB,UAAI,CAAC,EAAS,GACZ,OAAM,IAAI,EACR,0BAA0B,EAAS,MAAA,IAAU,EAAS,UAAA,IACtD,EAAS,MACX;AAEF,aAAO,EAAS,KAAK;AAAA,IACvB,CAAC,EACA,KAAA,CAAM,MAAU,EAAK,SAAS,KAAK,MAAM,CAAI,IAAI,CAAC,CAAE,EACpD,KAAA,CAAM,MAAS,CAAI;AAAA,EACxB;AACF"}
1
+ {"version":3,"file":"Fetch.es.js","names":[],"sources":["../../../src/core/utils/Fetch.ts"],"sourcesContent":["import { type GlobalErrorHandler } from '../types'\nimport { getLocale } from './Localization'\n\nexport class ApiError extends Error {\n public status: number\n /** Parsed JSON error body, when the server sent one (currently read by `put` only). */\n public body?: unknown\n constructor(message: string, status: number, body?: unknown) {\n super(message)\n this.name = 'ApiError'\n this.status = status\n this.body = body\n }\n}\n\nconst readErrorBody = async (response: Response): Promise<unknown> => {\n try {\n return await response.json()\n } catch {\n return undefined\n }\n}\n\nexport class Fetch {\n endpoint = '/'\n headers: Record<string, string>\n onError?: GlobalErrorHandler\n\n constructor(\n endpoint: string,\n token: string,\n headers?: Record<string, string>,\n onError?: GlobalErrorHandler,\n ) {\n this.endpoint = endpoint\n const defaultHeaders = {\n Accept: 'application/json',\n 'Accept-Language': getLocale(),\n 'Content-Type': 'application/json',\n 'MD-Session-Token': token,\n }\n this.headers = headers || defaultHeaders\n this.onError = onError\n }\n\n get = async (url: string) => {\n const options = {\n method: 'GET',\n headers: this.headers,\n }\n\n return fetch(`${this.endpoint}${url}`, options)\n .then((response) => {\n if (!response.ok) {\n throw new ApiError(\n `ApiGetRequestError: ${response.status} ${response.statusText}`,\n response.status,\n )\n }\n return response.text()\n })\n .then((text) => (text.length ? JSON.parse(text) : {}))\n .then((data) => data)\n .catch((err) => {\n this.onError?.(err, undefined, 'ApiGetRequestError')\n throw err\n })\n }\n\n post = async (url: string, data?: any) => {\n const body = data ? JSON.stringify(data) : undefined\n const options = {\n method: 'POST',\n headers: this.headers,\n body,\n }\n\n return fetch(`${this.endpoint}${url}`, options)\n .then((response) => {\n if (!response.ok) {\n throw new ApiError(\n `ApiPostRequestError: ${response.status} ${response.statusText}`,\n response.status,\n )\n }\n\n return response.text()\n })\n .then((text) => (text.length ? JSON.parse(text) : {}))\n .then((data) => data)\n }\n\n put = async (url: string, data: any) => {\n const body = JSON.stringify(data)\n const options = {\n method: 'PUT',\n headers: this.headers,\n body,\n }\n\n return fetch(`${this.endpoint}${url}`, options)\n .then(async (response) => {\n if (!response.ok) {\n throw new ApiError(\n `ApiPutRequestError: ${response.status} ${response.statusText}`,\n response.status,\n await readErrorBody(response),\n )\n }\n return response.text()\n })\n .then((text) => (text.length ? JSON.parse(text) : {}))\n .then((data) => data)\n .catch((err) => {\n if (window?.app?.config?.type === 'pulse') {\n this.onError?.(err, undefined, 'ApiPutRequestError')\n }\n throw err\n })\n }\n\n delete = async (url: string) => {\n const options = {\n method: 'DELETE',\n headers: this.headers,\n }\n\n return fetch(`${this.endpoint}${url}`, options)\n .then((response) => {\n if (!response.ok) {\n throw new ApiError(\n `ApiDeleteRequestError: ${response.status} ${response.statusText}`,\n response.status,\n )\n }\n return response.text()\n })\n .then((text) => (text.length ? JSON.parse(text) : {}))\n .then((data) => data)\n }\n}\n\nexport default Fetch\n"],"mappings":";AAGA,IAAa,IAAb,cAA8B,MAAM;AAAA,EAClC;AAAA,EAEA;AAAA,EACA,YAAY,GAAiB,GAAgB,GAAgB;AAC3D,UAAM,CAAO,GACb,KAAK,OAAO,YACZ,KAAK,SAAS,GACd,KAAK,OAAO;AAAA,EACd;AACF,GAEM,IAAgB,OAAO,MAAyC;AACpE,MAAI;AACF,WAAO,MAAM,EAAS,KAAK;AAAA,EAC7B,QAAQ;AACN;AAAA,EACF;AACF,GAEa,IAAb,MAAmB;AAAA,EACjB,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EAEA,YACE,GACA,GACA,GACA,GACA;AACA,SAAK,WAAW;AAChB,UAAM,IAAiB;AAAA,MACrB,QAAQ;AAAA,MACR,mBAAmB,EAAU;AAAA,MAC7B,gBAAgB;AAAA,MAChB,oBAAoB;AAAA,IACtB;AACA,SAAK,UAAU,KAAW,GAC1B,KAAK,UAAU;AAAA,EACjB;AAAA,EAEA,MAAM,OAAO,MAAgB;AAC3B,UAAM,IAAU;AAAA,MACd,QAAQ;AAAA,MACR,SAAS,KAAK;AAAA,IAChB;AAEA,WAAO,MAAM,GAAG,KAAK,QAAA,GAAW,CAAA,IAAO,CAAO,EAC3C,KAAA,CAAM,MAAa;AAClB,UAAI,CAAC,EAAS,GACZ,OAAM,IAAI,EACR,uBAAuB,EAAS,MAAA,IAAU,EAAS,UAAA,IACnD,EAAS,MACX;AAEF,aAAO,EAAS,KAAK;AAAA,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ACnB,MAAA,CAAO,MAAQ;AACd,YAAI,QAAQ,KAAK,QAAQ,SAAS,WAChC,KAAK,UAAU,GAAK,QAAW,oBAAoB,GAE/C;AAAA,IACR,CAAC;AAAA,EACL;AAAA,EAEA,SAAS,OAAO,MAAgB;AAC9B,UAAM,IAAU;AAAA,MACd,QAAQ;AAAA,MACR,SAAS,KAAK;AAAA,IAChB;AAEA,WAAO,MAAM,GAAG,KAAK,QAAA,GAAW,CAAA,IAAO,CAAO,EAC3C,KAAA,CAAM,MAAa;AAClB,UAAI,CAAC,EAAS,GACZ,OAAM,IAAI,EACR,0BAA0B,EAAS,MAAA,IAAU,EAAS,UAAA,IACtD,EAAS,MACX;AAEF,aAAO,EAAS,KAAK;AAAA,IACvB,CAAC,EACA,KAAA,CAAM,MAAU,EAAK,SAAS,KAAK,MAAM,CAAI,IAAI,CAAC,CAAE,EACpD,KAAA,CAAM,MAAS,CAAI;AAAA,EACxB;AACF"}
@@ -1,31 +1,32 @@
1
- import { buildDynamicCopy as X } from "../../../core/utils/Localization.es.js";
2
- import Y from "../../../common/utils/AccountDisplayName.es.js";
3
- import { useCategoryStore as Z, useGlobalCopyStore as N, useInsightsV2Store as k, useSettingsStore as oo, useUserStore as eo } from "../../../common/context/hooks.es.js";
4
- import V from "../../../common/components/Loader.es.js";
5
- import to from "../../../common/components/CurrencyDialog.es.js";
6
- import { useBeatActions as io } from "../../beatActions.es.js";
7
- import { useCtaHandler as no } from "../../ctaActions/useCtaAction.es.js";
8
- import { useAnalyticsEvent as ro } from "../../analytics/useAnalyticsEvent.es.js";
9
- import { useOpenedCta as so } from "../useOpenedCta.es.js";
1
+ import { buildDynamicCopy as Q } from "../../../core/utils/Localization.es.js";
2
+ import X from "../../../common/utils/AccountDisplayName.es.js";
3
+ import { useCategoryStore as Y, useGlobalCopyStore as w, useInsightsV2Store as B, useSettingsStore as Z, useUserStore as oo } from "../../../common/context/hooks.es.js";
4
+ import E from "../../../common/components/Loader.es.js";
5
+ import eo from "../../../common/components/CurrencyDialog.es.js";
6
+ import { useBeatActions as to } from "../../beatActions.es.js";
7
+ import { useCtaHandler as io } from "../../ctaActions/useCtaAction.es.js";
8
+ import { useAnalyticsEvent as no } from "../../analytics/useAnalyticsEvent.es.js";
9
+ import { useOpenedCta as ro } from "../useOpenedCta.es.js";
10
+ import { useBlockSave as so } from "../useBlockSave.es.js";
10
11
  import { CreateBudgetDialog as ao } from "./CreateBudgetDialog.es.js";
11
- import { AMOUNT_SETTINGS as co, CREATE_BUDGET_VARIANT as lo, findLowBalanceProfile as uo, isAmountInputVariant as w, resolveAmountInputVariant as mo, toInputValue as po } from "./layout.es.js";
12
- import r from "react";
13
- import { observer as M } from "mobx-react-lite";
14
- import R from "@mui/material/Stack";
15
- import { H3 as fo, InstitutionLogo as go, Text as B } from "@mxenabled/mxui";
16
- import { Icon as yo } from "@mxenabled/mx-icons";
17
- import { jsx as e, jsxs as $ } from "react/jsx-runtime";
12
+ import { AMOUNT_SETTINGS as co, CREATE_BUDGET_VARIANT as lo, findLowBalanceProfile as uo, isAmountInputVariant as L, resolveAmountInputVariant as mo, toInputValue as po } from "./layout.es.js";
13
+ import c from "react";
14
+ import { observer as k } from "mobx-react-lite";
15
+ import N from "@mui/material/Stack";
16
+ import { H3 as fo, InstitutionLogo as yo, Text as T } from "@mxenabled/mxui";
17
+ import { Icon as go } from "@mxenabled/mx-icons";
18
+ import { jsx as e, jsxs as V } from "react/jsx-runtime";
18
19
  import ho from "@mui/material/Dialog";
19
- import _o from "@mui/material/IconButton";
20
- var C = ({ children: g, closeAriaLabel: i, heading: n, onClose: t }) => {
21
- const s = r.useId();
20
+ import vo from "@mui/material/IconButton";
21
+ var _ = ({ children: y, closeAriaLabel: i, heading: n, onClose: t }) => {
22
+ const r = c.useId();
22
23
  return /* @__PURE__ */ e(ho, {
23
- "aria-labelledby": n ? s : void 0,
24
+ "aria-labelledby": n ? r : void 0,
24
25
  maxWidth: "xs",
25
26
  onClose: t,
26
27
  open: !0,
27
- sx: { "& .MuiDialog-paper": { borderRadius: (c) => `${c.shape.borderRadius}px` } },
28
- children: /* @__PURE__ */ $(R, {
28
+ sx: { "& .MuiDialog-paper": { borderRadius: (a) => `${a.shape.borderRadius}px` } },
29
+ children: /* @__PURE__ */ V(N, {
29
30
  sx: {
30
31
  gap: 12,
31
32
  p: 24,
@@ -33,10 +34,10 @@ var C = ({ children: g, closeAriaLabel: i, heading: n, onClose: t }) => {
33
34
  },
34
35
  children: [
35
36
  n && /* @__PURE__ */ e(fo, {
36
- id: s,
37
+ id: r,
37
38
  children: n
38
39
  }),
39
- /* @__PURE__ */ e(_o, {
40
+ /* @__PURE__ */ e(vo, {
40
41
  "aria-label": i || "Close",
41
42
  onClick: t,
42
43
  sx: {
@@ -44,104 +45,104 @@ var C = ({ children: g, closeAriaLabel: i, heading: n, onClose: t }) => {
44
45
  right: 8,
45
46
  top: 18
46
47
  },
47
- children: /* @__PURE__ */ e(yo, {
48
+ children: /* @__PURE__ */ e(go, {
48
49
  name: "close",
49
50
  sx: { color: "action.active" }
50
51
  })
51
52
  }),
52
- g
53
+ y
53
54
  ]
54
55
  })
55
56
  });
56
- }, Go = M(function({ beat: i }) {
57
- const { common: n } = N(), { closeActionDrawer: t } = k(), s = Z(), c = so(i), [l] = r.useState(() => mo(c)), d = l === lo;
58
- return r.useEffect(() => {
59
- d && !s.categoriesLoaded && s.loadCategories();
60
- }, [s, d]), d ? s.categoriesLoaded ? /* @__PURE__ */ e(ao, { beat: i }) : /* @__PURE__ */ e(C, {
57
+ }, Fo = k(function({ beat: i }) {
58
+ const { common: n } = w(), { closeActionDrawer: t } = B(), r = Y(), a = ro(i), [l] = c.useState(() => mo(a)), d = l === lo;
59
+ return c.useEffect(() => {
60
+ d && !r.categoriesLoaded && r.loadCategories();
61
+ }, [r, d]), d ? r.categoriesLoaded ? /* @__PURE__ */ e(ao, { beat: i }) : /* @__PURE__ */ e(_, {
61
62
  closeAriaLabel: n?.close_aria,
62
63
  onClose: t,
63
- children: /* @__PURE__ */ e(V, {})
64
- }) : /* @__PURE__ */ e(vo, {
64
+ children: /* @__PURE__ */ e(E, {})
65
+ }) : /* @__PURE__ */ e(_o, {
65
66
  beat: i,
66
67
  variant: l
67
68
  });
68
- }), vo = M(function({ beat: i, variant: n }) {
69
- const { common: t, insights_feed: s } = N(), { closeActionDrawer: c } = k(), l = oo(), { userInsightProfile: d } = eo(), G = no(i, io()), S = ro(), u = s?.amount_input_modal, o = w(n) ? co[n] : void 0, m = !!o?.needsNotificationProfiles, y = {
69
+ }), _o = k(function({ beat: i, variant: n }) {
70
+ const { common: t, insights_feed: r } = w(), { closeActionDrawer: a } = B(), l = Z(), { userInsightProfile: d } = oo(), M = io(i, to()), C = no(), u = r?.amount_input_modal, o = L(n) ? co[n] : void 0, m = !!o?.needsNotificationProfiles, g = {
70
71
  insightProfile: d,
71
72
  lowBalanceProfile: m ? uo(l.notificationProfiles, i.primary_account_guid) : void 0
72
- }, A = o?.read(y), [F, H] = r.useState(m), p = r.useRef(!0);
73
- r.useEffect(() => (p.current = !0, () => {
74
- p.current = !1;
75
- }), []), r.useEffect(() => {
73
+ }, S = o?.read(g), [R, $] = c.useState(m), { isMounted: G, isSaving: F, save: H } = so();
74
+ c.useEffect(() => {
76
75
  m && l.loadNotificationProfiles().finally(() => {
77
- p.current && H(!1);
76
+ G.current && $(!1);
78
77
  });
79
78
  }, [m, l]);
80
- const [O, U] = r.useState(null), [I, b] = r.useState(!1), [j, h] = r.useState(!1), f = O ?? po(A);
81
- if (F) return /* @__PURE__ */ e(C, {
79
+ const [O, U] = c.useState(null), [j, h] = c.useState(!1), p = O ?? po(S);
80
+ if (R) return /* @__PURE__ */ e(_, {
82
81
  closeAriaLabel: t?.close_aria,
83
- onClose: c,
84
- children: /* @__PURE__ */ e(V, {})
82
+ onClose: a,
83
+ children: /* @__PURE__ */ e(E, {})
85
84
  });
86
- const a = w(n) ? u?.[n] : void 0, x = o ? u?.[o.errorKey] : void 0, D = !!a?.title && !!a.description && !!a.input_label && !!x && !!u?.save_error && !!t?.save_button && (!o?.hasCancel || !!t.cancel_button) && !!t.close_aria, z = !!o?.hasSource(y);
87
- if (!u || !o || !a || !D || !z)
88
- return console.warn(`amount_input_modal_block: ${u ? o ? D ? m ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${n}"` : `unknown variant "${n}"` : "copy namespace missing"}`), /* @__PURE__ */ e(C, {
85
+ const s = L(n) ? u?.[n] : void 0, A = o ? u?.[o.errorKey] : void 0, b = !!s?.title && !!s.description && !!s.input_label && !!A && !!u?.save_error && !!t?.save_button && (!o?.hasCancel || !!t.cancel_button) && !!t.close_aria, z = !!o?.hasSource(g);
86
+ if (!u || !o || !s || !b || !z)
87
+ return console.warn(`amount_input_modal_block: ${u ? o ? b ? m ? "no low-balance profile for the account" : "user insight profile not set by the host" : `copy incomplete for "${n}"` : `unknown variant "${n}"` : "copy namespace missing"}`), /* @__PURE__ */ e(_, {
89
88
  closeAriaLabel: t?.close_aria,
90
89
  heading: t?.error_heading,
91
- onClose: c,
92
- children: /* @__PURE__ */ e(B, { children: t?.error_message })
90
+ onClose: a,
91
+ children: /* @__PURE__ */ e(T, { children: t?.error_message })
93
92
  });
94
- const P = () => {
95
- S(o.analytics.cancel), c();
96
- }, { inputSelected: L } = o.analytics, E = o.hasEditCopy && !!A, T = i.primary_account ? Y(i.primary_account) : "", _ = o.isValid(f), K = f !== "" && !_, W = async () => {
97
- if (!_ || I) return;
98
- const v = Number(f);
99
- b(!0), h(!1);
100
- const [q, J] = o.save(v, y), Q = await G(q, J, { analytics: o.analytics.save });
101
- p.current && (b(!1), Q ? c() : h(!0));
93
+ const I = () => {
94
+ C(o.analytics.cancel), a();
95
+ }, { inputSelected: x } = o.analytics, D = o.hasEditCopy && !!S, P = i.primary_account ? X(i.primary_account) : "", v = o.isValid(p), K = p !== "" && !v, W = async () => {
96
+ if (!v) return;
97
+ const f = await H(() => {
98
+ h(!1);
99
+ const [q, J] = o.save(Number(p), g);
100
+ return M(q, J, { analytics: o.analytics.save });
101
+ });
102
+ f !== void 0 && (f ? a() : h(!0));
102
103
  };
103
- return /* @__PURE__ */ e(to, {
104
+ return /* @__PURE__ */ e(eo, {
104
105
  closeAriaLabel: t.close_aria,
105
- content: X(E && a.description_edit || a.description, /* @__PURE__ */ e("strong", { children: T }, "account")),
106
- errorText: K ? x : j ? u.save_error : void 0,
107
- handleInputChange: (v) => {
108
- U(v), h(!1);
106
+ content: Q(D && s.description_edit || s.description, /* @__PURE__ */ e("strong", { children: P }, "account")),
107
+ errorText: K ? A : j ? u.save_error : void 0,
108
+ handleInputChange: (f) => {
109
+ U(f), h(!1);
109
110
  },
110
- handleInputClick: L ? () => S(L) : void 0,
111
- handleModalClose: P,
111
+ handleInputClick: x ? () => C(x) : void 0,
112
+ handleModalClose: I,
112
113
  handlePrimaryAction: () => {
113
114
  W();
114
115
  },
115
- handleSecondaryAction: P,
116
- inputLabel: a.input_label,
117
- inputValue: f,
116
+ handleSecondaryAction: I,
117
+ inputLabel: s.input_label,
118
+ inputValue: p,
118
119
  isOpen: !0,
119
- isPrimaryDisabled: I || !_,
120
+ isPrimaryDisabled: F || !v,
120
121
  primaryText: t.save_button,
121
122
  secondaryText: o.hasCancel ? t.cancel_button : void 0,
122
- subtitle: o.showsAccount && i.primary_account ? /* @__PURE__ */ $(R, {
123
+ subtitle: o.showsAccount && i.primary_account ? /* @__PURE__ */ V(N, {
123
124
  sx: {
124
125
  alignItems: "center",
125
126
  flexDirection: "row",
126
127
  gap: 8
127
128
  },
128
- children: [/* @__PURE__ */ e(go, {
129
+ children: [/* @__PURE__ */ e(yo, {
129
130
  alt: "",
130
131
  institutionGuid: i.primary_account.institution_guid ?? "",
131
132
  size: 16
132
- }), /* @__PURE__ */ e(B, {
133
+ }), /* @__PURE__ */ e(T, {
133
134
  color: "text.secondary",
134
135
  uppercase: !0,
135
136
  variant: "body2",
136
- children: T
137
+ children: P
137
138
  })]
138
139
  }) : void 0,
139
- title: E && a.title_edit || a.title,
140
+ title: D && s.title_edit || s.title,
140
141
  unit: o.unit
141
142
  });
142
143
  });
143
144
  export {
144
- Go as AmountInputModalBlock
145
+ Fo as AmountInputModalBlock
145
146
  };
146
147
 
147
148
  //# sourceMappingURL=AmountInputModalBlock.es.js.map