@dashadmin/dash-admin 1.3.72 → 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
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
function getCssVarFromDom(key: string): string | undefined {
|
|
2
|
-
const value = getComputedStyle(document.documentElement).getPropertyValue(`--${key}`).trim();
|
|
3
|
-
return value || undefined;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
function getAllCSSVariableNames(styleSheets: StyleSheetList = document.styleSheets): string[] {
|
|
7
|
-
const cssVars = new Set<string>();
|
|
8
|
-
|
|
9
|
-
for (let i = 0; i < styleSheets.length; i++) {
|
|
10
|
-
const sheet = styleSheets[i];
|
|
11
|
-
let rules: CSSRuleList | undefined;
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
// Some stylesheets may be cross-origin and throw on access
|
|
15
|
-
rules = (sheet as CSSStyleSheet).cssRules;
|
|
16
|
-
} catch {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!rules) continue;
|
|
21
|
-
|
|
22
|
-
for (let j = 0; j < rules.length; j++) {
|
|
23
|
-
const rule = rules[j];
|
|
24
|
-
// Only process style rules (ignore @media, @font-face, etc.)
|
|
25
|
-
if ('style' in rule && rule.style) {
|
|
26
|
-
const style = rule.style as CSSStyleDeclaration;
|
|
27
|
-
for (let k = 0; k < style.length; k++) {
|
|
28
|
-
const name = style[k];
|
|
29
|
-
if (name.startsWith('--')) {
|
|
30
|
-
cssVars.add(name);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return Array.from(cssVars);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Read CSS variables from all stylesheets EXCEPT the dynamic theme style element.
|
|
42
|
-
* This gives us the "static" compiled LESS/CSS defaults, unaffected by our own dynamic overrides.
|
|
43
|
-
*/
|
|
44
|
-
function getStaticCssVariables(): Record<string, string> {
|
|
45
|
-
const result: Record<string, string> = {};
|
|
46
|
-
for (let i = 0; i < document.styleSheets.length; i++) {
|
|
47
|
-
const sheet = document.styleSheets[i];
|
|
48
|
-
const ownerNode = sheet.ownerNode as HTMLElement;
|
|
49
|
-
// Skip our dynamic theme style element to avoid reading back our own values
|
|
50
|
-
if (ownerNode?.id === 'dash-theme-variables') continue;
|
|
51
|
-
try {
|
|
52
|
-
const rules = (sheet as CSSStyleSheet).cssRules;
|
|
53
|
-
if (!rules) continue;
|
|
54
|
-
for (let j = 0; j < rules.length; j++) {
|
|
55
|
-
const rule = rules[j];
|
|
56
|
-
if ('selectorText' in rule && (rule as CSSStyleRule).selectorText === ':root') {
|
|
57
|
-
const style = (rule as CSSStyleRule).style;
|
|
58
|
-
for (let k = 0; k < style.length; k++) {
|
|
59
|
-
const name = style[k];
|
|
60
|
-
if (name.startsWith('--')) {
|
|
61
|
-
result[name] = style.getPropertyValue(name).trim();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
} catch {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export const updateDomCssVariables = (
|
|
74
|
-
theme: string,
|
|
75
|
-
colors?: { [x: string]: string },
|
|
76
|
-
values?: { [x: string]: string }
|
|
77
|
-
) => {
|
|
78
|
-
const debug = false;
|
|
79
|
-
const themeSuffix = `--${theme}`;
|
|
80
|
-
const logKeys = [
|
|
81
|
-
// "primary-color--light",
|
|
82
|
-
// "primary-color--dark",
|
|
83
|
-
"framed_layout-bg--light",
|
|
84
|
-
"framed_layout-bg--dark",
|
|
85
|
-
// "primary-color--light",
|
|
86
|
-
// "primary-contrast--light",
|
|
87
|
-
// "primary-contrast--dark",
|
|
88
|
-
// "secondary-color--light",
|
|
89
|
-
// "secondary-color--dark",
|
|
90
|
-
// "highlight-color--light",
|
|
91
|
-
// "highlight-color--dark",
|
|
92
|
-
//"framed_layout-bg--light",
|
|
93
|
-
//"framed_layout-bg--dark",
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
// Find or create the style element
|
|
97
|
-
let themeStyleElement = document.getElementById('dash-theme-variables') as HTMLStyleElement | null;
|
|
98
|
-
|
|
99
|
-
if (!themeStyleElement) {
|
|
100
|
-
themeStyleElement = document.createElement('style');
|
|
101
|
-
themeStyleElement.id = 'dash-theme-variables';
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// CRITICAL FIX: Always ensure the style element is at the END of <head>
|
|
105
|
-
// for highest CSS cascade priority. This ensures our dynamic tenant colors
|
|
106
|
-
// override the static compiled LESS/CSS defaults.
|
|
107
|
-
// appendChild on an already-attached element moves it to the new position.
|
|
108
|
-
document.head.appendChild(themeStyleElement);
|
|
109
|
-
|
|
110
|
-
let styleString = '';
|
|
111
|
-
|
|
112
|
-
values && Object.entries(values).forEach(([key, value]) => {
|
|
113
|
-
styleString += `--${key}: ${value}; `;
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// When no colors provided, read from static stylesheets (excluding our dynamic style)
|
|
117
|
-
// to get compiled LESS defaults instead of reading back our own previous values.
|
|
118
|
-
const staticVars = colors ? undefined : getStaticCssVariables();
|
|
119
|
-
|
|
120
|
-
// Collect all keys to set (from colors or fallback to static stylesheets)
|
|
121
|
-
const allKeys = new Set<string>();
|
|
122
|
-
if (colors) {
|
|
123
|
-
Object.keys(colors).forEach(k => allKeys.add(k));
|
|
124
|
-
} else {
|
|
125
|
-
// Use static CSS variables (from compiled LESS, NOT our dynamic style)
|
|
126
|
-
Object.keys(staticVars!).forEach(name => {
|
|
127
|
-
allKeys.add(name.slice(2)); // remove leading '--'
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
logKeys.forEach(k => allKeys.add(k));
|
|
131
|
-
|
|
132
|
-
allKeys.forEach(key => {
|
|
133
|
-
// Get value: prefer colors param, then static vars, then computed DOM
|
|
134
|
-
let value = colors?.[key];
|
|
135
|
-
if (!value && staticVars) {
|
|
136
|
-
value = staticVars[`--${key}`];
|
|
137
|
-
}
|
|
138
|
-
if (!value) value = getCssVarFromDom(key);
|
|
139
|
-
|
|
140
|
-
if (value) {
|
|
141
|
-
// Only add the variable if it doesn't end with a theme suffix OR matches the current theme
|
|
142
|
-
// This prevents variables for other themes from being included
|
|
143
|
-
const isThemeVariable = key.includes('--');
|
|
144
|
-
const isCurrentTheme = key.endsWith(themeSuffix);
|
|
145
|
-
|
|
146
|
-
// Add all non-theme variables and only the ones for current theme
|
|
147
|
-
if (!isThemeVariable || isCurrentTheme) {
|
|
148
|
-
styleString += `--${key}: ${value}; `;
|
|
149
|
-
if (logKeys.includes(key)) {
|
|
150
|
-
debug && console.log(`%c ⬤ --${key}: ${value}; `, `color: ${value};`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Only set baseKey for the current theme
|
|
156
|
-
if (key.endsWith(themeSuffix)) {
|
|
157
|
-
const baseKey = key.slice(0, -themeSuffix.length);
|
|
158
|
-
let baseValue = colors?.[key];
|
|
159
|
-
if (!baseValue && staticVars) {
|
|
160
|
-
baseValue = staticVars[`--${key}`];
|
|
161
|
-
}
|
|
162
|
-
if (!baseValue) baseValue = getCssVarFromDom(key);
|
|
163
|
-
if (baseValue) {
|
|
164
|
-
styleString += `--${baseKey}: ${baseValue}; `;
|
|
165
|
-
if (logKeys.includes(`${baseKey}${themeSuffix}`)) {
|
|
166
|
-
debug && console.log(`%c ⬤ [DEFAULT][${themeSuffix}] --${baseKey}: ${baseValue}; `, `color: ${baseValue};`);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
// Remove this log or set debug to false in production
|
|
172
|
-
debug && console.log("STYLES", styleString);
|
|
173
|
-
themeStyleElement.textContent = `:root { ${styleString} }`;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export default updateDomCssVariables;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { getCookie } from '../utils/cookies';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Checks if the current user has the specified roles or permissions.
|
|
5
|
-
*
|
|
6
|
-
* @param permissions - An array of permission names to check.
|
|
7
|
-
* @param roles - An array of role names to check.
|
|
8
|
-
* @returns True if the user has the specified roles or permissions, false otherwise.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Checks if the current user has the specified roles or permissions.
|
|
13
|
-
*
|
|
14
|
-
* @param permissions - An array of permission names to check.
|
|
15
|
-
* @param roles - An array of role names to check.
|
|
16
|
-
* @returns True if the user has the specified roles or permissions, false otherwise.
|
|
17
|
-
*/
|
|
18
|
-
const checkRole = (permissions, roles) => {
|
|
19
|
-
const debug = false;
|
|
20
|
-
|
|
21
|
-
if (debug) console.info('Check Roles', permissions, roles);
|
|
22
|
-
|
|
23
|
-
if ((Array.isArray(roles) && roles.map(r => r.toLowerCase()).includes('*'))) return true;
|
|
24
|
-
|
|
25
|
-
if (permissions.map(r => r.toLowerCase()).includes('system')) return true;
|
|
26
|
-
const cookie_tenant_id = getCookie('tenant_id');
|
|
27
|
-
if (roles.map(r => r.toLowerCase()).includes('has_admin_id') && !cookie_tenant_id) return false;
|
|
28
|
-
|
|
29
|
-
return roles.map(r => r.toLowerCase()).find((role) => permissions.map(r => r.toLowerCase()).includes(role));
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export default checkRole;
|
|
33
|
-
|
|
34
|
-
// OLD CODE TO REVIEW: NEW LOGIC ONLY CHECK BY ROLE, NOT SPECIFIC PERMISSIONS.
|
|
35
|
-
/*const checkRole = (permissions, roles) => {
|
|
36
|
-
const debug = true;
|
|
37
|
-
|
|
38
|
-
if (debug) console.info('Check Roles', permissions, roles);
|
|
39
|
-
|
|
40
|
-
if ((Array.isArray(roles) && roles.includes('*'))) return true;
|
|
41
|
-
|
|
42
|
-
const userRoles = dashStorage.getItem('roles');
|
|
43
|
-
const userPermissions = dashStorage.getItem('permissions');
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const processedPermissions = {
|
|
47
|
-
roles: Array.isArray(JSON.parse(userRoles)) ? JSON.parse(userRoles).map((item) => item.name) : [],
|
|
48
|
-
list: userPermissions ? JSON.parse(userPermissions) : {},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
if (debug) console.info('Checking if processedPermissions exists', processedPermissions);
|
|
52
|
-
if (!processedPermissions) return false;
|
|
53
|
-
|
|
54
|
-
if (!Object.prototype.hasOwnProperty.call(processedPermissions, 'roles')) return false;
|
|
55
|
-
|
|
56
|
-
if (!roles) return true;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const cookie_tenant_id = getCookie('tenant_id');
|
|
60
|
-
if (roles.includes('HAS_ADMIN_ID') && !cookie_tenant_id) return false;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (processedPermissions.roles.includes('SYSTEM_ADMIN')) return true;
|
|
64
|
-
|
|
65
|
-
return roles.find((role) => processedPermissions.roles.includes(role));
|
|
66
|
-
};*/
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export const parseAxiosError = (error: any): string => {
|
|
2
|
-
|
|
3
|
-
// Handle array of validation errors
|
|
4
|
-
if (error?.originalError?.response?.data?.errors && typeof error?.originalError?.response?.data?.errors === 'object') {
|
|
5
|
-
const originalErrors = error.originalError.response.data.errors;
|
|
6
|
-
const errorMessages = []
|
|
7
|
-
|
|
8
|
-
for (const key in originalErrors) {
|
|
9
|
-
if (Array.isArray(originalErrors[key])) {
|
|
10
|
-
errorMessages.push(...originalErrors[key])
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (errorMessages.length > 0) {
|
|
15
|
-
return errorMessages.join('\n')
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// First priority - response data message
|
|
20
|
-
if (error?.response?.data?.message) {
|
|
21
|
-
return error.response.data.message;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Second priority - error code + name + message
|
|
25
|
-
if (error?.code || error?.message) {
|
|
26
|
-
return [error.code, error.name || '', error.message]
|
|
27
|
-
.filter(Boolean)
|
|
28
|
-
.join(' - ');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// Third priority - status + statusText
|
|
33
|
-
if (error?.response?.status || error?.response?.statusText) {
|
|
34
|
-
return [error.response.status, error.response.statusText]
|
|
35
|
-
.filter(Boolean)
|
|
36
|
-
.join(' - ');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Fallback
|
|
40
|
-
return 'An unexpected error occurred';
|
|
41
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Eexample.
|
|
5
|
-
* const Player = ({ url }) => {
|
|
6
|
-
* const [playing, toggle] = useAudio(url);
|
|
7
|
-
* return (
|
|
8
|
-
* <div>
|
|
9
|
-
* <button onClick={toggle}>{playing ? "Pause" : "Play"}</button>
|
|
10
|
-
* </div>
|
|
11
|
-
* );
|
|
12
|
-
* };
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const useAudio = (url) => {
|
|
16
|
-
const [audio] = useState(new Audio(url));
|
|
17
|
-
const [playing, setPlaying] = useState(false);
|
|
18
|
-
|
|
19
|
-
const toggle = () => setPlaying(!playing);
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (playing) {
|
|
23
|
-
audio.play();
|
|
24
|
-
} else {
|
|
25
|
-
audio.pause();
|
|
26
|
-
}
|
|
27
|
-
}, [playing]);
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
audio.addEventListener('ended', () => setPlaying(false));
|
|
31
|
-
return () => {
|
|
32
|
-
audio.removeEventListener('ended', () => setPlaying(false));
|
|
33
|
-
};
|
|
34
|
-
}, []);
|
|
35
|
-
|
|
36
|
-
return [playing, toggle];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default useAudio;
|
package/src/hooks/axios.tsx
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import constants from 'dash-constants/src/DASHAdminSystemConstants';
|
|
3
|
-
import { dashStorage } from 'dash-utils';
|
|
4
|
-
|
|
5
|
-
// Track refresh state to prevent multiple simultaneous refresh attempts
|
|
6
|
-
let isRefreshing = false;
|
|
7
|
-
let failedQueue: Array<{ resolve: (token: string) => void; reject: (error: any) => void }> = [];
|
|
8
|
-
|
|
9
|
-
const processQueue = (error: any, token?: string) => {
|
|
10
|
-
failedQueue.forEach(prom => {
|
|
11
|
-
if (error) {
|
|
12
|
-
prom.reject(error);
|
|
13
|
-
} else {
|
|
14
|
-
prom.resolve(token!);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
isRefreshing = false;
|
|
19
|
-
failedQueue = [];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const initAxios = () => {
|
|
23
|
-
let CSRFAuth = false;
|
|
24
|
-
|
|
25
|
-
let options = {
|
|
26
|
-
baseURL: constants.system.ADMIN_API_URL,
|
|
27
|
-
headers: {
|
|
28
|
-
'Content-Type': 'application/json',
|
|
29
|
-
Accept: 'application/json',
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const instance = axios.create(options);
|
|
34
|
-
|
|
35
|
-
if (CSRFAuth) {
|
|
36
|
-
instance.defaults.withCredentials = true;
|
|
37
|
-
instance.get('/csrf-cookie').then((response) => {
|
|
38
|
-
console.log('sanctum', response);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
instance.interceptors.request.use(function (config) {
|
|
43
|
-
const token = dashStorage.getItem('token');
|
|
44
|
-
//console.log("axios Hook", axios, token);
|
|
45
|
-
if (token !== undefined && token !== 'undefined') {
|
|
46
|
-
config.headers.Authorization = 'Bearer ' + token;
|
|
47
|
-
}
|
|
48
|
-
return config;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
instance.interceptors.response.use(
|
|
52
|
-
(response) => {
|
|
53
|
-
//console.log("Axios Success", response);
|
|
54
|
-
return response;
|
|
55
|
-
},
|
|
56
|
-
async (error) => {
|
|
57
|
-
const originalRequest = error.config;
|
|
58
|
-
|
|
59
|
-
// Skip refresh for auth-related endpoints to prevent infinite loops
|
|
60
|
-
const authEndpoints = ['/login', '/auth/refresh', '/logout', '/register'];
|
|
61
|
-
const isAuthEndpoint = authEndpoints.some(endpoint =>
|
|
62
|
-
originalRequest.url?.includes(endpoint)
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
// Handle 401 Unauthorized
|
|
66
|
-
if (error.response?.status === 401 && !isAuthEndpoint && !originalRequest._retry) {
|
|
67
|
-
if (isRefreshing) {
|
|
68
|
-
// If already refreshing, queue this request
|
|
69
|
-
return new Promise((resolve, reject) => {
|
|
70
|
-
failedQueue.push({ resolve, reject });
|
|
71
|
-
}).then(token => {
|
|
72
|
-
originalRequest.headers.Authorization = 'Bearer ' + token;
|
|
73
|
-
return instance(originalRequest);
|
|
74
|
-
}).catch(err => {
|
|
75
|
-
return Promise.reject(err);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
originalRequest._retry = true;
|
|
80
|
-
isRefreshing = true;
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
const refreshToken = dashStorage.getItem('refreshToken');
|
|
84
|
-
|
|
85
|
-
if (!refreshToken) {
|
|
86
|
-
// No refresh token available, logout user
|
|
87
|
-
await handleAuthFailure();
|
|
88
|
-
return Promise.reject(error);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Attempt to refresh the access token
|
|
92
|
-
const refreshResponse = await axios.post(
|
|
93
|
-
`${constants.system.ADMIN_API_URL}/auth/refresh`,
|
|
94
|
-
{ refresh_token: refreshToken }
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
const { token, refresh_token } = refreshResponse.data;
|
|
98
|
-
|
|
99
|
-
// Store new tokens
|
|
100
|
-
dashStorage.setItem('token', token);
|
|
101
|
-
dashStorage.setItem('refreshToken', refresh_token);
|
|
102
|
-
|
|
103
|
-
// Update original request with new token
|
|
104
|
-
originalRequest.headers.Authorization = 'Bearer ' + token;
|
|
105
|
-
|
|
106
|
-
// Process queued requests
|
|
107
|
-
processQueue(null, token);
|
|
108
|
-
|
|
109
|
-
// Retry original request
|
|
110
|
-
return instance(originalRequest);
|
|
111
|
-
} catch (refreshError) {
|
|
112
|
-
// Refresh failed, logout user
|
|
113
|
-
await handleAuthFailure();
|
|
114
|
-
processQueue(refreshError, null);
|
|
115
|
-
return Promise.reject(refreshError);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Dispatch global error event for other errors
|
|
120
|
-
if (error.response?.status !== 401) {
|
|
121
|
-
window.dispatchEvent(new MessageEvent('GlobalError', { data: { error } }));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (error.response && error.response.status === 422) {
|
|
125
|
-
/**
|
|
126
|
-
* Error Handling This is important for the system to parse Form field errors within AutoAdmin.
|
|
127
|
-
* therefore, an extra handling for errors are implemented in dataProvider and authProvider
|
|
128
|
-
**/
|
|
129
|
-
return Promise.reject(error.response.data?.errors || error);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return Promise.reject(error);
|
|
133
|
-
},
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
return instance;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
// Helper function to handle authentication failure
|
|
140
|
-
async function handleAuthFailure() {
|
|
141
|
-
// Clear auth data
|
|
142
|
-
dashStorage.removeItem('token');
|
|
143
|
-
dashStorage.removeItem('refreshToken');
|
|
144
|
-
dashStorage.removeItem('user');
|
|
145
|
-
dashStorage.removeItem('auth');
|
|
146
|
-
dashStorage.removeItem('authenticated');
|
|
147
|
-
dashStorage.removeItem('roles');
|
|
148
|
-
|
|
149
|
-
// Dispatch logout event
|
|
150
|
-
window.dispatchEvent(new MessageEvent('auth:logout'));
|
|
151
|
-
|
|
152
|
-
// Redirect to login if not already there
|
|
153
|
-
if (!window.location.pathname.includes('/login')) {
|
|
154
|
-
window.location.href = '/login';
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const useAxios = () => {
|
|
159
|
-
const axios = initAxios();
|
|
160
|
-
return {
|
|
161
|
-
axios,
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export default useAxios;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { useAxios } from 'dash-axios-hook';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import queryString from 'query-string';
|
|
4
|
-
import { useStore } from 'react-admin';
|
|
5
|
-
|
|
6
|
-
export interface IUseDashboardStats {
|
|
7
|
-
autoRefresh: boolean;
|
|
8
|
-
autoRefreshInterval?: number;
|
|
9
|
-
start?: string;
|
|
10
|
-
end?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const useDashboardStats = (options: IUseDashboardStats) => {
|
|
14
|
-
const { autoRefresh } = options;
|
|
15
|
-
const axios = useAxios();
|
|
16
|
-
const [data, setData] = useStore('dashboard.stats.data', null);
|
|
17
|
-
const [error, setError] = useState(null);
|
|
18
|
-
const [loaded, setLoaded] = useState(false);
|
|
19
|
-
|
|
20
|
-
const loadDashboardStats = async (o:any) => {
|
|
21
|
-
const payload = queryString.stringify(
|
|
22
|
-
{
|
|
23
|
-
...(o.start && { start: o.start }),
|
|
24
|
-
...(o.end && { end: o.end }),
|
|
25
|
-
},
|
|
26
|
-
{ arrayFormat: 'bracket' },
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
if (o.autoRefresh) {
|
|
30
|
-
try {
|
|
31
|
-
const response = await axios({
|
|
32
|
-
method: 'GET',
|
|
33
|
-
url: `/admin/dashboard?${payload}`,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if (response.status === 200) {
|
|
37
|
-
setData(response.data);
|
|
38
|
-
}
|
|
39
|
-
} catch (e) {
|
|
40
|
-
setError(e);
|
|
41
|
-
} finally {
|
|
42
|
-
setLoaded(true);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
loadDashboardStats({ ...options, autoRefresh: true });
|
|
49
|
-
const intervalId = setInterval(() => {
|
|
50
|
-
loadDashboardStats(options);
|
|
51
|
-
}, 10000);
|
|
52
|
-
|
|
53
|
-
return () => {
|
|
54
|
-
clearInterval(intervalId);
|
|
55
|
-
};
|
|
56
|
-
}, [autoRefresh]);
|
|
57
|
-
|
|
58
|
-
const refresh = () => {
|
|
59
|
-
loadDashboardStats({ ...options, autoRefresh: true });
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return { data, error, loaded, refresh };
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default useDashboardStats;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useAxios } from 'dash-axios-hook';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
export interface IDataPackagesByClients {
|
|
4
|
-
totalPackages: number;
|
|
5
|
-
totalCreatedPackages: number;
|
|
6
|
-
totalLabelPrintedPackages: number;
|
|
7
|
-
totalPreparedPackages: number;
|
|
8
|
-
totalInWarehousePackages: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const usePackageByClientsStats = (
|
|
12
|
-
start = null,
|
|
13
|
-
end = null,
|
|
14
|
-
) => {
|
|
15
|
-
const axios = useAxios();
|
|
16
|
-
|
|
17
|
-
const [data, setData] = useState<IDataPackagesByClients>(null);
|
|
18
|
-
const [error, setError] = useState(null);
|
|
19
|
-
const [loaded, setLoaded] = useState(false);
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
const loadDashboardStats = async () => {
|
|
23
|
-
try {
|
|
24
|
-
const response = await axios({
|
|
25
|
-
method: 'GET',
|
|
26
|
-
url: `/admin/dashboard/total-contadores-paquetes-por-cliente?start=${start}&end=${end}`,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
if (response.status === 200) {
|
|
30
|
-
setData(response.data);
|
|
31
|
-
}
|
|
32
|
-
} catch (e) {
|
|
33
|
-
setError(e);
|
|
34
|
-
} finally {
|
|
35
|
-
setLoaded(true);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
loadDashboardStats();
|
|
39
|
-
}, []);
|
|
40
|
-
|
|
41
|
-
return { data, error, loaded };
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default usePackageByClientsStats;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useAxios } from 'dash-axios-hook';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
export interface IDataPackagesByCommunes {
|
|
4
|
-
totalPackages: number;
|
|
5
|
-
totalCreatedPackages: number;
|
|
6
|
-
totalLabelPrintedPackages: number;
|
|
7
|
-
totalPreparedPackages: number;
|
|
8
|
-
totalInWarehousePackages: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const usePackageByCommunesStats = (
|
|
12
|
-
start = null,
|
|
13
|
-
end = null,
|
|
14
|
-
) => {
|
|
15
|
-
const axios = useAxios();
|
|
16
|
-
|
|
17
|
-
const [data, setData] = useState<IDataPackagesByCommunes>(null);
|
|
18
|
-
const [error, setError] = useState(null);
|
|
19
|
-
const [loaded, setLoaded] = useState(false);
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
const loadDashboardStats = async () => {
|
|
23
|
-
try {
|
|
24
|
-
const response = await axios({
|
|
25
|
-
method: 'GET',
|
|
26
|
-
url: `/admin/dashboard/total-contadores-paquetes-por-comuna?start=${start}&end=${end}`,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
if (response.status === 200) {
|
|
30
|
-
setData(response.data);
|
|
31
|
-
}
|
|
32
|
-
} catch (e) {
|
|
33
|
-
setError(e);
|
|
34
|
-
} finally {
|
|
35
|
-
setLoaded(true);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
loadDashboardStats();
|
|
39
|
-
}, []);
|
|
40
|
-
|
|
41
|
-
return { data, error, loaded };
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default usePackageByCommunesStats;
|