@mx-cartographer/experiences 9.7.177 → 9.7.179
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 +9 -0
- package/dist/core/api/SettingsApi.d.ts +6 -4
- package/dist/core/api/SettingsApi.es.js.map +1 -1
- package/dist/core/stores/SettingsStore.d.ts +2 -4
- package/dist/core/stores/SettingsStore.es.js +13 -8
- package/dist/core/stores/SettingsStore.es.js.map +1 -1
- package/dist/core/types/User.d.ts +2 -0
- package/dist/core/types/localization/SettingsCopy.d.ts +2 -0
- package/dist/core/utils/Fetch.d.ts +3 -1
- package/dist/core/utils/Fetch.es.js +28 -21
- package/dist/core/utils/Fetch.es.js.map +1 -1
- package/dist/settings/components/profile/ProfileTab.es.js +55 -52
- package/dist/settings/components/profile/ProfileTab.es.js.map +1 -1
- package/dist/settings/components/profile/actions/ResetPasswordAction.es.js +78 -61
- package/dist/settings/components/profile/actions/ResetPasswordAction.es.js.map +1 -1
- package/dist/settings/constants/Settings.d.ts +2 -0
- package/dist/settings/constants/Settings.es.js +13 -11
- package/dist/settings/constants/Settings.es.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [9.7.179] - 11-17-2026
|
|
2
|
+
|
|
3
|
+
- **ADDED** - Contract test and mock fixture for Weekly Small Purchases Summary beat (WEC-2361)
|
|
4
|
+
|
|
5
|
+
## [9.7.178] - 11-17-2026
|
|
6
|
+
|
|
7
|
+
- **ADDED** - Reset Password asks for the current password and shows a specific message when it's wrong (WELL-119)
|
|
8
|
+
- **CHANGED** - Reset Password is hidden for users who don't have a password (WELL-119)
|
|
9
|
+
|
|
1
10
|
## [9.7.177] - 11-17-2026
|
|
2
11
|
|
|
3
12
|
- **CHANGED** - Insights 2.0 block dialogs (Amount Input, Create Budget) save through one shared hook; no visible change (WEC-2262)
|
|
@@ -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:
|
|
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,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AA,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 {
|
|
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
|
|
5
|
-
import { makeAutoObservable as
|
|
6
|
-
var
|
|
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),
|
|
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(
|
|
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 ?
|
|
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
|
-
|
|
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,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;AA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AiB,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,EAA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I,GACpD,KAAK,SAAS,KAAK,KAAK,oBAAoB,SAAS,GACrD,MAAM,KAAK,qBAAqB;AAAA,IAClC,SAAS,GAAO;AACd,WAAK,aAAa,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"}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
4
|
+
body;
|
|
5
|
+
constructor(r, s, t) {
|
|
6
|
+
super(r), this.name = "ApiError", this.status = s, this.body = t;
|
|
6
7
|
}
|
|
7
|
-
}, a =
|
|
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(
|
|
12
|
-
this.endpoint =
|
|
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":
|
|
24
|
+
"MD-Session-Token": s
|
|
18
25
|
};
|
|
19
26
|
this.headers = t || e, this.onError = n;
|
|
20
27
|
}
|
|
21
|
-
get = async (
|
|
22
|
-
const
|
|
28
|
+
get = async (r) => {
|
|
29
|
+
const s = {
|
|
23
30
|
method: "GET",
|
|
24
31
|
headers: this.headers
|
|
25
32
|
};
|
|
26
|
-
return fetch(`${this.endpoint}${
|
|
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 (
|
|
34
|
-
const t =
|
|
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}${
|
|
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 (
|
|
45
|
-
const t = JSON.stringify(
|
|
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}${
|
|
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 (
|
|
58
|
-
const
|
|
64
|
+
delete = async (r) => {
|
|
65
|
+
const s = {
|
|
59
66
|
method: "DELETE",
|
|
60
67
|
headers: this.headers
|
|
61
68
|
};
|
|
62
|
-
return fetch(`${this.endpoint}${
|
|
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
|
-
|
|
71
|
-
|
|
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;
|
|
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,G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AAO,MAAM,GAAG,KAAK,QAAA,GAAW,CAAA,IAAO,CAAO,EAC3C,KAAK,OAAO,MAAa;AACxB,UAAI,CAAC,EAAS,GACZ,OAAM,IAAI,EACR,uBAAuB,EAAS,MAAA,IAAU,EAAS,UAAA,IACnD,EAAS,QACT,MAAM,EAAc,CAAQ,CAC9B;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,24 +1,24 @@
|
|
|
1
|
-
import { useAppConfig as
|
|
2
|
-
import { useScreenSize as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { useAppConfig as B, useGlobalCopyStore as M, useSettingsStore as R, useUserStore as L } from "../../../common/context/hooks.es.js";
|
|
2
|
+
import { useScreenSize as z } from "../../../common/hooks/useScreenSize.es.js";
|
|
3
|
+
import I from "../../../common/components/dialog/Dialog.es.js";
|
|
4
|
+
import N from "./actions/ResetPasswordAction.es.js";
|
|
5
|
+
import $ from "./actions/VerifyEmailAction.es.js";
|
|
6
|
+
import j from "./actions/VerifyPhoneAction.es.js";
|
|
7
7
|
import p from "react";
|
|
8
|
-
import { observer as
|
|
8
|
+
import { observer as H } from "mobx-react-lite";
|
|
9
9
|
import l from "@mui/material/Stack";
|
|
10
|
-
import { H3 as
|
|
11
|
-
import
|
|
12
|
-
import { Fragment as
|
|
13
|
-
import { alpha as b, useTheme as
|
|
14
|
-
import
|
|
15
|
-
import { getUnixTime as
|
|
10
|
+
import { H3 as J, P as O } from "@mxenabled/mxui";
|
|
11
|
+
import G from "@mui/material/Button";
|
|
12
|
+
import { Fragment as K, jsx as t, jsxs as i } from "react/jsx-runtime";
|
|
13
|
+
import { alpha as b, useTheme as Y } from "@mui/material/styles";
|
|
14
|
+
import q from "@mui/material/Box";
|
|
15
|
+
import { getUnixTime as Q } from "date-fns/getUnixTime";
|
|
16
16
|
import d from "@mui/material/TextField";
|
|
17
|
-
import { AdapterDateFns as
|
|
18
|
-
import { DatePicker as
|
|
19
|
-
import { LocalizationProvider as
|
|
20
|
-
var
|
|
21
|
-
const
|
|
17
|
+
import { AdapterDateFns as W } from "@mui/x-date-pickers/AdapterDateFns";
|
|
18
|
+
import { DatePicker as X } from "@mui/x-date-pickers";
|
|
19
|
+
import { LocalizationProvider as Z } from "@mui/x-date-pickers/LocalizationProvider";
|
|
20
|
+
var ee = ({ availableWidth: w, handleOnLeaveClick: f }) => {
|
|
21
|
+
const u = Y(), { common: S, settings: o } = M(), { isMobile: c } = z(w), { config: h } = B(), { updateUser: P } = R(), { user: r } = L(), [a, T] = p.useState({
|
|
22
22
|
first_name: r.first_name,
|
|
23
23
|
last_name: r.last_name,
|
|
24
24
|
email: r.email,
|
|
@@ -26,9 +26,9 @@ var Z = ({ availableWidth: C, handleOnLeaveClick: u }) => {
|
|
|
26
26
|
birthday: r.birthday,
|
|
27
27
|
postal_code: r.postal_code,
|
|
28
28
|
credit_score: r.credit_score
|
|
29
|
-
}), [m, y] = p.useState(!1), [
|
|
29
|
+
}), [m, y] = p.useState(!1), [U, g] = p.useState(!1), _ = p.useRef(null), v = a.email && !r.email_is_verified && !m, x = a.phone && !r.phone_is_verified && !m, C = h.display_password_options_in_settings && r.has_password !== !1;
|
|
30
30
|
p.useEffect(() => {
|
|
31
|
-
if (
|
|
31
|
+
if (f) {
|
|
32
32
|
const e = (s) => {
|
|
33
33
|
_.current && !_.current.contains(s.target) && m && g(!0);
|
|
34
34
|
};
|
|
@@ -37,31 +37,31 @@ var Z = ({ availableWidth: C, handleOnLeaveClick: u }) => {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
}, [m]);
|
|
40
|
-
const
|
|
40
|
+
const V = () => {
|
|
41
41
|
if (a.birthday) {
|
|
42
|
-
const e = /* @__PURE__ */ new Date(a.birthday * 1e3), s = e.getUTCFullYear(),
|
|
43
|
-
return new Date(s,
|
|
42
|
+
const e = /* @__PURE__ */ new Date(a.birthday * 1e3), s = e.getUTCFullYear(), A = e.getUTCMonth(), E = e.getUTCDate();
|
|
43
|
+
return new Date(s, A, E);
|
|
44
44
|
}
|
|
45
|
-
},
|
|
46
|
-
await
|
|
45
|
+
}, k = async () => {
|
|
46
|
+
await P({
|
|
47
47
|
...r,
|
|
48
48
|
...a
|
|
49
49
|
}), y(!1);
|
|
50
|
-
}, k = () => {
|
|
51
|
-
g(!1), u && u();
|
|
52
50
|
}, D = () => {
|
|
51
|
+
g(!1), f && f();
|
|
52
|
+
}, F = () => {
|
|
53
53
|
g(!1);
|
|
54
54
|
}, n = (e) => {
|
|
55
55
|
const s = {
|
|
56
56
|
...a,
|
|
57
57
|
...e
|
|
58
58
|
};
|
|
59
|
-
|
|
59
|
+
T(s), y(JSON.stringify({
|
|
60
60
|
...r,
|
|
61
61
|
...s
|
|
62
62
|
}) !== JSON.stringify(r));
|
|
63
63
|
};
|
|
64
|
-
return /* @__PURE__ */ i(
|
|
64
|
+
return /* @__PURE__ */ i(K, { children: [/* @__PURE__ */ i(q, {
|
|
65
65
|
component: "form",
|
|
66
66
|
ref: _,
|
|
67
67
|
sx: {
|
|
@@ -70,8 +70,8 @@ var Z = ({ availableWidth: C, handleOnLeaveClick: u }) => {
|
|
|
70
70
|
"& .MuiTextField-root, & .MuiPickersTextField-root": { flex: 1 }
|
|
71
71
|
},
|
|
72
72
|
children: [
|
|
73
|
-
/* @__PURE__ */ t(
|
|
74
|
-
/* @__PURE__ */ t(
|
|
73
|
+
/* @__PURE__ */ t(J, { children: o.personal_details }),
|
|
74
|
+
/* @__PURE__ */ t(O, {
|
|
75
75
|
variant: "body1",
|
|
76
76
|
children: o.update_information
|
|
77
77
|
}),
|
|
@@ -104,7 +104,7 @@ var Z = ({ availableWidth: C, handleOnLeaveClick: u }) => {
|
|
|
104
104
|
defaultValue: a.email,
|
|
105
105
|
label: o.email_address,
|
|
106
106
|
onChange: (e) => n({ email: e.target.value })
|
|
107
|
-
}), v && /* @__PURE__ */ t(
|
|
107
|
+
}), v && /* @__PURE__ */ t($, {})]
|
|
108
108
|
}), h.display_sms_edit_field_in_settings && /* @__PURE__ */ i(l, {
|
|
109
109
|
sx: {
|
|
110
110
|
flex: 1,
|
|
@@ -115,36 +115,36 @@ var Z = ({ availableWidth: C, handleOnLeaveClick: u }) => {
|
|
|
115
115
|
label: o.mobile_number,
|
|
116
116
|
onChange: (e) => n({ phone: e.target.value }),
|
|
117
117
|
type: "tel"
|
|
118
|
-
}), x && /* @__PURE__ */ t(
|
|
118
|
+
}), x && /* @__PURE__ */ t(j, {})]
|
|
119
119
|
})]
|
|
120
120
|
}),
|
|
121
121
|
/* @__PURE__ */ i(l, {
|
|
122
122
|
direction: c ? "column" : "row",
|
|
123
123
|
spacing: 24,
|
|
124
124
|
sx: { mb: 24 },
|
|
125
|
-
children: [/* @__PURE__ */ t(
|
|
126
|
-
dateAdapter:
|
|
127
|
-
children: /* @__PURE__ */ t(
|
|
125
|
+
children: [/* @__PURE__ */ t(Z, {
|
|
126
|
+
dateAdapter: W,
|
|
127
|
+
children: /* @__PURE__ */ t(X, {
|
|
128
128
|
label: o.birthdate,
|
|
129
|
-
onChange: (e) => n({ birthday:
|
|
129
|
+
onChange: (e) => n({ birthday: Q(e) }),
|
|
130
130
|
slotProps: {
|
|
131
131
|
nextIconButton: { sx: {
|
|
132
132
|
color: "primary.main",
|
|
133
|
-
"&:hover": { backgroundColor: b(
|
|
133
|
+
"&:hover": { backgroundColor: b(u.palette.primary.light, 0.1) }
|
|
134
134
|
} },
|
|
135
135
|
previousIconButton: { sx: {
|
|
136
136
|
color: "primary.main",
|
|
137
|
-
"&:hover": { backgroundColor: b(
|
|
137
|
+
"&:hover": { backgroundColor: b(u.palette.primary.light, 0.1) }
|
|
138
138
|
} }
|
|
139
139
|
},
|
|
140
140
|
sx: {
|
|
141
141
|
width: "100%",
|
|
142
142
|
"& .MuiIconButton-edgeEnd": {
|
|
143
143
|
color: "primary.main",
|
|
144
|
-
"&:hover": { backgroundColor: b(
|
|
144
|
+
"&:hover": { backgroundColor: b(u.palette.primary.light, 0.1) }
|
|
145
145
|
}
|
|
146
146
|
},
|
|
147
|
-
value:
|
|
147
|
+
value: V()
|
|
148
148
|
})
|
|
149
149
|
}), /* @__PURE__ */ t(d, {
|
|
150
150
|
defaultValue: a.postal_code,
|
|
@@ -158,28 +158,31 @@ var Z = ({ availableWidth: C, handleOnLeaveClick: u }) => {
|
|
|
158
158
|
label: o.credit_score,
|
|
159
159
|
onChange: (e) => n({ credit_score: Number(e.target.value) })
|
|
160
160
|
}),
|
|
161
|
-
|
|
162
|
-
/* @__PURE__ */ t(
|
|
161
|
+
C && /* @__PURE__ */ t(N, {}),
|
|
162
|
+
/* @__PURE__ */ t(G, {
|
|
163
163
|
disabled: !m,
|
|
164
|
-
onClick:
|
|
165
|
-
sx: {
|
|
164
|
+
onClick: k,
|
|
165
|
+
sx: {
|
|
166
|
+
mt: C ? 0 : 24,
|
|
167
|
+
width: c ? "100%" : 124
|
|
168
|
+
},
|
|
166
169
|
variant: "contained",
|
|
167
|
-
children:
|
|
170
|
+
children: S.save_button
|
|
168
171
|
})
|
|
169
172
|
] })
|
|
170
173
|
]
|
|
171
|
-
}), /* @__PURE__ */ t(
|
|
174
|
+
}), /* @__PURE__ */ t(I, {
|
|
172
175
|
copy: { title: o.discard_changes },
|
|
173
|
-
isOpen:
|
|
174
|
-
onClose:
|
|
175
|
-
onSecondaryAction:
|
|
176
|
+
isOpen: U,
|
|
177
|
+
onClose: F,
|
|
178
|
+
onSecondaryAction: D,
|
|
176
179
|
primaryText: o.keep_editing,
|
|
177
180
|
secondaryText: o.leave,
|
|
178
181
|
children: o.discard_changes_message
|
|
179
182
|
})] });
|
|
180
|
-
},
|
|
183
|
+
}, ve = H(ee);
|
|
181
184
|
export {
|
|
182
|
-
|
|
185
|
+
ve as default
|
|
183
186
|
};
|
|
184
187
|
|
|
185
188
|
//# sourceMappingURL=ProfileTab.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileTab.es.js","names":[],"sources":["../../../../src/settings/components/profile/ProfileTab.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\nimport { getUnixTime } from 'date-fns/getUnixTime'\n\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'\nimport { DatePicker } from '@mui/x-date-pickers'\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'\n\nimport { alpha, useTheme } from '@mui/material/styles'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\n\nimport { H3, P } from '@mxenabled/mxui'\n\nimport {\n useAppConfig,\n useGlobalCopyStore,\n useScreenSize,\n useSettingsStore,\n useUserStore,\n Dialog,\n} from '../../../common'\nimport { type EditableUser } from '../../../core'\nimport ResetPasswordAction from './actions/ResetPasswordAction'\nimport VerifyEmailAction from './actions/VerifyEmailAction'\nimport VerifyPhoneAction from './actions/VerifyPhoneAction'\n\ninterface ProfileFormProps {\n availableWidth?: number\n handleOnLeaveClick?: () => void\n}\n\ntype UserInput = {\n [U in keyof EditableUser]: EditableUser[U]\n}\n\nconst ProfileForm: React.FC<ProfileFormProps> = ({ availableWidth, handleOnLeaveClick }) => {\n const theme = useTheme()\n const { common: commonCopy, settings: settingsCopy } = useGlobalCopyStore()\n const { isMobile } = useScreenSize(availableWidth)\n const { config } = useAppConfig()\n const { updateUser } = useSettingsStore()\n const { user } = useUserStore()\n\n const [modifiedUser, setModifiedUser] = React.useState<EditableUser>({\n first_name: user.first_name,\n last_name: user.last_name,\n email: user.email,\n phone: user.phone,\n birthday: user.birthday,\n postal_code: user.postal_code,\n credit_score: user.credit_score,\n })\n const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false)\n const [showLeaveDialog, setShowLeaveDialog] = React.useState(false)\n const boxRef = React.useRef<HTMLDivElement>(null)\n\n const showVerifyEmail = modifiedUser.email && !user.email_is_verified && !hasUnsavedChanges\n const showVerifyPhone = modifiedUser.phone && !user.phone_is_verified && !hasUnsavedChanges\n\n React.useEffect(() => {\n if (handleOnLeaveClick) {\n const handleClickOutside = (event: MouseEvent) => {\n if (boxRef.current && !boxRef.current.contains(event.target as Node) && hasUnsavedChanges) {\n setShowLeaveDialog(true)\n }\n }\n\n document.addEventListener('mousedown', handleClickOutside)\n return () => {\n document.removeEventListener('mousedown', handleClickOutside)\n }\n }\n return undefined\n }, [hasUnsavedChanges])\n\n // eslint-disable-next-line consistent-return\n const formatReadableBirthday = () => {\n if (modifiedUser.birthday) {\n const utc = new Date(modifiedUser.birthday * 1000)\n const year = utc.getUTCFullYear()\n const month = utc.getUTCMonth()\n const day = utc.getUTCDate()\n return new Date(year, month, day)\n }\n }\n\n const handleSave = async () => {\n await updateUser({ ...user, ...modifiedUser })\n setHasUnsavedChanges(false)\n }\n\n const handleLeaveDialog = () => {\n setShowLeaveDialog(false)\n\n if (handleOnLeaveClick) {\n handleOnLeaveClick()\n }\n }\n\n const handleKeepEditing = () => {\n setShowLeaveDialog(false)\n }\n\n const handleInput = (update: UserInput) => {\n const changedUser = {\n ...modifiedUser,\n ...update,\n }\n setModifiedUser(changedUser)\n setHasUnsavedChanges(JSON.stringify({ ...user, ...changedUser }) !== JSON.stringify(user))\n }\n\n return (\n <>\n <Box\n component=\"form\"\n ref={boxRef}\n sx={{\n backgroundColor: 'background.paper',\n p: 24,\n '& .MuiTextField-root, & .MuiPickersTextField-root': {\n flex: 1,\n },\n }}\n >\n <H3>{settingsCopy.personal_details}</H3>\n <P variant=\"body1\">{settingsCopy.update_information}</P>\n <Stack direction={isMobile ? 'column' : 'row'} spacing={24} sx={{ mb: 24, pt: 24 }}>\n <TextField\n defaultValue={modifiedUser.first_name}\n label={settingsCopy.first_name}\n onChange={(e) => handleInput({ first_name: e.target.value })}\n />\n <TextField\n defaultValue={modifiedUser.last_name}\n label={settingsCopy.last_name}\n onChange={(e) => handleInput({ last_name: e.target.value })}\n />\n </Stack>\n <Stack direction={isMobile ? 'column' : 'row'}>\n {config.display_email_edit_field_in_settings && (\n <Stack sx={{ flex: 1, mb: showVerifyEmail ? 20 : 24, mr: isMobile ? 0 : 24 }}>\n <TextField\n defaultValue={modifiedUser.email}\n label={settingsCopy.email_address}\n onChange={(e) => handleInput({ email: e.target.value })}\n />\n {showVerifyEmail && <VerifyEmailAction />}\n </Stack>\n )}\n {config.display_sms_edit_field_in_settings && (\n <Stack sx={{ flex: 1, mb: showVerifyPhone ? 20 : 24 }}>\n <TextField\n defaultValue={modifiedUser.phone}\n label={settingsCopy.mobile_number}\n onChange={(e) => handleInput({ phone: e.target.value })}\n type=\"tel\"\n />\n {showVerifyPhone && <VerifyPhoneAction />}\n </Stack>\n )}\n </Stack>\n <Stack direction={isMobile ? 'column' : 'row'} spacing={24} sx={{ mb: 24 }}>\n <LocalizationProvider dateAdapter={AdapterDateFns}>\n <DatePicker\n label={settingsCopy.birthdate}\n onChange={(value) => handleInput({ birthday: getUnixTime(value as Date) })}\n slotProps={{\n nextIconButton: {\n sx: {\n color: 'primary.main',\n '&:hover': { backgroundColor: alpha(theme.palette.primary.light, 0.1) },\n },\n },\n previousIconButton: {\n sx: {\n color: 'primary.main',\n '&:hover': { backgroundColor: alpha(theme.palette.primary.light, 0.1) },\n },\n },\n }}\n sx={{\n width: '100%',\n '& .MuiIconButton-edgeEnd': {\n color: 'primary.main',\n '&:hover': { backgroundColor: alpha(theme.palette.primary.light, 0.1) },\n },\n }}\n value={formatReadableBirthday()}\n />\n </LocalizationProvider>\n <TextField\n defaultValue={modifiedUser.postal_code}\n label={settingsCopy.zip_code}\n onChange={(e) => handleInput({ postal_code: e.target.value })}\n />\n </Stack>\n <Stack>\n <TextField\n defaultValue={modifiedUser.credit_score}\n label={settingsCopy.credit_score}\n onChange={(e) => handleInput({ credit_score: Number(e.target.value) })}\n />\n {config.display_password_options_in_settings && <ResetPasswordAction />}\n <Button\n disabled={!hasUnsavedChanges}\n onClick={handleSave}\n sx={{ width: isMobile ? '100%' : 124 }}\n variant=\"contained\"\n >\n {commonCopy.save_button}\n </Button>\n </Stack>\n </Box>\n <Dialog\n copy={{ title: settingsCopy.discard_changes }}\n isOpen={showLeaveDialog}\n onClose={handleKeepEditing}\n onSecondaryAction={handleLeaveDialog}\n primaryText={settingsCopy.keep_editing}\n secondaryText={settingsCopy.leave}\n >\n {settingsCopy.discard_changes_message}\n </Dialog>\n </>\n )\n}\n\nexport default observer(ProfileForm)\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,IAAM,IAAA,CAA2C,EAAE,gBAAA,GAAgB,oBAAA,EAAA,MAAyB;AAC1F,QAAM,IAAQ,EAAS,GACjB,EAAE,QAAQ,GAAY,UAAU,EAAA,IAAiB,EAAmB,GACpE,EAAE,UAAA,EAAA,IAAa,EAAc,CAAc,GAC3C,EAAE,QAAA,EAAA,IAAW,EAAa,GAC1B,EAAE,YAAA,EAAA,I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A,IAC5C,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,mBAAmB;AAAA,IACnB,aAAa,EAAa;AAAA,IAC1B,eAAe,EAAa;AAAA,IAE3B,UAAA,EAAa;AAAA,EACR,CAAA,CACR,EAAA,CAAA;AAEN,GAEA,KAAe,EAAS,CAAW"}
|
|
1
|
+
{"version":3,"file":"ProfileTab.es.js","names":[],"sources":["../../../../src/settings/components/profile/ProfileTab.tsx"],"sourcesContent":["import React from 'react'\nimport { observer } from 'mobx-react-lite'\nimport { getUnixTime } from 'date-fns/getUnixTime'\n\nimport { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'\nimport { DatePicker } from '@mui/x-date-pickers'\nimport { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'\n\nimport { alpha, useTheme } from '@mui/material/styles'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\n\nimport { H3, P } from '@mxenabled/mxui'\n\nimport {\n useAppConfig,\n useGlobalCopyStore,\n useScreenSize,\n useSettingsStore,\n useUserStore,\n Dialog,\n} from '../../../common'\nimport { type EditableUser } from '../../../core'\nimport ResetPasswordAction from './actions/ResetPasswordAction'\nimport VerifyEmailAction from './actions/VerifyEmailAction'\nimport VerifyPhoneAction from './actions/VerifyPhoneAction'\n\ninterface ProfileFormProps {\n availableWidth?: number\n handleOnLeaveClick?: () => void\n}\n\ntype UserInput = {\n [U in keyof EditableUser]: EditableUser[U]\n}\n\nconst ProfileForm: React.FC<ProfileFormProps> = ({ availableWidth, handleOnLeaveClick }) => {\n const theme = useTheme()\n const { common: commonCopy, settings: settingsCopy } = useGlobalCopyStore()\n const { isMobile } = useScreenSize(availableWidth)\n const { config } = useAppConfig()\n const { updateUser } = useSettingsStore()\n const { user } = useUserStore()\n\n const [modifiedUser, setModifiedUser] = React.useState<EditableUser>({\n first_name: user.first_name,\n last_name: user.last_name,\n email: user.email,\n phone: user.phone,\n birthday: user.birthday,\n postal_code: user.postal_code,\n credit_score: user.credit_score,\n })\n const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false)\n const [showLeaveDialog, setShowLeaveDialog] = React.useState(false)\n const boxRef = React.useRef<HTMLDivElement>(null)\n\n const showVerifyEmail = modifiedUser.email && !user.email_is_verified && !hasUnsavedChanges\n const showVerifyPhone = modifiedUser.phone && !user.phone_is_verified && !hasUnsavedChanges\n // Hidden only when the server says there is no password; a missing has_password shows it.\n const showResetPassword =\n config.display_password_options_in_settings && user.has_password !== false\n\n React.useEffect(() => {\n if (handleOnLeaveClick) {\n const handleClickOutside = (event: MouseEvent) => {\n if (boxRef.current && !boxRef.current.contains(event.target as Node) && hasUnsavedChanges) {\n setShowLeaveDialog(true)\n }\n }\n\n document.addEventListener('mousedown', handleClickOutside)\n return () => {\n document.removeEventListener('mousedown', handleClickOutside)\n }\n }\n return undefined\n }, [hasUnsavedChanges])\n\n // eslint-disable-next-line consistent-return\n const formatReadableBirthday = () => {\n if (modifiedUser.birthday) {\n const utc = new Date(modifiedUser.birthday * 1000)\n const year = utc.getUTCFullYear()\n const month = utc.getUTCMonth()\n const day = utc.getUTCDate()\n return new Date(year, month, day)\n }\n }\n\n const handleSave = async () => {\n await updateUser({ ...user, ...modifiedUser })\n setHasUnsavedChanges(false)\n }\n\n const handleLeaveDialog = () => {\n setShowLeaveDialog(false)\n\n if (handleOnLeaveClick) {\n handleOnLeaveClick()\n }\n }\n\n const handleKeepEditing = () => {\n setShowLeaveDialog(false)\n }\n\n const handleInput = (update: UserInput) => {\n const changedUser = {\n ...modifiedUser,\n ...update,\n }\n setModifiedUser(changedUser)\n setHasUnsavedChanges(JSON.stringify({ ...user, ...changedUser }) !== JSON.stringify(user))\n }\n\n return (\n <>\n <Box\n component=\"form\"\n ref={boxRef}\n sx={{\n backgroundColor: 'background.paper',\n p: 24,\n '& .MuiTextField-root, & .MuiPickersTextField-root': {\n flex: 1,\n },\n }}\n >\n <H3>{settingsCopy.personal_details}</H3>\n <P variant=\"body1\">{settingsCopy.update_information}</P>\n <Stack direction={isMobile ? 'column' : 'row'} spacing={24} sx={{ mb: 24, pt: 24 }}>\n <TextField\n defaultValue={modifiedUser.first_name}\n label={settingsCopy.first_name}\n onChange={(e) => handleInput({ first_name: e.target.value })}\n />\n <TextField\n defaultValue={modifiedUser.last_name}\n label={settingsCopy.last_name}\n onChange={(e) => handleInput({ last_name: e.target.value })}\n />\n </Stack>\n <Stack direction={isMobile ? 'column' : 'row'}>\n {config.display_email_edit_field_in_settings && (\n <Stack sx={{ flex: 1, mb: showVerifyEmail ? 20 : 24, mr: isMobile ? 0 : 24 }}>\n <TextField\n defaultValue={modifiedUser.email}\n label={settingsCopy.email_address}\n onChange={(e) => handleInput({ email: e.target.value })}\n />\n {showVerifyEmail && <VerifyEmailAction />}\n </Stack>\n )}\n {config.display_sms_edit_field_in_settings && (\n <Stack sx={{ flex: 1, mb: showVerifyPhone ? 20 : 24 }}>\n <TextField\n defaultValue={modifiedUser.phone}\n label={settingsCopy.mobile_number}\n onChange={(e) => handleInput({ phone: e.target.value })}\n type=\"tel\"\n />\n {showVerifyPhone && <VerifyPhoneAction />}\n </Stack>\n )}\n </Stack>\n <Stack direction={isMobile ? 'column' : 'row'} spacing={24} sx={{ mb: 24 }}>\n <LocalizationProvider dateAdapter={AdapterDateFns}>\n <DatePicker\n label={settingsCopy.birthdate}\n onChange={(value) => handleInput({ birthday: getUnixTime(value as Date) })}\n slotProps={{\n nextIconButton: {\n sx: {\n color: 'primary.main',\n '&:hover': { backgroundColor: alpha(theme.palette.primary.light, 0.1) },\n },\n },\n previousIconButton: {\n sx: {\n color: 'primary.main',\n '&:hover': { backgroundColor: alpha(theme.palette.primary.light, 0.1) },\n },\n },\n }}\n sx={{\n width: '100%',\n '& .MuiIconButton-edgeEnd': {\n color: 'primary.main',\n '&:hover': { backgroundColor: alpha(theme.palette.primary.light, 0.1) },\n },\n }}\n value={formatReadableBirthday()}\n />\n </LocalizationProvider>\n <TextField\n defaultValue={modifiedUser.postal_code}\n label={settingsCopy.zip_code}\n onChange={(e) => handleInput({ postal_code: e.target.value })}\n />\n </Stack>\n <Stack>\n <TextField\n defaultValue={modifiedUser.credit_score}\n label={settingsCopy.credit_score}\n onChange={(e) => handleInput({ credit_score: Number(e.target.value) })}\n />\n {showResetPassword && <ResetPasswordAction />}\n <Button\n disabled={!hasUnsavedChanges}\n onClick={handleSave}\n // Reset Password normally separates Credit Score from Save; keep the gap without it.\n sx={{ mt: showResetPassword ? 0 : 24, width: isMobile ? '100%' : 124 }}\n variant=\"contained\"\n >\n {commonCopy.save_button}\n </Button>\n </Stack>\n </Box>\n <Dialog\n copy={{ title: settingsCopy.discard_changes }}\n isOpen={showLeaveDialog}\n onClose={handleKeepEditing}\n onSecondaryAction={handleLeaveDialog}\n primaryText={settingsCopy.keep_editing}\n secondaryText={settingsCopy.leave}\n >\n {settingsCopy.discard_changes_message}\n </Dialog>\n </>\n )\n}\n\nexport default observer(ProfileForm)\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,IAAM,KAAA,CAA2C,EAAE,gBAAA,GAAgB,oBAAA,EAAA,MAAyB;AAC1F,QAAM,IAAQ,EAAS,GACjB,EAAE,QAAQ,GAAY,UAAU,EAAA,IAAiB,EAAmB,GACpE,EAAE,UAAA,EAAA,IAAa,EAAc,CAAc,GAC3C,EAAE,QAAA,EAAA,IAAW,EAAa,GAC1B,EAAE,YAAA,EAAA,IAAe,EAAiB,GAClC,EAAE,MAAA,EAAA,IAAS,EAAa,GAExB,CAAC,GAAc,CAAA,IAAmB,EAAM,SAAuB;AAAA,IACnE,YAAY,EAAK;AAAA,IACjB,WAAW,EAAK;AAAA,IAChB,OAAO,EAAK;AAAA,IACZ,OAAO,EAAK;AAAA,IACZ,UAAU,EAAK;AAAA,IACf,aAAa,EAAK;AAAA,IAClB,cAAc,EAAK;AAAA,EACrB,CAAC,GACK,CAAC,GAAmB,CAAA,IAAwB,EAAM,SAAS,EAAK,GAChE,C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
|
-
import
|
|
3
|
-
import { HAS_LETTER as
|
|
4
|
-
import
|
|
5
|
-
import { observer as
|
|
6
|
-
import
|
|
7
|
-
import { Text as
|
|
8
|
-
import
|
|
9
|
-
import { ChevronRight as
|
|
10
|
-
import { jsx as e, jsxs as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
var
|
|
15
|
-
const { common:
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
},
|
|
1
|
+
import { useGlobalCopyStore as N, useSettingsStore as T } from "../../../../common/context/hooks.es.js";
|
|
2
|
+
import I from "../../../../common/components/dialog/Dialog.es.js";
|
|
3
|
+
import { HAS_LETTER as H, HAS_NUMBER as k, HIDE_CONFIRM_PASSWORD as M, HIDE_CURRENT_PASSWORD as B, HIDE_NEW_PASSWORD as U, PASSWORD_REQUIREMENTS as j, SHOW_CONFIRM_PASSWORD as F, SHOW_CURRENT_PASSWORD as V, SHOW_NEW_PASSWORD as G } from "../../../constants/Settings.es.js";
|
|
4
|
+
import t from "react";
|
|
5
|
+
import { observer as L } from "mobx-react-lite";
|
|
6
|
+
import A from "@mui/material/Stack";
|
|
7
|
+
import { Text as O } from "@mxenabled/mxui";
|
|
8
|
+
import Q from "@mui/material/Button";
|
|
9
|
+
import { ChevronRight as $, Visibility as p, VisibilityOff as c } from "@mxenabled/mx-icons";
|
|
10
|
+
import { jsx as e, jsxs as m } from "react/jsx-runtime";
|
|
11
|
+
import w from "@mui/material/IconButton";
|
|
12
|
+
import u from "@mui/material/InputAdornment";
|
|
13
|
+
import S from "@mui/material/TextField";
|
|
14
|
+
var ae = L(() => {
|
|
15
|
+
const { common: b, settings: o } = N(), { updatePassword: x } = T(), [v, f] = t.useState(!1), [d, h] = t.useState(""), [n, _] = t.useState(!1), [s, P] = t.useState(""), [l, C] = t.useState(""), [a, g] = t.useState(!1), [i, R] = t.useState(!1), E = d.length > 0 && s.length >= 12 && H.test(s) && k.test(s) && s === l, y = () => {
|
|
16
|
+
f(!1), h(""), _(!1), P(""), C(""), g(!1), R(!1);
|
|
17
|
+
}, W = () => {
|
|
18
|
+
f(!0);
|
|
19
|
+
}, D = () => {
|
|
20
20
|
x({
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
current_password: d,
|
|
22
|
+
new_password: s,
|
|
23
|
+
new_password_again: l
|
|
23
24
|
});
|
|
24
25
|
};
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
onClick:
|
|
27
|
-
children: [/* @__PURE__ */ e(
|
|
26
|
+
return /* @__PURE__ */ m(A, { children: [/* @__PURE__ */ m(Q, {
|
|
27
|
+
onClick: W,
|
|
28
|
+
children: [/* @__PURE__ */ e(O, {
|
|
28
29
|
variant: "body2",
|
|
29
|
-
children:
|
|
30
|
-
}), /* @__PURE__ */ e(
|
|
31
|
-
}), /* @__PURE__ */ e(
|
|
32
|
-
copy: { title:
|
|
33
|
-
disablePrimaryButton: !
|
|
34
|
-
isOpen:
|
|
35
|
-
onClose:
|
|
36
|
-
onPrimaryAction:
|
|
37
|
-
onSecondaryAction:
|
|
38
|
-
primaryText:
|
|
39
|
-
secondaryText:
|
|
30
|
+
children: o.reset_password
|
|
31
|
+
}), /* @__PURE__ */ e($, {})]
|
|
32
|
+
}), /* @__PURE__ */ e(I, {
|
|
33
|
+
copy: { title: o.reset_password },
|
|
34
|
+
disablePrimaryButton: !E,
|
|
35
|
+
isOpen: v,
|
|
36
|
+
onClose: y,
|
|
37
|
+
onPrimaryAction: D,
|
|
38
|
+
onSecondaryAction: y,
|
|
39
|
+
primaryText: o.save_password,
|
|
40
|
+
secondaryText: b.cancel_button,
|
|
40
41
|
sx: { "& .MuiToolbar-root:last-child": {
|
|
41
42
|
padding: 24,
|
|
42
43
|
justifyContent: "flex-end"
|
|
43
44
|
} },
|
|
44
|
-
children: /* @__PURE__ */
|
|
45
|
+
children: /* @__PURE__ */ m(A, {
|
|
45
46
|
spacing: 16,
|
|
46
47
|
sx: {
|
|
47
48
|
px: 40,
|
|
48
|
-
textAlign: "
|
|
49
|
+
textAlign: "left",
|
|
49
50
|
width: "100%"
|
|
50
51
|
},
|
|
51
52
|
children: [
|
|
52
|
-
/* @__PURE__ */ e(
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
/* @__PURE__ */ e(S, {
|
|
54
|
+
autoComplete: "current-password",
|
|
55
|
+
label: o.current_password,
|
|
56
|
+
onChange: (r) => h(r.target.value),
|
|
57
|
+
slotProps: { input: { endAdornment: /* @__PURE__ */ e(u, {
|
|
58
|
+
position: "end",
|
|
59
|
+
children: /* @__PURE__ */ e(w, {
|
|
60
|
+
"aria-label": n ? B : V,
|
|
61
|
+
edge: "end",
|
|
62
|
+
onClick: () => _(!n),
|
|
63
|
+
children: n ? /* @__PURE__ */ e(c, {}) : /* @__PURE__ */ e(p, {})
|
|
64
|
+
})
|
|
65
|
+
}) } },
|
|
66
|
+
type: n ? "text" : "password",
|
|
67
|
+
value: d
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ e(O, {
|
|
70
|
+
variant: "body2",
|
|
71
|
+
children: j
|
|
55
72
|
}),
|
|
56
|
-
/* @__PURE__ */ e(
|
|
57
|
-
label:
|
|
58
|
-
onChange: (
|
|
59
|
-
slotProps: { input: { endAdornment: /* @__PURE__ */ e(
|
|
73
|
+
/* @__PURE__ */ e(S, {
|
|
74
|
+
label: o.new_password,
|
|
75
|
+
onChange: (r) => P(r.target.value),
|
|
76
|
+
slotProps: { input: { endAdornment: /* @__PURE__ */ e(u, {
|
|
60
77
|
position: "end",
|
|
61
|
-
children: /* @__PURE__ */ e(
|
|
62
|
-
"aria-label":
|
|
78
|
+
children: /* @__PURE__ */ e(w, {
|
|
79
|
+
"aria-label": a ? U : G,
|
|
63
80
|
edge: "end",
|
|
64
|
-
onClick: () =>
|
|
65
|
-
children:
|
|
81
|
+
onClick: () => g(!a),
|
|
82
|
+
children: a ? /* @__PURE__ */ e(c, {}) : /* @__PURE__ */ e(p, {})
|
|
66
83
|
})
|
|
67
84
|
}) } },
|
|
68
|
-
type:
|
|
69
|
-
value:
|
|
85
|
+
type: a ? "text" : "password",
|
|
86
|
+
value: s
|
|
70
87
|
}),
|
|
71
|
-
/* @__PURE__ */ e(
|
|
72
|
-
label:
|
|
73
|
-
onChange: (
|
|
74
|
-
slotProps: { input: { endAdornment: /* @__PURE__ */ e(
|
|
88
|
+
/* @__PURE__ */ e(S, {
|
|
89
|
+
label: o.confirm_new_password,
|
|
90
|
+
onChange: (r) => C(r.target.value),
|
|
91
|
+
slotProps: { input: { endAdornment: /* @__PURE__ */ e(u, {
|
|
75
92
|
position: "end",
|
|
76
|
-
children: /* @__PURE__ */ e(
|
|
77
|
-
"aria-label":
|
|
93
|
+
children: /* @__PURE__ */ e(w, {
|
|
94
|
+
"aria-label": i ? M : F,
|
|
78
95
|
edge: "end",
|
|
79
|
-
onClick: () =>
|
|
80
|
-
children:
|
|
96
|
+
onClick: () => R(!i),
|
|
97
|
+
children: i ? /* @__PURE__ */ e(c, {}) : /* @__PURE__ */ e(p, {})
|
|
81
98
|
})
|
|
82
99
|
}) } },
|
|
83
|
-
type:
|
|
84
|
-
value:
|
|
100
|
+
type: i ? "text" : "password",
|
|
101
|
+
value: l
|
|
85
102
|
})
|
|
86
103
|
]
|
|
87
104
|
})
|
|
88
105
|
})] });
|
|
89
106
|
});
|
|
90
107
|
export {
|
|
91
|
-
|
|
108
|
+
ae as default
|
|
92
109
|
};
|
|
93
110
|
|
|
94
111
|
//# sourceMappingURL=ResetPasswordAction.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResetPasswordAction.es.js","names":[],"sources":["../../../../../src/settings/components/profile/actions/ResetPasswordAction.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\nimport React from 'react'\n\nimport Button from '@mui/material/Button'\nimport IconButton from '@mui/material/IconButton'\nimport InputAdornment from '@mui/material/InputAdornment'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\n\nimport { Text } from '@mxenabled/mxui'\nimport { ChevronRight, Visibility, VisibilityOff } from '@mxenabled/mx-icons'\n\nimport { Dialog, useGlobalCopyStore, useSettingsStore } from '../../../../common'\nimport {\n HAS_LETTER,\n HAS_NUMBER,\n HIDE_CONFIRM_PASSWORD,\n HIDE_NEW_PASSWORD,\n MIN_PASSWORD_LENGTH,\n PASSWORD_REQUIREMENTS,\n SHOW_CONFIRM_PASSWORD,\n SHOW_NEW_PASSWORD,\n} from '../../../constants/Settings'\n\nconst ResetPasswordAction = observer(() => {\n const { common: commonCopy, settings: settingsCopy } = useGlobalCopyStore()\n const { updatePassword } = useSettingsStore()\n\n const [isOpen, setIsOpen] = React.useState(false)\n const [newPassword, setNewPassword] = React.useState('')\n const [confirmPassword, setConfirmPassword] = React.useState('')\n const [showNewPassword, setShowNewPassword] = React.useState(false)\n const [showConfirmPassword, setShowConfirmPassword] = React.useState(false)\n const isValid =\n newPassword.length >= MIN_PASSWORD_LENGTH &&\n HAS_LETTER.test(newPassword) &&\n HAS_NUMBER.test(newPassword) &&\n newPassword === confirmPassword\n\n const handleClose = (): void => {\n setIsOpen(false)\n setNewPassword('')\n setConfirmPassword('')\n setShowNewPassword(false)\n setShowConfirmPassword(false)\n }\n\n const handleOpen = (): void => {\n setIsOpen(true)\n }\n\n const handleSave = () => {\n updatePassword({ new_password: newPassword
|
|
1
|
+
{"version":3,"file":"ResetPasswordAction.es.js","names":[],"sources":["../../../../../src/settings/components/profile/actions/ResetPasswordAction.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\nimport React from 'react'\n\nimport Button from '@mui/material/Button'\nimport IconButton from '@mui/material/IconButton'\nimport InputAdornment from '@mui/material/InputAdornment'\nimport Stack from '@mui/material/Stack'\nimport TextField from '@mui/material/TextField'\n\nimport { Text } from '@mxenabled/mxui'\nimport { ChevronRight, Visibility, VisibilityOff } from '@mxenabled/mx-icons'\n\nimport { Dialog, useGlobalCopyStore, useSettingsStore } from '../../../../common'\nimport {\n HAS_LETTER,\n HAS_NUMBER,\n HIDE_CONFIRM_PASSWORD,\n HIDE_CURRENT_PASSWORD,\n HIDE_NEW_PASSWORD,\n MIN_PASSWORD_LENGTH,\n PASSWORD_REQUIREMENTS,\n SHOW_CONFIRM_PASSWORD,\n SHOW_CURRENT_PASSWORD,\n SHOW_NEW_PASSWORD,\n} from '../../../constants/Settings'\n\nconst ResetPasswordAction = observer(() => {\n const { common: commonCopy, settings: settingsCopy } = useGlobalCopyStore()\n const { updatePassword } = useSettingsStore()\n\n const [isOpen, setIsOpen] = React.useState(false)\n const [currentPassword, setCurrentPassword] = React.useState('')\n const [showCurrentPassword, setShowCurrentPassword] = React.useState(false)\n const [newPassword, setNewPassword] = React.useState('')\n const [confirmPassword, setConfirmPassword] = React.useState('')\n const [showNewPassword, setShowNewPassword] = React.useState(false)\n const [showConfirmPassword, setShowConfirmPassword] = React.useState(false)\n const isValid =\n currentPassword.length > 0 &&\n newPassword.length >= MIN_PASSWORD_LENGTH &&\n HAS_LETTER.test(newPassword) &&\n HAS_NUMBER.test(newPassword) &&\n newPassword === confirmPassword\n\n const handleClose = (): void => {\n setIsOpen(false)\n setCurrentPassword('')\n setShowCurrentPassword(false)\n setNewPassword('')\n setConfirmPassword('')\n setShowNewPassword(false)\n setShowConfirmPassword(false)\n }\n\n const handleOpen = (): void => {\n setIsOpen(true)\n }\n\n const handleSave = () => {\n updatePassword({\n current_password: currentPassword,\n new_password: newPassword,\n new_password_again: confirmPassword,\n })\n }\n\n return (\n <Stack>\n <Button onClick={handleOpen}>\n <Text variant=\"body2\">{settingsCopy.reset_password}</Text>\n <ChevronRight />\n </Button>\n <Dialog\n copy={{ title: settingsCopy.reset_password }}\n disablePrimaryButton={!isValid}\n isOpen={isOpen}\n onClose={handleClose}\n onPrimaryAction={handleSave}\n onSecondaryAction={handleClose}\n primaryText={settingsCopy.save_password}\n secondaryText={commonCopy.cancel_button}\n sx={{\n '& .MuiToolbar-root:last-child': {\n padding: 24,\n justifyContent: 'flex-end',\n },\n }}\n >\n <Stack spacing={16} sx={{ px: 40, textAlign: 'left', width: '100%' }}>\n <TextField\n autoComplete=\"current-password\"\n label={settingsCopy.current_password}\n onChange={(e) => setCurrentPassword(e.target.value)}\n slotProps={{\n input: {\n endAdornment: (\n <InputAdornment position=\"end\">\n <IconButton\n aria-label={\n showCurrentPassword ? HIDE_CURRENT_PASSWORD : SHOW_CURRENT_PASSWORD\n }\n edge=\"end\"\n onClick={() => setShowCurrentPassword(!showCurrentPassword)}\n >\n {showCurrentPassword ? <VisibilityOff /> : <Visibility />}\n </IconButton>\n </InputAdornment>\n ),\n },\n }}\n type={showCurrentPassword ? 'text' : 'password'}\n value={currentPassword}\n />\n <Text variant=\"body2\">{PASSWORD_REQUIREMENTS}</Text>\n <TextField\n label={settingsCopy.new_password}\n onChange={(e) => setNewPassword(e.target.value)}\n slotProps={{\n input: {\n endAdornment: (\n <InputAdornment position=\"end\">\n <IconButton\n aria-label={showNewPassword ? HIDE_NEW_PASSWORD : SHOW_NEW_PASSWORD}\n edge=\"end\"\n onClick={() => setShowNewPassword(!showNewPassword)}\n >\n {showNewPassword ? <VisibilityOff /> : <Visibility />}\n </IconButton>\n </InputAdornment>\n ),\n },\n }}\n type={showNewPassword ? 'text' : 'password'}\n value={newPassword}\n />\n <TextField\n label={settingsCopy.confirm_new_password}\n onChange={(e) => setConfirmPassword(e.target.value)}\n slotProps={{\n input: {\n endAdornment: (\n <InputAdornment position=\"end\">\n <IconButton\n aria-label={\n showConfirmPassword ? HIDE_CONFIRM_PASSWORD : SHOW_CONFIRM_PASSWORD\n }\n edge=\"end\"\n onClick={() => setShowConfirmPassword(!showConfirmPassword)}\n >\n {showConfirmPassword ? <VisibilityOff /> : <Visibility />}\n </IconButton>\n </InputAdornment>\n ),\n },\n }}\n type={showConfirmPassword ? 'text' : 'password'}\n value={confirmPassword}\n />\n </Stack>\n </Dialog>\n </Stack>\n )\n})\n\nexport default ResetPasswordAction\n"],"mappings":";;;;;;;;;;;;;AA0B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AAS;AAAA,YACvB,UAAA,gBAAA,EAAC,GAAD;AAAA,cACE,cAAY,IAAkB,IAAoB;AAAA,cAClD,MAAK;AAAA,cACL,SAAA,MAAe,EAAmB,CAAC,CAAe;AAAA,cAEjD,UAAA,IAAkB,gBAAA,EAAC,GAAD,CAAgB,CAAA,IAAI,gBAAA,EAAC,GAAD,CAAa,CAAA;AAAA,YAC1C,CAAA;AAAA,UACE,CAAA,EAEpB,EACF;AAAA,UACA,MAAM,IAAkB,SAAS;AAAA,UACjC,OAAO;AAAA,QACR,CAAA;AAAA,QACD,gBAAA,EAAC,GAAD;AAAA,UACE,OAAO,EAAa;AAAA,UACpB,UAAA,CAAW,MAAM,EAAmB,EAAE,OAAO,KAAK;AAAA,UAClD,WAAW,EACT,OAAO,EACL,cACE,gBAAA,EAAC,GAAD;AAAA,YAAgB,UAAS;AAAA,YACvB,UAAA,gBAAA,EAAC,GAAD;AAAA,cACE,cACE,IAAsB,IAAwB;AAAA,cAEhD,MAAK;AAAA,cACL,SAAA,MAAe,EAAuB,CAAC,CAAmB;AAAA,cAEzD,UAAA,IAAsB,gBAAA,EAAC,GAAD,CAAgB,CAAA,IAAI,gBAAA,EAAC,GAAD,CAAa,CAAA;AAAA,YAC9C,CAAA;AAAA,UACE,CAAA,EAEpB,EACF;AAAA,UACA,MAAM,IAAsB,SAAS;AAAA,UACrC,OAAO;AAAA,QACR,CAAA;AAAA,MACI;AAAA;EACD,CAAA,CACH,EAAA,CAAA;AAEX,CAAC"}
|
|
@@ -6,6 +6,8 @@ export declare enum DialogType {
|
|
|
6
6
|
export declare const MIN_PASSWORD_LENGTH = 12;
|
|
7
7
|
export declare const HAS_LETTER: RegExp;
|
|
8
8
|
export declare const HAS_NUMBER: RegExp;
|
|
9
|
+
export declare const HIDE_CURRENT_PASSWORD = "Hide current password";
|
|
10
|
+
export declare const SHOW_CURRENT_PASSWORD = "Show current password";
|
|
9
11
|
export declare const HIDE_NEW_PASSWORD = "Hide new password";
|
|
10
12
|
export declare const SHOW_NEW_PASSWORD = "Show new password";
|
|
11
13
|
export declare const HIDE_CONFIRM_PASSWORD = "Hide confirm password";
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
return
|
|
3
|
-
})({}),
|
|
1
|
+
var a = /* @__PURE__ */ (function(r) {
|
|
2
|
+
return r.Delete = "delete", r.Edit = "edit", r.Token = "token", r;
|
|
3
|
+
})({}), e = /[a-zA-Z]/, S = /\d/, s = "Hide current password", t = "Show current password", n = "Hide new password", o = "Show new password", R = "Hide confirm password", d = "Show confirm password", _ = "Passwords must be at least 12 characters, and must contain at least one number and one letter.";
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
a as DialogType,
|
|
6
|
+
e as HAS_LETTER,
|
|
7
|
+
S as HAS_NUMBER,
|
|
8
|
+
R as HIDE_CONFIRM_PASSWORD,
|
|
9
|
+
s as HIDE_CURRENT_PASSWORD,
|
|
10
|
+
n as HIDE_NEW_PASSWORD,
|
|
11
|
+
_ as PASSWORD_REQUIREMENTS,
|
|
12
|
+
d as SHOW_CONFIRM_PASSWORD,
|
|
13
|
+
t as SHOW_CURRENT_PASSWORD,
|
|
14
|
+
o as SHOW_NEW_PASSWORD
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
//# sourceMappingURL=Settings.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.es.js","names":[],"sources":["../../../src/settings/constants/Settings.ts"],"sourcesContent":["export enum DialogType {\n Delete = 'delete',\n Edit = 'edit',\n Token = 'token',\n}\n\nexport const MIN_PASSWORD_LENGTH = 12\nexport const HAS_LETTER = /[a-zA-Z]/\nexport const HAS_NUMBER = /\\d/\nexport const HIDE_NEW_PASSWORD = 'Hide new password'\nexport const SHOW_NEW_PASSWORD = 'Show new password'\nexport const HIDE_CONFIRM_PASSWORD = 'Hide confirm password'\nexport const SHOW_CONFIRM_PASSWORD = 'Show confirm password'\nexport const PASSWORD_REQUIREMENTS =\n 'Passwords must be at least 12 characters, and must contain at least one number and one letter.'\n"],"mappings":"AAAA,IAAY,IAAL,0BAAA,GAAA;AACL,SAAA,EAAA,SAAA,UACA,EAAA,OAAA,QACA,EAAA,QAAA;AACF,GAAA,CAAA,CAAA,GAGa,IAAa,YACb,IAAa,MACb,IAAoB,qBACpB,IAAoB,qBACpB,IAAwB,yBACxB,IAAwB,yBACxB,IACX"}
|
|
1
|
+
{"version":3,"file":"Settings.es.js","names":[],"sources":["../../../src/settings/constants/Settings.ts"],"sourcesContent":["export enum DialogType {\n Delete = 'delete',\n Edit = 'edit',\n Token = 'token',\n}\n\nexport const MIN_PASSWORD_LENGTH = 12\nexport const HAS_LETTER = /[a-zA-Z]/\nexport const HAS_NUMBER = /\\d/\nexport const HIDE_CURRENT_PASSWORD = 'Hide current password'\nexport const SHOW_CURRENT_PASSWORD = 'Show current password'\nexport const HIDE_NEW_PASSWORD = 'Hide new password'\nexport const SHOW_NEW_PASSWORD = 'Show new password'\nexport const HIDE_CONFIRM_PASSWORD = 'Hide confirm password'\nexport const SHOW_CONFIRM_PASSWORD = 'Show confirm password'\nexport const PASSWORD_REQUIREMENTS =\n 'Passwords must be at least 12 characters, and must contain at least one number and one letter.'\n"],"mappings":"AAAA,IAAY,IAAL,0BAAA,GAAA;AACL,SAAA,EAAA,SAAA,UACA,EAAA,OAAA,QACA,EAAA,QAAA;AACF,GAAA,CAAA,CAAA,GAGa,IAAa,YACb,IAAa,MACb,IAAwB,yBACxB,IAAwB,yBACxB,IAAoB,qBACpB,IAAoB,qBACpB,IAAwB,yBACxB,IAAwB,yBACxB,IACX"}
|