@dashadmin/dash-admin 1.3.73 → 1.3.74-srcfree.1
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/dist/components/tenant/TenancyPlan.js +307 -0
- package/dist/systemResources.js +18 -2
- package/package.json +25 -22
- package/src/AppAsyncWrapper.tsx +0 -42
- package/src/AppWrapper.tsx +0 -45
- package/src/DASHAdmin.tsx +0 -502
- package/src/DASHAdmin.tsx.old +0 -456
- package/src/RoutingWrapper.tsx +0 -143
- package/src/classes/DASHStorageClass.tsx +0 -8
- package/src/components/Input/RichTextField.tsx +0 -27
- package/src/components/Redirect.tsx +0 -46
- package/src/components/avatar/Avatar.tsx +0 -71
- package/src/components/avatar/SingleImageUploader.tsx +0 -107
- package/src/components/currency/Format.tsx +0 -79
- package/src/components/custom/Redirect.tsx +0 -23
- package/src/components/error/Error.tsx +0 -168
- package/src/components/geocoding/GeocodingField.tsx +0 -167
- package/src/components/i18n/BridgedLocalesMenuButton.tsx +0 -160
- package/src/components/i18n/LangSwitcher.tsx +0 -204
- package/src/components/loader/GlobalLoader.tsx +0 -49
- package/src/components/logs/LogFile.tsx +0 -88
- package/src/components/logs/LogFileById.tsx +0 -68
- package/src/components/logs/LogViewer.tsx +0 -43
- package/src/components/menu/AppMenu.tsx +0 -22
- package/src/components/menu/CustomMenuItemLink.tsx +0 -61
- package/src/components/menu/DarkToggleMode.tsx +0 -65
- package/src/components/menu/LanguageToggleMode.tsx +0 -120
- package/src/components/misc/CustomImageInput.tsx +0 -62
- package/src/components/misc/DASHGlobalErrorHandler.tsx +0 -194
- package/src/components/misc/DarkModeSwitcher.tsx +0 -112
- package/src/components/misc/HorizontalScroller.tsx +0 -225
- package/src/components/misc/LanguageSwitcher.tsx +0 -199
- package/src/components/misc/MUIHtmlToolTip.tsx +0 -15
- package/src/components/misc/MuiSimpleJsonTable.tsx +0 -279
- package/src/components/misc/MultiLevelTable.tsx +0 -229
- package/src/components/misc/NoResults.tsx +0 -28
- package/src/components/misc/PDFViewer.tsx +0 -85
- package/src/components/navigation/Breadcrumbs.tsx +0 -220
- package/src/components/navigation/BreadcrumbsManager.tsx +0 -310
- package/src/components/navigation/index.tsx +0 -5
- package/src/components/panel/Error.tsx +0 -168
- package/src/components/permission/AvailablePermissionsContext.tsx +0 -173
- package/src/components/permission/PermissionsSelector.tsx +0 -834
- package/src/components/permission/PermissionsSelectorList.tsx +0 -473
- package/src/components/permission/tsx +0 -0
- package/src/components/racustombuttons/CustomRAButton.tsx +0 -87
- package/src/components/racustombuttons/QuickButton.tsx +0 -117
- package/src/components/racustombuttons/QuickEditButton.tsx +0 -115
- package/src/components/racustombuttons/QuickIconButton.tsx +0 -122
- package/src/components/scrollbar/Scrollbar.tsx +0 -31
- package/src/components/selects/MultiSelect.tsx +0 -53
- package/src/components/selects/RASearchableSelect.tsx +0 -282
- package/src/components/selects/RASearchableSelectChips.tsx +0 -308
- package/src/components/selects/SearchableSelect.tsx +0 -139
- package/src/components/serviceAccount/ApiKeyRevealDialog.tsx +0 -129
- package/src/components/serviceAccount/ServiceAccountStatusSwitch.tsx +0 -99
- package/src/components/subscription/BillingCycleSelectInput.tsx +0 -68
- package/src/components/subscription/PlanAddonsSettings.tsx +0 -563
- package/src/components/subscription/PlanAuditLog.tsx +0 -453
- package/src/components/subscription/PlanFeaturesSettings.tsx +0 -243
- package/src/components/subscription/PlanLimitsSettings.tsx +0 -230
- package/src/components/subscription/PlanMetadataSettings.tsx +0 -306
- package/src/components/subscription/PlanPricesSettings.tsx +0 -307
- package/src/components/subscription/index.ts +0 -7
- package/src/components/svgelements/SvgLoading.tsx +0 -229
- package/src/components/svgelements/SvgLogo.tsx +0 -53
- package/src/components/svgelements/SvgLogoMin.tsx +0 -64
- package/src/components/svgelements/SvgShipping.tsx +0 -673
- package/src/components/tenancy/GlobalTenantWrapper.tsx +0 -84
- package/src/components/tenancy/TenantSwitcher.tsx +0 -514
- package/src/components/tenant/AvailablePermissionsContext.tsx +0 -0
- package/src/components/tenant/SettingsSections.tsx +0 -151
- package/src/components/tenant/TenancySettings.tsx +0 -122
- package/src/components/tenant/TenantAttributes.tsx +0 -153
- package/src/components/tenant/TenantAttributesContext.tsx +0 -163
- package/src/components/tenant/TenantSelector.tsx +0 -142
- package/src/components/tenant/TenantSettings.tsx +0 -184
- package/src/components/tenant/TenantSettingsContext.tsx +0 -165
- package/src/components/tenant/TenantTheme.tsx +0 -172
- package/src/components/user/AvatarComponent.tsx +0 -317
- package/src/components/user/TenantAvatarComponent.tsx +0 -99
- package/src/components/user/UserPreferences.tsx +0 -677
- package/src/config/ACTIONS.tsx +0 -26
- package/src/config/ConstantsService.tsx +0 -44
- package/src/config/DASHAdminSystemConstants.tsx +0 -183
- package/src/config/PARSERS.tsx +0 -9
- package/src/contexts/DashQueryClientContext.tsx +0 -113
- package/src/contexts/DashResourceContext.tsx +0 -34
- package/src/contexts/I18nBridgeContext.tsx +0 -156
- package/src/contexts/I18nBridgeSetter.tsx +0 -39
- package/src/contexts/I18nReduxSync.tsx +0 -27
- package/src/contexts/SubscriptionPlanFormatsProvider.tsx +0 -217
- package/src/contexts/SystemRequestsCache.tsx +0 -215
- package/src/contexts/auth/AuthContext.tsx +0 -567
- package/src/contexts/auth/AuthContextLocalStorage.tsx +0 -140
- package/src/contexts/auth/DASHAuthenticationService.tsx +0 -915
- package/src/contexts/auth/WindowContext.tsx +0 -15
- package/src/contexts/auth/index.tsx +0 -3
- package/src/contexts/com/FCMContext.tsx +0 -415
- package/src/contexts/com/LaravelEchoContext.tsx +0 -41
- package/src/contexts/com/LaravelEchoMgr.tsx +0 -155
- package/src/contexts/com/components/DefaultNotificationComponent.tsx +0 -20
- package/src/contexts/com/components/EchoNotificationsCenter.tsx +0 -65
- package/src/contexts/com/components/NotificationAttributesTable.tsx +0 -54
- package/src/contexts/com/components/NotificationRenderer.tsx +0 -42
- package/src/contexts/com/components/NotificationsWidget.tsx +0 -182
- package/src/contexts/com/components/notificationFormats.tsx +0 -50
- package/src/contexts/com/useLaravelEcho.tsx +0 -432
- package/src/contexts/dictionary/DictionaryContext.tsx +0 -94
- package/src/declarations.d.ts +0 -17
- package/src/default-theme/DASHAppProviders.tsx +0 -117
- package/src/default-theme/DashThemeContext.tsx +0 -209
- package/src/default-theme/DashThemeContext.tsx.fast +0 -143
- package/src/default-theme/DashThemeContext.tsx.old +0 -306
- package/src/default-theme/DashThemeHelperProvider.tsx +0 -98
- package/src/default-theme/DomainAppLayout.tsx +0 -166
- package/src/default-theme/DomainHeader.tsx +0 -162
- package/src/default-theme/DomainTheme.tsx +0 -59
- package/src/default-theme/FullLayoutMarkup.tsx +0 -231
- package/src/default-theme/StaticLayout.tsx +0 -47
- package/src/default-theme/index.tsx +0 -11
- package/src/default-theme/menu/AppDashboardGrid.tsx +0 -279
- package/src/default-theme/menu/AppMaterialMenu.tsx +0 -546
- package/src/default-theme/menu/AppMenuComponents/SubmenuPortal.tsx +0 -61
- package/src/default-theme/menu/AppMenuComponents/collapsed/CollapsedSidebarItem.tsx +0 -264
- package/src/default-theme/menu/AppMenuComponents/collapsed/CollapsedSidebarItems.tsx +0 -31
- package/src/default-theme/menu/AppMenuComponents/expanded/CollapsableSidebarMenu.tsx +0 -293
- package/src/default-theme/menu/AppMenuComponents/expanded/SidebarItem.tsx +0 -92
- package/src/default-theme/menu/AppMenuComponents/getItem.tsx +0 -17
- package/src/default-theme/menu/AppMenuComponents/interfaces.tsx +0 -41
- package/src/default-theme/menu/AppMenuComponents/submenuConstants.ts +0 -90
- package/src/default-theme/menu/AppSidebarMaterial.tsx +0 -339
- package/src/default-theme/menu/SidebarActions.tsx +0 -84
- package/src/default-theme/updateDomCssVariables.tsx +0 -176
- package/src/helpers/checkRole.tsx +0 -66
- package/src/helpers/parseAxiosError.tsx +0 -41
- package/src/hooks/audio/useAudio.tsx +0 -39
- package/src/hooks/axios.tsx +0 -165
- package/src/hooks/data/useDashboardStats.tsx +0 -65
- package/src/hooks/data/usePackageByClientsStats.tsx +0 -44
- package/src/hooks/data/usePackageByCommunesStats.tsx +0 -44
- package/src/hooks/data/usePackageStats.tsx +0 -69
- package/src/hooks/data/usePackageWithdrawDetails.tsx +0 -61
- package/src/hooks/data/useStats.tsx +0 -86
- package/src/hooks/isCurrentPath.tsx +0 -22
- package/src/hooks/notifications/WSMessagesManager.tsx +0 -152
- package/src/hooks/notifications/WSPusherManager.tsx +0 -92
- package/src/hooks/useBreadcrumbs.tsx +0 -329
- package/src/hooks/useClickOutside.tsx +0 -57
- package/src/hooks/useFormPersistance.tsx +0 -150
- package/src/hooks/useGlobalErrorMediator.tsx +0 -43
- package/src/hooks/useGlobalLoaderMgr.tsx +0 -21
- package/src/hooks/useHash.tsx +0 -27
- package/src/hooks/useLocalStorage.tsx +0 -196
- package/src/hooks/usePolyglotTranslation.tsx +0 -62
- package/src/hooks/usePrevious.tsx +0 -9
- package/src/hooks/usePrintSelected.tsx +0 -37
- package/src/hooks/useVirtualHash.tsx +0 -33
- package/src/hooks/window/useWindowSize.tsx +0 -36
- package/src/index.tsx +0 -134
- package/src/interfaces/IAppResourceConfig.tsx +0 -20
- package/src/interfaces/Log.tsx +0 -16
- package/src/interfaces/Tenant.tsx +0 -25
- package/src/interfaces/communication/IActions.tsx +0 -5
- package/src/interfaces/communication/INotification.tsx +0 -21
- package/src/interfaces/communication/IPayload.tsx +0 -3
- package/src/interfaces/communication/IRequestAction.tsx +0 -10
- package/src/interfaces/communication/IRequestPayload.tsx +0 -7
- package/src/interfaces/communication/IResponseAction.tsx +0 -7
- package/src/interfaces/misc/IAny.tsx +0 -3
- package/src/interfaces/misc/IFlashMessage.tsx +0 -10
- package/src/interfaces/navigation/IAppMenu.ts +0 -14
- package/src/interfaces/navigation/ICollapsableSidebarMenu.ts +0 -12
- package/src/interfaces/navigation/IMenuItem.ts +0 -16
- package/src/interfaces/notifications/IModel.tsx +0 -6
- package/src/interfaces/notifications/IModelField.tsx +0 -8
- package/src/interfaces/notifications/IUserNotification.tsx +0 -12
- package/src/interfaces/notifications/IUserNotificationData.tsx +0 -13
- package/src/interfaces/notifications/IUserNotificationPayload.tsx +0 -8
- package/src/interfaces/user/IGetAuth.tsx +0 -92
- package/src/interfaces/user/ITenantSettings.tsx +0 -3
- package/src/interfaces/user/IUser.tsx +0 -60
- package/src/interfaces/user/IUserSettings.tsx +0 -43
- package/src/interfaces.tsx +0 -6
- package/src/layout/AppLayout.tsx +0 -112
- package/src/layout/ApplicationLayout.tsx +0 -197
- package/src/layout/MotionWrapper.original.tsx +0 -236
- package/src/layout/MotionWrapper.tsx +0 -236
- package/src/layout/ResourceMenu.tsx +0 -164
- package/src/layout/ResoureLayout.tsx +0 -105
- package/src/layout/TransitionWrapper.tsx +0 -125
- package/src/pages/ChangePassword.tsx +0 -179
- package/src/pages/DASHLanding.tsx +0 -22
- package/src/pages/DASHLightWeightLogin.tsx +0 -611
- package/src/pages/DASHSimpleLogin.tsx +0 -260
- package/src/pages/Login.tsx +0 -111
- package/src/pages/Profile.tsx +0 -357
- package/src/pages/RecoverPassword.tsx +0 -175
- package/src/pages/SingleImageUploader.tsx +0 -55
- package/src/pages/VerifyAccount.tsx +0 -128
- package/src/providers/authProvider.tsx +0 -217
- package/src/providers/dataProvider.tsx +0 -672
- package/src/providers/i18n/en.ts +0 -646
- package/src/providers/i18n/es.ts +0 -652
- package/src/providers/i18n/languages.tsx +0 -8
- package/src/providers/i18n/mergeTranslations.ts +0 -53
- package/src/providers/i18nProvider.tsx +0 -23
- package/src/react-admin-dash/RADashComponent.tsx +0 -240
- package/src/react-admin-dash/Resource.tsx +0 -77
- package/src/resources/Brand/BrandResource.tsx +0 -130
- package/src/resources/DASHResourceLoader.ts +0 -180
- package/src/resources/Log/LogResource.tsx +0 -73
- package/src/resources/Tenant/ImpersonateTenantResource.tsx +0 -113
- package/src/resources/Trash/TrashTemplate.tsx +0 -180
- package/src/resources/User/components/AvatarUploadField.tsx +0 -57
- package/src/resources/User/components/PasswordFields.tsx +0 -73
- package/src/resources/User/getProfileMenu.ts +0 -57
- package/src/resources/User/profileResource.tsx +0 -51
- package/src/resources/User/userLayout.tsx +0 -62
- package/src/resources/User/userResource.tsx +0 -111
- package/src/resources/User/userSchema.tsx +0 -213
- package/src/resources/User/usersFilters.tsx +0 -21
- package/src/resources.tsx +0 -280
- package/src/schemas/log.tsx +0 -45
- package/src/schemas/notification.tsx +0 -42
- package/src/schemas/permissions.tsx +0 -44
- package/src/schemas/roles.tsx +0 -48
- package/src/schemas/rolesDataGrid.tsx +0 -48
- package/src/schemas/subscription/components/SubscriptionActions.tsx +0 -153
- package/src/schemas/subscription/components/SubscriptionPaymentHistory.tsx +0 -127
- package/src/schemas/subscription/components/SubscriptionPlanFeatures.tsx +0 -162
- package/src/schemas/subscription/components/SubscriptionPlanPreview.tsx +0 -141
- package/src/schemas/subscription/components/SubscriptionPlanStats.tsx +0 -318
- package/src/schemas/subscription/components/SubscriptionStatusIndicator.tsx +0 -72
- package/src/schemas/subscription/subscriptionPlanSchema.tsx +0 -185
- package/src/schemas/subscription/subscriptionSchema.tsx +0 -152
- package/src/schemas/subscriptionPlan.ts +0 -422
- package/src/schemas/tenant.tsx +0 -129
- package/src/schemas/tenantUser.tsx +0 -96
- package/src/schemas/tenant_superadmin.tsx +0 -119
- package/src/schemas/user.tsx +0 -26
- package/src/systemResources.old.tsx +0 -928
- package/src/systemResources.tsx +0 -1369
- package/src/templates/ResourceTemplate.tsx +0 -240
- package/src/templates/ResourceTemplate.tsx.memoized_experiment +0 -350
- package/src/templates/ResourceTemplate.tsx.original +0 -396
- package/src/templates/ResourceTemplateCreate.tsx +0 -182
- package/src/templates/ResourceTemplateEdit.tsx +0 -176
- package/src/templates/ResourceTemplateFull.tsx +0 -581
- package/src/templates/ResourceTemplateList.tsx +0 -340
- package/src/templates/ResourceTemplateOld.tsx.bkup +0 -567
- package/src/templates/ResourceTemplateShow.tsx +0 -88
- package/src/templates/TrashTemplate.tsx +0 -179
- package/src/tenantResources.tsx +0 -223
- package/src/test_portal_bubbles.tsx +0 -40
- package/src/theme/AppHeader.tsx +0 -52
- package/src/theme/AppLayoutSetting.tsx +0 -33
- package/src/theme/AppLogo.tsx +0 -13
- package/src/theme/AppSidebar.tsx +0 -12
- package/src/theme/AppSidebarContent.tsx +0 -105
- package/src/theme/AppSidebarLogo.tsx +0 -48
- package/src/theme/components/PageTitle.tsx +0 -37
- package/src/utils/cache/CacheInvalidatorContext.tsx +0 -125
- package/src/utils/cache/CacheInvalidatorListenerComponent.tsx +0 -10
- package/src/utils/cache/useCacheInvalidatorListener.tsx +0 -27
- package/src/utils/convertFileToBase64.tsx +0 -9
- package/src/utils/convertToFile.tsx +0 -14
- package/src/utils/cookies.tsx +0 -33
- package/src/utils/dashDefaultQueryClient.tsx +0 -34
- package/src/utils/dataUrlToBlob.tsx +0 -30
- package/src/utils/deepReplace.tsx +0 -19
- package/src/utils/getProfileMenu.tsx +0 -41
- package/src/utils/getTenantSettings.tsx +0 -9
- package/src/utils/getType.tsx +0 -8
- package/src/utils/getUserSettings.tsx +0 -8
- package/src/utils/hasCode.tsx +0 -14
- package/src/utils/index.ts +0 -19
- package/src/utils/injectTenantStyles.ts +0 -28
- package/src/utils/isComponent.tsx +0 -45
- package/src/utils/navEvents.tsx +0 -91
- package/src/utils/prototypes.tsx +0 -5
- package/src/utils/regexp.tsx +0 -4
- package/src/utils/resolveObjectPath.tsx +0 -4
- package/src/utils/setNativeValue.tsx +0 -24
- package/src/utils/slugify.tsx +0 -11
- package/src/utils/validators/emailValidator.tsx +0 -6
- package/src/utils/validators/requiredValidator.tsx +0 -5
- package/src/utils/validators/rutValidator.tsx +0 -31
- package/src/utils/validators.tsx +0 -96
package/src/pages/Profile.tsx
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import { FC, useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Button, Card, CardContent, CardHeader, Grid, Typography } from '@mui/material';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
Form,
|
|
7
|
-
useRefresh,
|
|
8
|
-
Loading,
|
|
9
|
-
useNotify,
|
|
10
|
-
useTranslate,
|
|
11
|
-
TextInput,
|
|
12
|
-
} from 'react-admin';
|
|
13
|
-
|
|
14
|
-
import { useDispatch } from 'react-redux';
|
|
15
|
-
import { DASH_REDUX_ACTIONS } from 'dash-admin-state';
|
|
16
|
-
|
|
17
|
-
import React from 'react';
|
|
18
|
-
import { useAxios } from 'dash-axios-hook';
|
|
19
|
-
import { SingleImageUploader } from 'dash-components';
|
|
20
|
-
import { useAuthContext } from '../contexts/auth';
|
|
21
|
-
import UserPreferences from '../components/user/UserPreferences';
|
|
22
|
-
|
|
23
|
-
const Profile: FC = (_props) => {
|
|
24
|
-
const [currTab, setCurrTab] = useState('auth/update/info');
|
|
25
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
26
|
-
|
|
27
|
-
const { user, fetchAuth } = useAuthContext();
|
|
28
|
-
const [avatar, setAvatar] = useState({ rawFile: null, urlFile: '' });
|
|
29
|
-
const notify = useNotify();
|
|
30
|
-
const translate = useTranslate();
|
|
31
|
-
|
|
32
|
-
const axios = useAxios();
|
|
33
|
-
const refresh = useRefresh();
|
|
34
|
-
|
|
35
|
-
const { showPreferences = false } = _props;
|
|
36
|
-
|
|
37
|
-
const dispatch = useDispatch();
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
dispatch(
|
|
41
|
-
DASH_REDUX_ACTIONS.updatePage({
|
|
42
|
-
title: translate('profile.title', { _: 'Perfil' }),
|
|
43
|
-
//icon:
|
|
44
|
-
subTitle: translate('profile.subtitle', { _: 'Configuración de perfil' }),
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
// translate is included so the page header re-translates on locale change
|
|
48
|
-
// (react-admin returns a new translate reference when the locale changes)
|
|
49
|
-
}, [translate]);
|
|
50
|
-
|
|
51
|
-
const validateUserCreation = (values) => {
|
|
52
|
-
const errors: any = {};
|
|
53
|
-
if (currTab === 'auth/update/password') {
|
|
54
|
-
const required = translate('profile.validation.required', { _: 'El campo es requerido' });
|
|
55
|
-
const mismatch = translate('profile.validation.password_mismatch', { _: 'Las contraseñas no coinciden' });
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
(values.password || values.password_confirmation) &&
|
|
59
|
-
!values.current_password
|
|
60
|
-
) {
|
|
61
|
-
errors.current_password = required;
|
|
62
|
-
}
|
|
63
|
-
if (
|
|
64
|
-
values.current_password &&
|
|
65
|
-
(!values.password || !values.password_confirmation)
|
|
66
|
-
) {
|
|
67
|
-
errors.password = required;
|
|
68
|
-
errors.password_confirmation = required;
|
|
69
|
-
}
|
|
70
|
-
if (values.password_confirmation !== values.password) {
|
|
71
|
-
errors.password = mismatch;
|
|
72
|
-
errors.password_confirmation = mismatch;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return errors;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const handleSubmit = async (values) => {
|
|
80
|
-
setIsLoading(true);
|
|
81
|
-
|
|
82
|
-
const formData = new FormData();
|
|
83
|
-
|
|
84
|
-
const passwords = {
|
|
85
|
-
current_password: values.current_password,
|
|
86
|
-
password: values.password,
|
|
87
|
-
password_confirmation: values.password_confirmation,
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// Append all user info fields to formData
|
|
91
|
-
if (values.name) { formData.append('name', values.name); }
|
|
92
|
-
if (values.lastname) { formData.append('lastname', values.lastname); }
|
|
93
|
-
if (values.email) { formData.append('email', values.email); }
|
|
94
|
-
if (avatar.rawFile) { formData.append('avatar', avatar.rawFile); }
|
|
95
|
-
formData.append('_method', 'put');
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
if (currTab === 'auth/update/info') {
|
|
99
|
-
await axios.post(currTab, formData, {
|
|
100
|
-
headers: { 'Content-Type': 'multipart/form-data' },
|
|
101
|
-
});
|
|
102
|
-
} else {
|
|
103
|
-
await axios.put(currTab, passwords);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Refresh the auth context with updated user data
|
|
107
|
-
try {
|
|
108
|
-
await fetchAuth();
|
|
109
|
-
console.log('Auth context refreshed after profile update');
|
|
110
|
-
} catch (authError) {
|
|
111
|
-
console.error('Failed to refresh auth context:', authError);
|
|
112
|
-
// Don't show error to user as the main operation succeeded
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
notify(translate('profile.notify.success', { _: 'Usuario actualizado correctamente' }), { type: 'success' });
|
|
116
|
-
refresh();
|
|
117
|
-
} catch (error: any) {
|
|
118
|
-
|
|
119
|
-
// Handle backend error messages gracefully
|
|
120
|
-
let mainMessage = error?.response?.data?.message || error?.body?.message || '';
|
|
121
|
-
let fieldErrors = error?.response?.data?.errors || error?.body?.errors || error;
|
|
122
|
-
if (mainMessage) {
|
|
123
|
-
notify(translate('profile.notify.error_with_message', { message: mainMessage, _: `Error al actualizar el usuario, ${mainMessage}` }), { type: 'error' });
|
|
124
|
-
} else {
|
|
125
|
-
notify(translate('profile.notify.error', { _: 'Error al actualizar el usuario' }), { type: 'error' });
|
|
126
|
-
}
|
|
127
|
-
if (fieldErrors && typeof fieldErrors === 'object') {
|
|
128
|
-
const errors: any = {};
|
|
129
|
-
Object.keys(fieldErrors).forEach((key) => {
|
|
130
|
-
errors[key] = Array.isArray(fieldErrors[key])
|
|
131
|
-
? fieldErrors[key].join(' , ')
|
|
132
|
-
: fieldErrors[key];
|
|
133
|
-
});
|
|
134
|
-
return errors;
|
|
135
|
-
}
|
|
136
|
-
} finally {
|
|
137
|
-
setIsLoading(false);
|
|
138
|
-
// TechDebt: the avatar update doesn't reflect immediately after the update, this is a quick fix to reload the page and show the new avatar, ideally we should update the auth context with the new avatar url and avoid reloading the page
|
|
139
|
-
window.location.reload();
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const handleInfoSubmit = () => {
|
|
144
|
-
setCurrTab('auth/update/info');
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const handlePasswordSubmit = () => {
|
|
148
|
-
setCurrTab('auth/update/password');
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<div className='dash-profile'>
|
|
153
|
-
|
|
154
|
-
{user ? (
|
|
155
|
-
<Form
|
|
156
|
-
onSubmit={handleSubmit}
|
|
157
|
-
validate={validateUserCreation}
|
|
158
|
-
defaultValues={{ name: user?.name, email: user?.email, lastname: user?.lastname }}
|
|
159
|
-
className='dash-form'
|
|
160
|
-
>
|
|
161
|
-
|
|
162
|
-
<div className='dash-card-content dash-module dash-card-profile'>
|
|
163
|
-
|
|
164
|
-
<Grid
|
|
165
|
-
container
|
|
166
|
-
spacing={{ xs: 2, md: 3 }}
|
|
167
|
-
sx={{ minHeight: '400px' }}
|
|
168
|
-
>
|
|
169
|
-
{/* Profile Image Section */}
|
|
170
|
-
<Grid
|
|
171
|
-
size={{ xs: 12, md: 4 }}
|
|
172
|
-
sx={{
|
|
173
|
-
display: "flex",
|
|
174
|
-
justifyContent: "center",
|
|
175
|
-
alignItems: "center"
|
|
176
|
-
}}>
|
|
177
|
-
<CardContent
|
|
178
|
-
sx={{
|
|
179
|
-
height: '100%',
|
|
180
|
-
display: 'flex',
|
|
181
|
-
flexDirection: 'column',
|
|
182
|
-
justifyContent: 'center',
|
|
183
|
-
alignItems: 'center',
|
|
184
|
-
width: '100%',
|
|
185
|
-
}}
|
|
186
|
-
>
|
|
187
|
-
<SingleImageUploader
|
|
188
|
-
currentUrl={user?.image_path}
|
|
189
|
-
onChange={(file: File) => {
|
|
190
|
-
setAvatar({
|
|
191
|
-
rawFile: file,
|
|
192
|
-
urlFile: URL.createObjectURL(file),
|
|
193
|
-
});
|
|
194
|
-
}}
|
|
195
|
-
classNamePrefix='dash-profile'
|
|
196
|
-
/>
|
|
197
|
-
<Typography
|
|
198
|
-
className='dash-profile-name'
|
|
199
|
-
variant='h2'
|
|
200
|
-
sx={{ mt: 2, textAlign: 'center' }}
|
|
201
|
-
>
|
|
202
|
-
{`${user?.name || ''}`}
|
|
203
|
-
</Typography>
|
|
204
|
-
<Typography
|
|
205
|
-
variant="body2"
|
|
206
|
-
sx={{
|
|
207
|
-
display: 'block',
|
|
208
|
-
textAlign: 'center',
|
|
209
|
-
fontSize: '14px',
|
|
210
|
-
opacity: 0.54,
|
|
211
|
-
mt: 1,
|
|
212
|
-
}}
|
|
213
|
-
>
|
|
214
|
-
{/* Cargo, telefono, etc. */}
|
|
215
|
-
</Typography>
|
|
216
|
-
</CardContent>
|
|
217
|
-
</Grid>
|
|
218
|
-
|
|
219
|
-
{/* User Info Section */}
|
|
220
|
-
<Grid size={{ xs: 12, md: 4 }}>
|
|
221
|
-
<CardHeader
|
|
222
|
-
sx={{ padding: '16px 25px 0' }}
|
|
223
|
-
title={translate('profile.info.title', { _: 'Info' })}
|
|
224
|
-
/>
|
|
225
|
-
<CardContent sx={{ padding: '25px' }}>
|
|
226
|
-
<Grid container spacing={2}>
|
|
227
|
-
<Grid size={12}>
|
|
228
|
-
<TextInput
|
|
229
|
-
source='name'
|
|
230
|
-
label={translate('profile.info.name', { _: 'Nombre' })}
|
|
231
|
-
variant='outlined'
|
|
232
|
-
fullWidth
|
|
233
|
-
/>
|
|
234
|
-
</Grid>
|
|
235
|
-
<Grid size={12}>
|
|
236
|
-
<TextInput
|
|
237
|
-
source='lastname'
|
|
238
|
-
label={translate('profile.info.lastname', { _: 'Apellido' })}
|
|
239
|
-
variant='outlined'
|
|
240
|
-
fullWidth
|
|
241
|
-
/>
|
|
242
|
-
</Grid>
|
|
243
|
-
<Grid size={12}>
|
|
244
|
-
<TextInput
|
|
245
|
-
source='email'
|
|
246
|
-
label={translate('profile.info.email', { _: 'Email' })}
|
|
247
|
-
variant='outlined'
|
|
248
|
-
fullWidth
|
|
249
|
-
/>
|
|
250
|
-
</Grid>
|
|
251
|
-
<Grid size={12} sx={{ mt: 2 }}>
|
|
252
|
-
<Button
|
|
253
|
-
onClick={handleInfoSubmit}
|
|
254
|
-
disabled={isLoading}
|
|
255
|
-
variant='contained'
|
|
256
|
-
type='submit'
|
|
257
|
-
fullWidth
|
|
258
|
-
sx={{
|
|
259
|
-
position: 'relative',
|
|
260
|
-
'&.Mui-disabled': {
|
|
261
|
-
backgroundColor: 'primary.main',
|
|
262
|
-
opacity: 0.7,
|
|
263
|
-
color: 'white'
|
|
264
|
-
}
|
|
265
|
-
}}
|
|
266
|
-
>
|
|
267
|
-
{isLoading && currTab === 'auth/update/info'
|
|
268
|
-
? translate('profile.info.saving', { _: 'Guardando...' })
|
|
269
|
-
: translate('profile.info.save', { _: 'Guardar' })}
|
|
270
|
-
</Button>
|
|
271
|
-
</Grid>
|
|
272
|
-
</Grid>
|
|
273
|
-
</CardContent>
|
|
274
|
-
</Grid>
|
|
275
|
-
|
|
276
|
-
{/* Password Section */}
|
|
277
|
-
<Grid size={{ xs: 12, md: 4 }}>
|
|
278
|
-
<CardHeader
|
|
279
|
-
sx={{ padding: '16px 25px 0' }}
|
|
280
|
-
title={translate('profile.password.title', { _: 'Contraseñas' })}
|
|
281
|
-
/>
|
|
282
|
-
<CardContent sx={{ padding: '25px' }}>
|
|
283
|
-
<Grid container spacing={2}>
|
|
284
|
-
<Grid size={12}>
|
|
285
|
-
<TextInput
|
|
286
|
-
type='password'
|
|
287
|
-
source='current_password'
|
|
288
|
-
label={translate('profile.password.current', { _: 'Contraseña actual' })}
|
|
289
|
-
variant='outlined'
|
|
290
|
-
fullWidth
|
|
291
|
-
/>
|
|
292
|
-
</Grid>
|
|
293
|
-
<Grid size={12}>
|
|
294
|
-
<TextInput
|
|
295
|
-
type='password'
|
|
296
|
-
source='password'
|
|
297
|
-
label={translate('profile.password.new', { _: 'Nueva contraseña' })}
|
|
298
|
-
variant='outlined'
|
|
299
|
-
fullWidth
|
|
300
|
-
/>
|
|
301
|
-
</Grid>
|
|
302
|
-
<Grid size={12}>
|
|
303
|
-
<TextInput
|
|
304
|
-
label={translate('profile.password.confirm', { _: 'Repita nueva contraseña' })}
|
|
305
|
-
type='password'
|
|
306
|
-
source='password_confirmation'
|
|
307
|
-
variant='outlined'
|
|
308
|
-
fullWidth
|
|
309
|
-
/>
|
|
310
|
-
</Grid>
|
|
311
|
-
<Grid size={12} sx={{ mt: 2 }}>
|
|
312
|
-
<Button
|
|
313
|
-
onClick={handlePasswordSubmit}
|
|
314
|
-
disabled={isLoading}
|
|
315
|
-
variant='contained'
|
|
316
|
-
type='submit'
|
|
317
|
-
fullWidth
|
|
318
|
-
sx={{
|
|
319
|
-
position: 'relative',
|
|
320
|
-
'&.Mui-disabled': {
|
|
321
|
-
backgroundColor: 'primary.main',
|
|
322
|
-
opacity: 0.7,
|
|
323
|
-
color: 'white'
|
|
324
|
-
}
|
|
325
|
-
}}
|
|
326
|
-
>
|
|
327
|
-
{isLoading && currTab === 'auth/update/password'
|
|
328
|
-
? translate('profile.password.saving', { _: 'Guardando Contraseñas...' })
|
|
329
|
-
: translate('profile.password.save', { _: 'Guardar Contraseñas' })}
|
|
330
|
-
</Button>
|
|
331
|
-
</Grid>
|
|
332
|
-
</Grid>
|
|
333
|
-
</CardContent>
|
|
334
|
-
</Grid>
|
|
335
|
-
|
|
336
|
-
{/* User Preferences Section */}
|
|
337
|
-
{showPreferences && (
|
|
338
|
-
<Grid size={{ xs: 12 }}>
|
|
339
|
-
<CardContent sx={{ padding: '25px' }}>
|
|
340
|
-
<UserPreferences />
|
|
341
|
-
</CardContent>
|
|
342
|
-
</Grid>
|
|
343
|
-
)}
|
|
344
|
-
|
|
345
|
-
</Grid>
|
|
346
|
-
</div>
|
|
347
|
-
|
|
348
|
-
</Form>
|
|
349
|
-
|
|
350
|
-
) : (
|
|
351
|
-
<Loading />
|
|
352
|
-
)}
|
|
353
|
-
</div>
|
|
354
|
-
);
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
export default Profile;
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { Button, Input, InputLabel, TextField, Alert, IconButton, Grid, Dialog, DialogContent, DialogActions, Box } from '@mui/material';
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import { Layout } from 'react-admin';
|
|
4
|
-
import { useNotify, useRedirect } from 'react-admin';
|
|
5
|
-
import useAxios from '../hooks/axios';
|
|
6
|
-
import { FullLayoutMarkup } from '../default-theme';
|
|
7
|
-
import getType from '../utils/getType';
|
|
8
|
-
import MUISimpleJsonTable from '../components/misc/MuiSimpleJsonTable';
|
|
9
|
-
import HomeIcon from '@mui/icons-material/Home';
|
|
10
|
-
import { getCookie, removeCookie, setCookie,clearAllCookies } from '../../src/utils/cookies';
|
|
11
|
-
import { dashStorage } from 'dash-utils';
|
|
12
|
-
|
|
13
|
-
const RecoverPassword = ({ }: { }) => {
|
|
14
|
-
const [email, setEmail] = useState('');
|
|
15
|
-
const [loading, setLoading] = useState(false);
|
|
16
|
-
const [error, setError] = useState('');
|
|
17
|
-
const [success, setSuccess] = useState(false);
|
|
18
|
-
const { axios } = useAxios();
|
|
19
|
-
const redirect = useRedirect();
|
|
20
|
-
const notify = useNotify();
|
|
21
|
-
|
|
22
|
-
const handleSubmit = async (e) => {
|
|
23
|
-
e.preventDefault();
|
|
24
|
-
setError('');
|
|
25
|
-
setLoading(true);
|
|
26
|
-
try {
|
|
27
|
-
const { data } = await axios.post(`password/email`, {
|
|
28
|
-
email,
|
|
29
|
-
});
|
|
30
|
-
setSuccess(true);
|
|
31
|
-
notify(data.message, { type: 'success' });
|
|
32
|
-
} catch (error: any) {
|
|
33
|
-
let errorMsg = 'Ha ocurrido un error';
|
|
34
|
-
if (error?.response?.data) {
|
|
35
|
-
const resp = error.response.data;
|
|
36
|
-
// Prefer error from errors.email, then message, then fallback
|
|
37
|
-
if (resp.errors && resp.errors.email && resp.errors.email.length > 0) {
|
|
38
|
-
errorMsg = resp.errors.email[0];
|
|
39
|
-
} else if (resp.message) {
|
|
40
|
-
errorMsg = resp.message;
|
|
41
|
-
}
|
|
42
|
-
} else if (error?.message) {
|
|
43
|
-
errorMsg = error.message;
|
|
44
|
-
}
|
|
45
|
-
setError(errorMsg);
|
|
46
|
-
notify(errorMsg, { type: 'warning' });
|
|
47
|
-
} finally {
|
|
48
|
-
setLoading(false);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
dashStorage.clear();
|
|
54
|
-
clearAllCookies();
|
|
55
|
-
}, [])
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<FullLayoutMarkup>
|
|
59
|
-
<Box
|
|
60
|
-
sx={{
|
|
61
|
-
//height: '100vh',
|
|
62
|
-
display: 'flex',
|
|
63
|
-
alignItems: 'flex-start', // align to top
|
|
64
|
-
justifyContent: 'center',
|
|
65
|
-
pt: 8, // thick top margin
|
|
66
|
-
}}
|
|
67
|
-
>
|
|
68
|
-
<Box
|
|
69
|
-
sx={{
|
|
70
|
-
width: '100%',
|
|
71
|
-
maxWidth: 420,
|
|
72
|
-
mx: 'auto',
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
75
|
-
{success ? (
|
|
76
|
-
<Box
|
|
77
|
-
sx={{
|
|
78
|
-
display: 'flex',
|
|
79
|
-
flexDirection: 'column',
|
|
80
|
-
alignItems: 'center',
|
|
81
|
-
justifyContent: 'center',
|
|
82
|
-
boxShadow: 3,
|
|
83
|
-
borderRadius: 2,
|
|
84
|
-
p: 4,
|
|
85
|
-
minWidth: 320,
|
|
86
|
-
minHeight: 200,
|
|
87
|
-
bgcolor: 'background.paper',
|
|
88
|
-
mt: 8, // thick top margin
|
|
89
|
-
mx: 'auto',
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
<h1 className="dash-app-login-form-title" style={{ margin: 0 }}>Recuperar Contraseña</h1>
|
|
93
|
-
<Alert severity="success" sx={{ mt: 2, mb: 2 }}>
|
|
94
|
-
Si el correo existe en nuestro sistema, recibirás un enlace para restablecer tu contraseña.
|
|
95
|
-
</Alert>
|
|
96
|
-
<Button
|
|
97
|
-
variant="contained"
|
|
98
|
-
color="primary"
|
|
99
|
-
onClick={() => redirect('/login')}
|
|
100
|
-
sx={{ mt: 2 }}
|
|
101
|
-
>
|
|
102
|
-
Ir al Login
|
|
103
|
-
</Button>
|
|
104
|
-
</Box>
|
|
105
|
-
) : (
|
|
106
|
-
<form onSubmit={handleSubmit} className='dash-app-login-form'>
|
|
107
|
-
<Grid
|
|
108
|
-
container
|
|
109
|
-
spacing={2}
|
|
110
|
-
sx={{
|
|
111
|
-
alignItems: "center",
|
|
112
|
-
mb:4,
|
|
113
|
-
mt:2
|
|
114
|
-
}}>
|
|
115
|
-
{/* @ts-ignore */}
|
|
116
|
-
<Grid item xs={2}>
|
|
117
|
-
<IconButton
|
|
118
|
-
color={'primary'}
|
|
119
|
-
size={'large'}
|
|
120
|
-
onClick={() => redirect('/')}
|
|
121
|
-
>
|
|
122
|
-
<HomeIcon />
|
|
123
|
-
</IconButton>
|
|
124
|
-
</Grid>
|
|
125
|
-
{/* @ts-ignore */}
|
|
126
|
-
<Grid item xs={10}>
|
|
127
|
-
<h1 className="dash-app-login-form-title" style={{ margin: 0 }}>Recuperar Contraseña</h1>
|
|
128
|
-
</Grid>
|
|
129
|
-
</Grid>
|
|
130
|
-
|
|
131
|
-
{error && (
|
|
132
|
-
<Alert severity="error" sx={{ mb: 2 }}>
|
|
133
|
-
{error}
|
|
134
|
-
</Alert>
|
|
135
|
-
)}
|
|
136
|
-
|
|
137
|
-
<div className='dash-app-form-item'>
|
|
138
|
-
<TextField
|
|
139
|
-
fullWidth
|
|
140
|
-
variant='outlined'
|
|
141
|
-
label='Email'
|
|
142
|
-
placeholder='Email'
|
|
143
|
-
required
|
|
144
|
-
value={email}
|
|
145
|
-
onChange={(e) => setEmail(e.target.value)}
|
|
146
|
-
className='dash-app-form-item-input'
|
|
147
|
-
autoComplete="username"
|
|
148
|
-
name="email"
|
|
149
|
-
type="email"
|
|
150
|
-
id="email"
|
|
151
|
-
slotProps={{
|
|
152
|
-
htmlInput: {type:'email'}
|
|
153
|
-
}}
|
|
154
|
-
/>
|
|
155
|
-
</div>
|
|
156
|
-
|
|
157
|
-
<div className='dash-app-form-item mt-1'>
|
|
158
|
-
<Button
|
|
159
|
-
type='submit'
|
|
160
|
-
variant='contained'
|
|
161
|
-
disabled={loading}
|
|
162
|
-
sx={{ mb: 2, width: '100%' }}
|
|
163
|
-
>
|
|
164
|
-
{loading ? 'Cargando...' : 'Resetear Contraseña'}
|
|
165
|
-
</Button>
|
|
166
|
-
</div>
|
|
167
|
-
</form>
|
|
168
|
-
)}
|
|
169
|
-
</Box>
|
|
170
|
-
</Box>
|
|
171
|
-
</FullLayoutMarkup>
|
|
172
|
-
);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
export default RecoverPassword;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { IconButton } from '@mui/material';
|
|
2
|
-
import { FC, useState } from 'react';
|
|
3
|
-
import { Upload } from '@mui/icons-material';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
export interface ISingleImageUploader {
|
|
6
|
-
classNamePrefix?: string;
|
|
7
|
-
currentUrl?: string;
|
|
8
|
-
onChange?: (file:File) => void
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const SingleImageUploader:FC<ISingleImageUploader> = (props) => {
|
|
12
|
-
|
|
13
|
-
const { classNamePrefix = 'default', currentUrl = 'single-image-uploader', onChange } = props;
|
|
14
|
-
|
|
15
|
-
const [localFile, setLocalFile] = useState(null);
|
|
16
|
-
|
|
17
|
-
return <div className={`single-image-uploader ${classNamePrefix}-img`}>
|
|
18
|
-
{localFile || currentUrl ? (
|
|
19
|
-
<img src={localFile || currentUrl} alt='' />
|
|
20
|
-
) : (
|
|
21
|
-
<div className={`${classNamePrefix}-icon`}>
|
|
22
|
-
{/*<Image />*/}
|
|
23
|
-
</div>
|
|
24
|
-
)}
|
|
25
|
-
<IconButton
|
|
26
|
-
aria-label='upload image'
|
|
27
|
-
component='label'
|
|
28
|
-
className={`${classNamePrefix}-edit`}
|
|
29
|
-
>
|
|
30
|
-
|
|
31
|
-
<Upload style={{ opacity: '0.6' }} />
|
|
32
|
-
|
|
33
|
-
<input
|
|
34
|
-
hidden
|
|
35
|
-
accept='image/*'
|
|
36
|
-
type='file'
|
|
37
|
-
onChange={e => {
|
|
38
|
-
|
|
39
|
-
setLocalFile(URL.createObjectURL(e.target.files[0]));
|
|
40
|
-
|
|
41
|
-
if (onChange) {
|
|
42
|
-
onChange(e.target.files[0]);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}}
|
|
46
|
-
/>
|
|
47
|
-
|
|
48
|
-
{/*<Edit
|
|
49
|
-
style={{ opacity: '0.6' }}
|
|
50
|
-
/>*/}
|
|
51
|
-
</IconButton>
|
|
52
|
-
</div>;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default SingleImageUploader;
|