@pagamio/frontend-commons-lib 0.8.175 → 0.8.183
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/lib/api/client.d.ts +88 -0
- package/lib/api/client.js +339 -0
- package/lib/api/context.d.ts +112 -0
- package/lib/api/context.js +105 -0
- package/lib/api/index.d.ts +4 -0
- package/lib/api/index.js +4 -0
- package/lib/api/swr.d.ts +46 -0
- package/lib/api/swr.js +124 -0
- package/lib/api/types.d.ts +145 -0
- package/lib/api/types.js +10 -0
- package/lib/auth/authenticators/AuthenticatorFactory.d.ts +25 -0
- package/lib/auth/authenticators/AuthenticatorFactory.js +32 -0
- package/lib/auth/authenticators/index.d.ts +7 -0
- package/lib/auth/authenticators/index.js +7 -0
- package/lib/auth/authenticators/processors/DefaultAuthenticatorProcessor.d.ts +21 -0
- package/lib/auth/authenticators/processors/DefaultAuthenticatorProcessor.js +26 -0
- package/lib/auth/authenticators/processors/StrapiAuthenticatorProcessor.d.ts +74 -0
- package/lib/auth/authenticators/processors/StrapiAuthenticatorProcessor.js +99 -0
- package/lib/auth/authenticators/types.d.ts +26 -0
- package/lib/auth/authenticators/types.js +9 -0
- package/lib/auth/components/AppBanner.d.ts +7 -0
- package/lib/auth/components/AppBanner.js +9 -0
- package/lib/auth/components/AuthCard.d.ts +8 -0
- package/lib/auth/components/AuthCard.js +14 -0
- package/lib/auth/components/AuthFormUtils.d.ts +58 -0
- package/lib/auth/components/AuthFormUtils.js +52 -0
- package/lib/auth/components/AuthPageLayout.d.ts +45 -0
- package/lib/auth/components/AuthPageLayout.js +12 -0
- package/lib/auth/components/ChangePasswordPage.d.ts +12 -0
- package/lib/auth/components/ChangePasswordPage.js +59 -0
- package/lib/auth/components/CustomerRegistrationPage.d.ts +50 -0
- package/lib/auth/components/CustomerRegistrationPage.js +140 -0
- package/lib/auth/components/ForgotPasswordPage.d.ts +38 -0
- package/lib/auth/components/ForgotPasswordPage.js +76 -0
- package/lib/auth/components/LoginPage.d.ts +73 -0
- package/lib/auth/components/LoginPage.js +115 -0
- package/lib/auth/components/LogoutButton.d.ts +30 -0
- package/lib/auth/components/LogoutButton.js +47 -0
- package/lib/auth/components/ResetPasswordPage.d.ts +42 -0
- package/lib/auth/components/ResetPasswordPage.js +88 -0
- package/lib/auth/components/hooks/useChangeUserPassword.d.ts +26 -0
- package/lib/auth/components/hooks/useChangeUserPassword.js +63 -0
- package/lib/auth/components/index.d.ts +8 -0
- package/lib/auth/components/index.js +7 -0
- package/lib/auth/context/AuthContext.d.ts +65 -0
- package/lib/auth/context/AuthContext.js +150 -0
- package/lib/auth/context/index.d.ts +1 -0
- package/lib/auth/context/index.js +1 -0
- package/lib/auth/index.d.ts +7 -0
- package/lib/auth/index.js +7 -0
- package/lib/auth/services/AuthService.d.ts +230 -0
- package/lib/auth/services/AuthService.js +475 -0
- package/lib/auth/services/LogoutService.d.ts +27 -0
- package/lib/auth/services/LogoutService.js +98 -0
- package/lib/auth/services/index.d.ts +2 -0
- package/lib/auth/services/index.js +2 -0
- package/lib/auth/shared/index.d.ts +1 -0
- package/lib/auth/shared/index.js +1 -0
- package/lib/auth/shared/layout/AuthPageLayout.d.ts +10 -0
- package/lib/auth/shared/layout/AuthPageLayout.js +16 -0
- package/lib/auth/shared/layout/index.d.ts +1 -0
- package/lib/auth/shared/layout/index.js +1 -0
- package/lib/auth/types/auth.types.d.ts +234 -0
- package/lib/auth/types/auth.types.js +14 -0
- package/lib/auth/types/index.d.ts +1 -0
- package/lib/auth/types/index.js +1 -0
- package/lib/auth/utils/TokenManager.d.ts +43 -0
- package/lib/auth/utils/TokenManager.js +171 -0
- package/lib/auth/utils/Transformers.d.ts +158 -0
- package/lib/auth/utils/Transformers.js +263 -0
- package/lib/auth/utils/errorDetection.d.ts +22 -0
- package/lib/auth/utils/errorDetection.js +190 -0
- package/lib/auth/utils/index.d.ts +3 -0
- package/lib/auth/utils/index.js +3 -0
- package/lib/components/charts/LineGraph.d.ts +15 -0
- package/lib/components/charts/LineGraph.js +131 -0
- package/lib/components/icons/Icon.d.ts +8 -0
- package/lib/components/icons/Icon.js +13 -0
- package/lib/components/icons/index.d.ts +2 -0
- package/lib/components/icons/index.js +2 -0
- package/lib/components/icons/types.d.ts +26 -0
- package/lib/components/icons/types.js +33 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.js +3 -0
- package/lib/components/layout/AppLayout.d.ts +34 -0
- package/lib/components/layout/AppLayout.js +19 -0
- package/lib/components/layout/AuthPageLayout.d.ts +13 -0
- package/lib/components/layout/AuthPageLayout.js +15 -0
- package/lib/components/layout/BreadcrumbNav.d.ts +2 -0
- package/lib/components/layout/BreadcrumbNav.js +10 -0
- package/lib/components/layout/LayoutContent.d.ts +6 -0
- package/lib/components/layout/LayoutContent.js +10 -0
- package/lib/components/layout/Navbar.d.ts +106 -0
- package/lib/components/layout/Navbar.js +66 -0
- package/lib/components/layout/PageHeader.d.ts +8 -0
- package/lib/components/layout/PageHeader.js +7 -0
- package/lib/components/layout/SessionExpiryModal.d.ts +10 -0
- package/lib/components/layout/SessionExpiryModal.js +9 -0
- package/lib/components/layout/Sidebar.d.ts +6 -0
- package/lib/components/layout/Sidebar.js +87 -0
- package/lib/components/layout/VerticalTabsLayout.d.ts +12 -0
- package/lib/components/layout/VerticalTabsLayout.js +14 -0
- package/lib/components/layout/index.d.ts +9 -0
- package/lib/components/layout/index.js +9 -0
- package/lib/components/ui/Avatar.d.ts +6 -0
- package/lib/components/ui/Avatar.js +11 -0
- package/lib/components/ui/AvatarIcon.d.ts +4 -0
- package/lib/components/ui/AvatarIcon.js +6 -0
- package/lib/components/ui/Button.d.ts +14 -0
- package/lib/components/ui/Button.js +30 -0
- package/lib/components/ui/Calendar.d.ts +9 -0
- package/lib/components/ui/Calendar.js +35 -0
- package/lib/components/ui/Card.d.ts +16 -0
- package/lib/components/ui/Card.js +6 -0
- package/lib/components/ui/Chart.d.ts +2 -0
- package/lib/components/ui/Chart.js +16 -0
- package/lib/components/ui/Checkbox.d.ts +4 -0
- package/lib/components/ui/Checkbox.js +8 -0
- package/lib/components/ui/Command.d.ts +80 -0
- package/lib/components/ui/Command.js +28 -0
- package/lib/components/ui/ContainedTab.d.ts +21 -0
- package/lib/components/ui/ContainedTab.js +37 -0
- package/lib/components/ui/DateFormat.d.ts +6 -0
- package/lib/components/ui/DateFormat.js +8 -0
- package/lib/components/ui/DatePicker.d.ts +14 -0
- package/lib/components/ui/DatePicker.js +91 -0
- package/lib/components/ui/DateRangeModal.d.ts +38 -0
- package/lib/components/ui/DateRangeModal.js +89 -0
- package/lib/components/ui/DetailsCard.d.ts +16 -0
- package/lib/components/ui/DetailsCard.js +14 -0
- package/lib/components/ui/DetailsPage.d.ts +36 -0
- package/lib/components/ui/DetailsPage.js +50 -0
- package/lib/components/ui/Dialog.d.ts +19 -0
- package/lib/components/ui/Dialog.js +22 -0
- package/lib/components/ui/EmptyState.d.ts +6 -0
- package/lib/components/ui/EmptyState.js +6 -0
- package/lib/components/ui/FilterComponent.d.ts +30 -0
- package/lib/components/ui/FilterComponent.js +80 -0
- package/lib/components/ui/FilterList.d.ts +52 -0
- package/lib/components/ui/FilterList.js +62 -0
- package/lib/components/ui/FilterSection.d.ts +31 -0
- package/lib/components/ui/FilterSection.js +21 -0
- package/lib/components/ui/FilterWrapper.d.ts +6 -0
- package/lib/components/ui/FilterWrapper.js +7 -0
- package/lib/components/ui/Form.d.ts +23 -0
- package/lib/components/ui/Form.js +62 -0
- package/lib/components/ui/HoverableValue.d.ts +7 -0
- package/lib/components/ui/HoverableValue.js +8 -0
- package/lib/components/ui/IconButton.d.ts +10 -0
- package/lib/components/ui/IconButton.js +10 -0
- package/lib/components/ui/ImageComponent.d.ts +8 -0
- package/lib/components/ui/ImageComponent.js +5 -0
- package/lib/components/ui/ImageUploader.d.ts +17 -0
- package/lib/components/ui/ImageUploader.js +144 -0
- package/lib/components/ui/Input.d.ts +4 -0
- package/lib/components/ui/Input.js +8 -0
- package/lib/components/ui/Label.d.ts +5 -0
- package/lib/components/ui/Label.js +9 -0
- package/lib/components/ui/Loader.d.ts +10 -0
- package/lib/components/ui/Loader.js +7 -0
- package/lib/components/ui/Modal.d.ts +72 -0
- package/lib/components/ui/Modal.js +31 -0
- package/lib/components/ui/MultiSelect.d.ts +16 -0
- package/lib/components/ui/MultiSelect.js +59 -0
- package/lib/components/ui/NotificationModal.d.ts +18 -0
- package/lib/components/ui/NotificationModal.js +40 -0
- package/lib/components/ui/PhoneInput.d.ts +12 -0
- package/lib/components/ui/PhoneInput.js +58 -0
- package/lib/components/ui/Popover.d.ts +7 -0
- package/lib/components/ui/Popover.js +10 -0
- package/lib/components/ui/Progress.d.ts +7 -0
- package/lib/components/ui/Progress.js +7 -0
- package/lib/components/ui/Radio.d.ts +5 -0
- package/lib/components/ui/Radio.js +14 -0
- package/lib/components/ui/RangeDatePicker.d.ts +78 -0
- package/lib/components/ui/RangeDatePicker.js +68 -0
- package/lib/components/ui/Select.d.ts +13 -0
- package/lib/components/ui/Select.js +57 -0
- package/lib/components/ui/Separator.d.ts +4 -0
- package/lib/components/ui/Separator.js +7 -0
- package/lib/components/ui/Sheet.d.ts +26 -0
- package/lib/components/ui/Sheet.js +37 -0
- package/lib/components/ui/StatusCell.d.ts +9 -0
- package/lib/components/ui/StatusCell.js +6 -0
- package/lib/components/ui/Switch.d.ts +10 -0
- package/lib/components/ui/Switch.js +22 -0
- package/lib/components/ui/Tab.d.ts +15 -0
- package/lib/components/ui/Tab.js +13 -0
- package/lib/components/ui/TableDownload.d.ts +11 -0
- package/lib/components/ui/TableDownload.js +82 -0
- package/lib/components/ui/TailwindIndicator.d.ts +1 -0
- package/lib/components/ui/TailwindIndicator.js +6 -0
- package/lib/components/ui/TextField.d.ts +60 -0
- package/lib/components/ui/TextField.js +42 -0
- package/lib/components/ui/Textarea.d.ts +5 -0
- package/lib/components/ui/Textarea.js +8 -0
- package/lib/components/ui/Toast.d.ts +12 -0
- package/lib/components/ui/Toast.js +25 -0
- package/lib/components/ui/UploadField.d.ts +15 -0
- package/lib/components/ui/UploadField.js +45 -0
- package/lib/components/ui/VerticalTab.d.ts +16 -0
- package/lib/components/ui/VerticalTab.js +13 -0
- package/lib/components/ui/index.d.ts +49 -0
- package/lib/components/ui/index.js +47 -0
- package/lib/context/BreadcrumbContext.d.ts +28 -0
- package/lib/context/BreadcrumbContext.js +238 -0
- package/lib/context/FormEngineDrawerProvider.d.ts +21 -0
- package/lib/context/FormEngineDrawerProvider.js +38 -0
- package/lib/context/MultiFormEngineDrawerProvider.d.ts +25 -0
- package/lib/context/MultiFormEngineDrawerProvider.js +89 -0
- package/lib/context/SidebarContext.d.ts +65 -0
- package/lib/context/SidebarContext.js +47 -0
- package/lib/context/ToastContext.d.ts +17 -0
- package/lib/context/ToastContext.js +29 -0
- package/lib/context/index.d.ts +5 -0
- package/lib/context/index.js +5 -0
- package/lib/dashboard-visuals/components/BaseChart.d.ts +55 -0
- package/lib/dashboard-visuals/components/BaseChart.js +201 -0
- package/lib/dashboard-visuals/components/CardWrapper.d.ts +10 -0
- package/lib/dashboard-visuals/components/CardWrapper.js +13 -0
- package/lib/dashboard-visuals/components/ChartDetailsModal.d.ts +57 -0
- package/lib/dashboard-visuals/components/ChartDetailsModal.js +27 -0
- package/lib/dashboard-visuals/components/ChartDetailsModalWrapper.d.ts +29 -0
- package/lib/dashboard-visuals/components/ChartDetailsModalWrapper.js +4 -0
- package/lib/dashboard-visuals/components/ChartFormatter.d.ts +22 -0
- package/lib/dashboard-visuals/components/ChartFormatter.js +46 -0
- package/lib/dashboard-visuals/components/ChartWrapper.d.ts +11 -0
- package/lib/dashboard-visuals/components/ChartWrapper.js +14 -0
- package/lib/dashboard-visuals/components/DashboardFilter.d.ts +8 -0
- package/lib/dashboard-visuals/components/DashboardFilter.js +17 -0
- package/lib/dashboard-visuals/components/DataTable.d.ts +3 -0
- package/lib/dashboard-visuals/components/DataTable.js +57 -0
- package/lib/dashboard-visuals/components/EmptyState.d.ts +6 -0
- package/lib/dashboard-visuals/components/EmptyState.js +6 -0
- package/lib/dashboard-visuals/components/ErrorState.d.ts +7 -0
- package/lib/dashboard-visuals/components/ErrorState.js +5 -0
- package/lib/dashboard-visuals/components/FilterComponentSkeleton.d.ts +3 -0
- package/lib/dashboard-visuals/components/FilterComponentSkeleton.js +11 -0
- package/lib/dashboard-visuals/components/Pagination.d.ts +10 -0
- package/lib/dashboard-visuals/components/Pagination.js +7 -0
- package/lib/dashboard-visuals/components/Switch.d.ts +8 -0
- package/lib/dashboard-visuals/components/Switch.js +10 -0
- package/lib/dashboard-visuals/components/TileSkeleton.d.ts +2 -0
- package/lib/dashboard-visuals/components/TileSkeleton.js +5 -0
- package/lib/dashboard-visuals/components/molecules/Analytics.d.ts +11 -0
- package/lib/dashboard-visuals/components/molecules/Analytics.js +9 -0
- package/lib/dashboard-visuals/components/molecules/DataGrid.d.ts +15 -0
- package/lib/dashboard-visuals/components/molecules/DataGrid.js +124 -0
- package/lib/dashboard-visuals/components/molecules/NoChartData.d.ts +6 -0
- package/lib/dashboard-visuals/components/molecules/NoChartData.js +6 -0
- package/lib/dashboard-visuals/components/molecules/VisualChart.d.ts +16 -0
- package/lib/dashboard-visuals/components/molecules/VisualChart.js +8 -0
- package/lib/dashboard-visuals/components/types.d.ts +62 -0
- package/lib/dashboard-visuals/components/types.js +1 -0
- package/lib/dashboard-visuals/hooks/useChartData.d.ts +15 -0
- package/lib/dashboard-visuals/hooks/useChartData.js +82 -0
- package/lib/dashboard-visuals/hooks/useTooltipFormatter.d.ts +13 -0
- package/lib/dashboard-visuals/hooks/useTooltipFormatter.js +10 -0
- package/lib/dashboard-visuals/index.d.ts +39 -0
- package/lib/dashboard-visuals/index.js +168 -0
- package/lib/dashboard-visuals/types/index.d.ts +83 -0
- package/lib/dashboard-visuals/types/index.js +1 -0
- package/lib/dashboard-visuals/types/metricDetailData.d.ts +25 -0
- package/lib/dashboard-visuals/types/metricDetailData.js +1 -0
- package/lib/dashboard-visuals/utils/api.d.ts +5 -0
- package/lib/dashboard-visuals/utils/api.js +6 -0
- package/lib/dashboard-visuals/utils/chartOptions.d.ts +481 -0
- package/lib/dashboard-visuals/utils/chartOptions.js +393 -0
- package/lib/dashboard-visuals/utils/chunkArray.d.ts +1 -0
- package/lib/dashboard-visuals/utils/chunkArray.js +7 -0
- package/lib/dashboard-visuals/utils/defaultColors.d.ts +1 -0
- package/lib/dashboard-visuals/utils/defaultColors.js +1 -0
- package/lib/dashboard-visuals/utils/formatUtil.d.ts +203 -0
- package/lib/dashboard-visuals/utils/formatUtil.js +472 -0
- package/lib/dashboard-visuals/utils/gridUtil.d.ts +11 -0
- package/lib/dashboard-visuals/utils/gridUtil.js +32 -0
- package/lib/dashboard-visuals/utils/index.d.ts +6 -0
- package/lib/dashboard-visuals/utils/index.js +6 -0
- package/lib/dashboard-visuals/utils/tooltipUtils.d.ts +11 -0
- package/lib/dashboard-visuals/utils/tooltipUtils.js +180 -0
- package/lib/dashboard-visuals/visualRegistry.d.ts +4 -0
- package/lib/dashboard-visuals/visualRegistry.js +41 -0
- package/lib/dashboard-visuals/visuals/BarChart.d.ts +58 -0
- package/lib/dashboard-visuals/visuals/BarChart.js +95 -0
- package/lib/dashboard-visuals/visuals/BarLineHybridChart.d.ts +33 -0
- package/lib/dashboard-visuals/visuals/BarLineHybridChart.js +60 -0
- package/lib/dashboard-visuals/visuals/BubbleChart.d.ts +25 -0
- package/lib/dashboard-visuals/visuals/BubbleChart.js +101 -0
- package/lib/dashboard-visuals/visuals/DistributionChart.d.ts +11 -0
- package/lib/dashboard-visuals/visuals/DistributionChart.js +48 -0
- package/lib/dashboard-visuals/visuals/DonutChart.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/DonutChart.js +105 -0
- package/lib/dashboard-visuals/visuals/GaugeChart.d.ts +32 -0
- package/lib/dashboard-visuals/visuals/GaugeChart.js +53 -0
- package/lib/dashboard-visuals/visuals/GroupedBarChart.d.ts +47 -0
- package/lib/dashboard-visuals/visuals/GroupedBarChart.js +131 -0
- package/lib/dashboard-visuals/visuals/HeatmapChart.d.ts +79 -0
- package/lib/dashboard-visuals/visuals/HeatmapChart.js +146 -0
- package/lib/dashboard-visuals/visuals/HorizontalBarChart.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/HorizontalBarChart.js +131 -0
- package/lib/dashboard-visuals/visuals/ItemPerformanceCard.d.ts +30 -0
- package/lib/dashboard-visuals/visuals/ItemPerformanceCard.js +31 -0
- package/lib/dashboard-visuals/visuals/LineChart.d.ts +56 -0
- package/lib/dashboard-visuals/visuals/LineChart.js +80 -0
- package/lib/dashboard-visuals/visuals/LineGraph.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/LineGraph.js +189 -0
- package/lib/dashboard-visuals/visuals/MetricSummaryCard.d.ts +14 -0
- package/lib/dashboard-visuals/visuals/MetricSummaryCard.js +8 -0
- package/lib/dashboard-visuals/visuals/MultiGaugeChart.d.ts +39 -0
- package/lib/dashboard-visuals/visuals/MultiGaugeChart.js +119 -0
- package/lib/dashboard-visuals/visuals/PieChart.d.ts +59 -0
- package/lib/dashboard-visuals/visuals/PieChart.js +194 -0
- package/lib/dashboard-visuals/visuals/SelectedEventTile.d.ts +14 -0
- package/lib/dashboard-visuals/visuals/SelectedEventTile.js +35 -0
- package/lib/dashboard-visuals/visuals/SpeedometerChart.d.ts +53 -0
- package/lib/dashboard-visuals/visuals/SpeedometerChart.js +94 -0
- package/lib/dashboard-visuals/visuals/Table.d.ts +26 -0
- package/lib/dashboard-visuals/visuals/Table.js +113 -0
- package/lib/dashboard-visuals/visuals/Tile.d.ts +16 -0
- package/lib/dashboard-visuals/visuals/Tile.js +16 -0
- package/lib/dashboard-visuals/visuals/TreeMap.d.ts +25 -0
- package/lib/dashboard-visuals/visuals/TreeMap.js +45 -0
- package/lib/dashboard-visuals/visuals/WaterfallChart.d.ts +52 -0
- package/lib/dashboard-visuals/visuals/WaterfallChart.js +266 -0
- package/lib/form-engine/Form.d.ts +4 -0
- package/lib/form-engine/Form.js +14 -0
- package/lib/form-engine/FormEngine.d.ts +3 -0
- package/lib/form-engine/FormEngine.js +121 -0
- package/lib/form-engine/components/FieldWrapper.d.ts +18 -0
- package/lib/form-engine/components/FieldWrapper.js +63 -0
- package/lib/form-engine/components/index.d.ts +2 -0
- package/lib/form-engine/components/index.js +2 -0
- package/lib/form-engine/components/inputs/card-expiry-input/CardExpiryInput.d.ts +16 -0
- package/lib/form-engine/components/inputs/card-expiry-input/CardExpiryInput.js +48 -0
- package/lib/form-engine/components/inputs/checkbox-input/CheckboxInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/checkbox-input/CheckboxInput.js +5 -0
- package/lib/form-engine/components/inputs/credit-card-input/CreditCardInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/credit-card-input/CreditCardInput.js +82 -0
- package/lib/form-engine/components/inputs/date-input/DateInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/date-input/DateInput.js +7 -0
- package/lib/form-engine/components/inputs/date-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/date-input/index.js +1 -0
- package/lib/form-engine/components/inputs/email-input/EmailInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/email-input/EmailInput.js +5 -0
- package/lib/form-engine/components/inputs/email-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/email-input/index.js +1 -0
- package/lib/form-engine/components/inputs/index.d.ts +13 -0
- package/lib/form-engine/components/inputs/index.js +13 -0
- package/lib/form-engine/components/inputs/label-input/LabelInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/label-input/LabelInput.js +7 -0
- package/lib/form-engine/components/inputs/label-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/label-input/index.js +1 -0
- package/lib/form-engine/components/inputs/multi-select-input/MultiSelectInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/multi-select-input/MultiSelectInput.js +5 -0
- package/lib/form-engine/components/inputs/number-input/NumberInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/number-input/NumberInput.js +5 -0
- package/lib/form-engine/components/inputs/number-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/number-input/index.js +1 -0
- package/lib/form-engine/components/inputs/password-input/PasswordInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/password-input/PasswordInput.js +9 -0
- package/lib/form-engine/components/inputs/password-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/password-input/index.js +1 -0
- package/lib/form-engine/components/inputs/radio-button/RadioInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/radio-button/RadioInput.js +6 -0
- package/lib/form-engine/components/inputs/radio-button/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/radio-button/index.js +1 -0
- package/lib/form-engine/components/inputs/select/SelectInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/select/SelectInput.js +6 -0
- package/lib/form-engine/components/inputs/select/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/select/index.js +1 -0
- package/lib/form-engine/components/inputs/textarea-input/TextareaInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/textarea-input/TextareaInput.js +5 -0
- package/lib/form-engine/components/inputs/textarea-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/textarea-input/index.js +1 -0
- package/lib/form-engine/components/inputs/time-input/TimeInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/time-input/TimeInput.js +5 -0
- package/lib/form-engine/components/inputs/time-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/time-input/index.js +1 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/ToggleSwitchInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/ToggleSwitchInput.js +7 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/index.js +1 -0
- package/lib/form-engine/components/inputs/upload-field/UploadFieldForm.d.ts +4 -0
- package/lib/form-engine/components/inputs/upload-field/UploadFieldForm.js +59 -0
- package/lib/form-engine/components/inputs/upload-field/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/upload-field/index.js +1 -0
- package/lib/form-engine/hooks/useFormPersistence.d.ts +11 -0
- package/lib/form-engine/hooks/useFormPersistence.js +46 -0
- package/lib/form-engine/index.d.ts +5 -0
- package/lib/form-engine/index.js +5 -0
- package/lib/form-engine/registry/RegisterComponents.d.ts +1 -0
- package/lib/form-engine/registry/RegisterComponents.js +35 -0
- package/lib/form-engine/registry/Registry.d.ts +5 -0
- package/lib/form-engine/registry/Registry.js +13 -0
- package/lib/form-engine/registry/index.d.ts +2 -0
- package/lib/form-engine/registry/index.js +2 -0
- package/lib/form-engine/types/index.d.ts +311 -0
- package/lib/form-engine/types/index.js +1 -0
- package/lib/helpers/index.d.ts +2 -0
- package/lib/helpers/index.js +2 -0
- package/lib/helpers/utils.d.ts +37 -0
- package/lib/helpers/utils.js +77 -0
- package/lib/helpers/validations.d.ts +80 -0
- package/lib/helpers/validations.js +39 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +30 -0
- package/lib/mocks/mockApiRequestsConfig.d.ts +2 -0
- package/lib/mocks/mockApiRequestsConfig.js +343 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/TopUpWalletContent.d.ts +14 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/TopUpWalletContent.js +40 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/index.d.ts +11 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/index.js +7 -0
- package/lib/pagamio-drawer/components/BaseDrawer.d.ts +11 -0
- package/lib/pagamio-drawer/components/BaseDrawer.js +10 -0
- package/lib/pagamio-drawer/components/DrawerContent.d.ts +27 -0
- package/lib/pagamio-drawer/components/DrawerContent.js +237 -0
- package/lib/pagamio-drawer/index.d.ts +22 -0
- package/lib/pagamio-drawer/index.js +133 -0
- package/lib/pagamio-table/data-table/ExportButton.d.ts +57 -0
- package/lib/pagamio-table/data-table/ExportButton.js +96 -0
- package/lib/pagamio-table/data-table/MantineCoreTable.d.ts +44 -0
- package/lib/pagamio-table/data-table/MantineCoreTable.js +129 -0
- package/lib/pagamio-table/data-table/Pagination.d.ts +10 -0
- package/lib/pagamio-table/data-table/Pagination.js +5 -0
- package/lib/pagamio-table/data-table/TableDownload.d.ts +8 -0
- package/lib/pagamio-table/data-table/TableDownload.js +81 -0
- package/lib/pagamio-table/data-table/TableToolbar.d.ts +3 -0
- package/lib/pagamio-table/data-table/TableToolbar.js +16 -0
- package/lib/pagamio-table/data-table/exportUtils.d.ts +42 -0
- package/lib/pagamio-table/data-table/exportUtils.js +782 -0
- package/lib/pagamio-table/data-table/index.d.ts +5 -0
- package/lib/pagamio-table/data-table/index.js +11 -0
- package/lib/pagamio-table/data-table/pdfExportUtils.d.ts +111 -0
- package/lib/pagamio-table/data-table/pdfExportUtils.js +113 -0
- package/lib/pagamio-table/data-table/types.d.ts +169 -0
- package/lib/pagamio-table/data-table/types.js +1 -0
- package/lib/pagamio-table/index.d.ts +4 -0
- package/lib/pagamio-table/index.js +4 -0
- package/lib/pagamio-table/utils/functionHelper.d.ts +12 -0
- package/lib/pagamio-table/utils/functionHelper.js +24 -0
- package/lib/pagamio-table/utils/index.d.ts +1 -0
- package/lib/pagamio-table/utils/index.js +1 -0
- package/lib/rbac/hooks.d.ts +39 -0
- package/lib/rbac/hooks.js +51 -0
- package/lib/rbac/index.d.ts +8 -0
- package/lib/rbac/index.js +11 -0
- package/lib/rbac/store.d.ts +24 -0
- package/lib/rbac/store.js +37 -0
- package/lib/rbac/types.d.ts +39 -0
- package/lib/rbac/types.js +4 -0
- package/lib/rbac/utils.d.ts +44 -0
- package/lib/rbac/utils.js +117 -0
- package/lib/shared/constants/index.d.ts +2 -0
- package/lib/shared/constants/index.js +2 -0
- package/lib/shared/hooks/index.d.ts +4 -0
- package/lib/shared/hooks/index.js +4 -0
- package/lib/shared/hooks/useAnyDrawerOpen.d.ts +4 -0
- package/lib/shared/hooks/useAnyDrawerOpen.js +18 -0
- package/lib/shared/hooks/useContainerWidth.d.ts +2 -0
- package/lib/shared/hooks/useContainerWidth.js +18 -0
- package/lib/shared/hooks/useImageUpload.d.ts +15 -0
- package/lib/shared/hooks/useImageUpload.js +66 -0
- package/lib/shared/hooks/useMediaQueries.d.ts +5 -0
- package/lib/shared/hooks/useMediaQueries.js +35 -0
- package/lib/shared/hooks/usePagamioTable.d.ts +158 -0
- package/lib/shared/hooks/usePagamioTable.js +475 -0
- package/lib/shared/hooks/useSessionTimer.d.ts +33 -0
- package/lib/shared/hooks/useSessionTimer.js +96 -0
- package/lib/shared/index.d.ts +4 -0
- package/lib/shared/index.js +4 -0
- package/lib/shared/types/index.d.ts +1 -0
- package/lib/shared/types/index.js +1 -0
- package/lib/shared/url/index.d.ts +9 -0
- package/lib/shared/url/index.js +20 -0
- package/lib/shared/utils/filterUtils.d.ts +5 -0
- package/lib/shared/utils/filterUtils.js +31 -0
- package/lib/shared/utils/functionHelper.d.ts +27 -0
- package/lib/shared/utils/functionHelper.js +124 -0
- package/lib/shared/utils/index.d.ts +2 -0
- package/lib/shared/utils/index.js +2 -0
- package/lib/shared/utils/localStorage.d.ts +53 -0
- package/lib/shared/utils/localStorage.js +139 -0
- package/lib/styles.css +6247 -0
- package/lib/translations/components/LocaleSwitcher.d.ts +7 -0
- package/lib/translations/components/LocaleSwitcher.js +18 -0
- package/lib/translations/components/index.d.ts +1 -0
- package/lib/translations/components/index.js +1 -0
- package/lib/translations/context/TranslationContext.d.ts +5 -0
- package/lib/translations/context/TranslationContext.js +151 -0
- package/lib/translations/context/index.d.ts +1 -0
- package/lib/translations/context/index.js +1 -0
- package/lib/translations/hooks/index.d.ts +2 -0
- package/lib/translations/hooks/index.js +2 -0
- package/lib/translations/hooks/useLibTranslations.d.ts +7 -0
- package/lib/translations/hooks/useLibTranslations.js +46 -0
- package/lib/translations/hooks/useTranslation.d.ts +7 -0
- package/lib/translations/hooks/useTranslation.js +11 -0
- package/lib/translations/index.d.ts +91 -0
- package/lib/translations/index.js +11 -0
- package/lib/translations/locales/en.json +21 -0
- package/lib/translations/locales/es.json +21 -0
- package/lib/translations/locales/fr.json +21 -0
- package/lib/translations/locales/pt.json +21 -0
- package/lib/translations/types/index.d.ts +24 -0
- package/lib/translations/types/index.js +1 -0
- package/lib/translations/utils/index.d.ts +6 -0
- package/lib/translations/utils/index.js +25 -0
- package/package.json +9 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
const TileSkeleton = () => {
|
|
3
|
+
return (_jsxs("div", { className: "animate-pulse", children: [_jsx("div", { className: "h-4 bg-gray-200 rounded-full w-1/2 mb-4" }), _jsxs("div", { className: "flex justify-between", style: { height: '50px' }, children: [_jsxs("div", { className: "space-y-3", children: [_jsx("div", { className: "h-6 bg-gray-200 rounded-full w-24" }), _jsx("div", { className: "h-4 bg-gray-200 rounded-full w-20" })] }), _jsx("div", { className: "h-6 bg-gray-200 rounded-full w-16" })] })] }));
|
|
4
|
+
};
|
|
5
|
+
export default TileSkeleton;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DistributionMetricsProps, StatisticsMetricsProps } from '../ChartDetailsModal';
|
|
2
|
+
interface AnalyticsProps {
|
|
3
|
+
data: any[];
|
|
4
|
+
valueKey: string;
|
|
5
|
+
itemMetricsData: StatisticsMetricsProps;
|
|
6
|
+
valueMetricsData: StatisticsMetricsProps;
|
|
7
|
+
averageMetricsData: StatisticsMetricsProps;
|
|
8
|
+
distributionMetricsData: DistributionMetricsProps;
|
|
9
|
+
}
|
|
10
|
+
declare const Analytics: ({ data, valueKey, itemMetricsData, valueMetricsData, averageMetricsData, distributionMetricsData, }: AnalyticsProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default Analytics;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import ReactECharts from 'echarts-for-react';
|
|
3
|
+
import MetricSummaryCard from '../../visuals/MetricSummaryCard';
|
|
4
|
+
import Card from '../CardWrapper';
|
|
5
|
+
import ChartWrapper from '../ChartWrapper';
|
|
6
|
+
const Analytics = ({ data, valueKey, itemMetricsData, valueMetricsData, averageMetricsData, distributionMetricsData, }) => {
|
|
7
|
+
return (_jsx("div", { className: "w-full h-[60vh]", children: _jsxs("div", { className: "p-4", children: [_jsx("h4", { className: "text-lg font-semibold mb-2", children: "Summary Statistics" }), _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-2", children: [_jsx(MetricSummaryCard, { title: itemMetricsData.title, format: itemMetricsData.format, value: itemMetricsData.value, previousValue: itemMetricsData.previousValue, isEmpty: itemMetricsData.isEmpty, loading: itemMetricsData.loading, currency: itemMetricsData.currency, error: itemMetricsData.error, refresh: itemMetricsData.refresh }), _jsx(MetricSummaryCard, { title: valueMetricsData.title, format: valueMetricsData.format, value: valueMetricsData.value, previousValue: valueMetricsData.previousValue, isEmpty: valueMetricsData.isEmpty, loading: valueMetricsData.loading, currency: valueMetricsData.currency, error: valueMetricsData.error, refresh: valueMetricsData.refresh }), _jsx(MetricSummaryCard, { title: averageMetricsData.title, format: averageMetricsData.format, value: averageMetricsData.value, previousValue: averageMetricsData.previousValue, isEmpty: averageMetricsData.isEmpty, loading: averageMetricsData.loading, currency: valueMetricsData.currency, error: averageMetricsData.error, refresh: averageMetricsData.refresh })] }), _jsx("div", { className: "mt-5", children: _jsx(Card, { title: 'Distribution', children: _jsx(ChartWrapper, { loading: distributionMetricsData.loading, error: distributionMetricsData.error, isEmpty: distributionMetricsData.isEmpty, onRetry: distributionMetricsData.refresh, children: _jsx("div", { className: "mt-[19px]", children: _jsx(ReactECharts, { option: distributionMetricsData.data, style: { height: '350px' }, opts: { renderer: 'canvas' } }) }) }) }) })] }) }));
|
|
8
|
+
};
|
|
9
|
+
export default Analytics;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { QueryProps } from '../../../shared/types';
|
|
2
|
+
import type { TableColumn } from '../../visuals/Table';
|
|
3
|
+
interface DataGridProps<TData extends {
|
|
4
|
+
id: string | number;
|
|
5
|
+
}> {
|
|
6
|
+
dataGridQuery: QueryProps;
|
|
7
|
+
columns: TableColumn<TData>[];
|
|
8
|
+
searchInputPlaceHolder?: string;
|
|
9
|
+
searchKey: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const DataGrid: <TData extends {
|
|
13
|
+
id: string | number;
|
|
14
|
+
}>({ dataGridQuery, columns, searchInputPlaceHolder, searchKey, title, }: DataGridProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export default DataGrid;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ActionIcon, Tooltip } from '@mantine/core';
|
|
3
|
+
import { IconCopy } from '@tabler/icons-react';
|
|
4
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
5
|
+
import { usePaginatedApiSWR } from '../../../api';
|
|
6
|
+
import PagamioTable from '../../../pagamio-table/data-table';
|
|
7
|
+
import { DashboardPaths } from '../../utils';
|
|
8
|
+
import Card from '../CardWrapper';
|
|
9
|
+
import ErrorState from '../ErrorState';
|
|
10
|
+
const DataGrid = ({ dataGridQuery, columns, searchInputPlaceHolder, searchKey, title, }) => {
|
|
11
|
+
const [sortBy, setSortBy] = useState(undefined);
|
|
12
|
+
const [sortDir, setSortDir] = useState(undefined);
|
|
13
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
14
|
+
const [currentPage, setCurrentPage] = useState(0);
|
|
15
|
+
const [appliedSearchQuery, setAppliedSearchQuery] = useState('');
|
|
16
|
+
const [itemsPerPage, setItemsPerPage] = useState(10);
|
|
17
|
+
const url = DashboardPaths.PAGED;
|
|
18
|
+
const defaultSortByData = { sortBy: 'asc' };
|
|
19
|
+
const enhancedColumns = useMemo(() => {
|
|
20
|
+
return columns.map((column) => {
|
|
21
|
+
const extendedColumn = column;
|
|
22
|
+
if (extendedColumn.enableCopy) {
|
|
23
|
+
return {
|
|
24
|
+
...extendedColumn,
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
26
|
+
Cell: ({ cell }) => (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx("span", { children: cell.getValue() }), _jsx(Tooltip, { label: "Copy", children: _jsx(ActionIcon, { size: "xs", onClick: () => navigator.clipboard.writeText(cell.getValue()), style: { marginLeft: 8 }, children: _jsx(IconCopy, { size: 16 }) }) })] })),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (extendedColumn.formattedCellElement) {
|
|
30
|
+
return {
|
|
31
|
+
...extendedColumn,
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
33
|
+
Cell: ({ row }) => {
|
|
34
|
+
return extendedColumn.formattedCellElement(row.original);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return column;
|
|
39
|
+
});
|
|
40
|
+
}, [columns]);
|
|
41
|
+
// Build the query parameters
|
|
42
|
+
const queryParams = useMemo(() => {
|
|
43
|
+
let resolvedSortDirection;
|
|
44
|
+
if (sortDir) {
|
|
45
|
+
resolvedSortDirection = sortDir === 'asc' ? 'ASC' : 'DESC';
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
resolvedSortDirection = dataGridQuery.sortDirection;
|
|
49
|
+
}
|
|
50
|
+
return JSON.stringify({
|
|
51
|
+
...dataGridQuery,
|
|
52
|
+
filters: appliedSearchQuery
|
|
53
|
+
? { [searchKey]: appliedSearchQuery, ...dataGridQuery.filters }
|
|
54
|
+
: dataGridQuery.filters,
|
|
55
|
+
sortBy: sortBy ?? dataGridQuery.sortBy,
|
|
56
|
+
sortDirection: resolvedSortDirection,
|
|
57
|
+
page: currentPage,
|
|
58
|
+
size: itemsPerPage,
|
|
59
|
+
});
|
|
60
|
+
}, [dataGridQuery, appliedSearchQuery, searchKey, sortBy, sortDir, currentPage, itemsPerPage]);
|
|
61
|
+
// Use SWR for data fetching
|
|
62
|
+
const { data: response, error, mutate, } = usePaginatedApiSWR([url, queryParams], {
|
|
63
|
+
method: 'POST',
|
|
64
|
+
body: queryParams,
|
|
65
|
+
});
|
|
66
|
+
const tableData = response?.content ?? [];
|
|
67
|
+
const totalItems = response?.totalElements ?? 0;
|
|
68
|
+
const totalPages = response?.totalPages ?? 0;
|
|
69
|
+
const handleRetry = useCallback(() => {
|
|
70
|
+
mutate().then();
|
|
71
|
+
}, [mutate]);
|
|
72
|
+
const handleSort = useCallback((sortKey, sortDirection) => {
|
|
73
|
+
setSortBy(sortKey);
|
|
74
|
+
setSortDir(sortDirection);
|
|
75
|
+
setCurrentPage(0);
|
|
76
|
+
}, []);
|
|
77
|
+
const handleSearch = (e) => {
|
|
78
|
+
setSearchQuery(e.target.value);
|
|
79
|
+
};
|
|
80
|
+
const handleSearchTable = () => {
|
|
81
|
+
setAppliedSearchQuery(searchQuery);
|
|
82
|
+
setCurrentPage(0);
|
|
83
|
+
};
|
|
84
|
+
const handlePageChange = (page) => {
|
|
85
|
+
setCurrentPage(page);
|
|
86
|
+
};
|
|
87
|
+
const handleItemsPerPageChange = useCallback((pageIndex, pageSize) => {
|
|
88
|
+
setItemsPerPage(pageSize);
|
|
89
|
+
setCurrentPage(0);
|
|
90
|
+
}, []);
|
|
91
|
+
const handleClearFilters = useCallback(() => {
|
|
92
|
+
setSearchQuery('');
|
|
93
|
+
setAppliedSearchQuery('');
|
|
94
|
+
setCurrentPage(0);
|
|
95
|
+
setSortBy(undefined);
|
|
96
|
+
setSortDir(undefined);
|
|
97
|
+
}, []);
|
|
98
|
+
const sortConfig = sortBy ? { sortBy, sortDir: sortDir } : defaultSortByData;
|
|
99
|
+
const renderContent = () => {
|
|
100
|
+
if (error) {
|
|
101
|
+
return _jsx(ErrorState, { error: error, onRetry: handleRetry });
|
|
102
|
+
}
|
|
103
|
+
return (_jsx("div", { className: "mt-[19px]", children: _jsx(PagamioTable, { columns: enhancedColumns, data: tableData, addButton: false, rowCount: totalItems, searctInputPlaceHolder: searchInputPlaceHolder, pagination: {
|
|
104
|
+
enabled: true,
|
|
105
|
+
pageIndex: currentPage,
|
|
106
|
+
totalPages: totalPages,
|
|
107
|
+
onPageChange: handlePageChange,
|
|
108
|
+
pageSize: itemsPerPage,
|
|
109
|
+
itemsPerPage,
|
|
110
|
+
itemsPerPageOptions: [10, 20, 50],
|
|
111
|
+
onPaginationChange: handleItemsPerPageChange,
|
|
112
|
+
}, sorting: {
|
|
113
|
+
multiSorting: false,
|
|
114
|
+
sortConfig: sortConfig,
|
|
115
|
+
onSort: handleSort,
|
|
116
|
+
}, search: {
|
|
117
|
+
enabled: true,
|
|
118
|
+
searchQuery,
|
|
119
|
+
onSearch: handleSearch,
|
|
120
|
+
}, handleSearchTable: handleSearchTable, onClearFilters: handleClearFilters, sortable: true, showApplyFilterButton: true, enableManualSorting: true, enableManualPagination: true, enablePagination: true, showClearFilters: true, exportable: true, enableGlobalFilters: false }) }));
|
|
121
|
+
};
|
|
122
|
+
return _jsx(Card, { title: title, children: renderContent() });
|
|
123
|
+
};
|
|
124
|
+
export default DataGrid;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { HiChartPie, HiInformationCircle, HiTable } from 'react-icons/hi';
|
|
3
|
+
const NoChartData = ({ onSwitchToTable }) => {
|
|
4
|
+
return (_jsxs("div", { className: "flex flex-col items-center justify-center h-[60vh] p-6 bg-gray-50 rounded-lg", children: [_jsxs("div", { className: "relative mb-4", children: [_jsx(HiChartPie, { className: "w-16 h-16 text-gray-300" }), _jsx("div", { className: "absolute -top-1 -right-1", children: _jsx(HiInformationCircle, { className: "w-6 h-6 text-blue-500" }) })] }), _jsx("h3", { className: "text-xl font-semibold text-gray-700 mb-2", children: "Chart Visualization Unavailable" }), _jsx("p", { className: "text-gray-600 text-center max-w-md mb-6", children: "The chart visualization is not available for this dataset. You can still view and analyze the data in table format." }), onSwitchToTable && (_jsxs("button", { onClick: onSwitchToTable, className: "flex items-center gap-2 px-4 py-2 bg-blue-500 text-white rounded-lg \n hover:bg-blue-600 transition-colors duration-200 shadow-sm", children: [_jsx(HiTable, { className: "w-5 h-5" }), _jsx("span", { children: "View Data Table" })] })), _jsx("div", { className: "mt-8 p-4 bg-blue-50 rounded-lg max-w-md", children: _jsxs("div", { className: "flex gap-2", children: [_jsx(HiInformationCircle, { className: "w-5 h-5 text-blue-500 flex-shrink-0 mt-0.5" }), _jsxs("div", { className: "text-sm text-blue-700", children: [_jsx("p", { className: "font-medium mb-1", children: "Why might chart data be unavailable?" }), _jsxs("ul", { className: "list-disc list-inside space-y-1 ml-2", children: [_jsx("li", { children: "The dataset is too large to be properly rendered for chart visualization" }), _jsx("li", { children: "The dataset structure doesn't support chart visualization" }), _jsx("li", { children: "The required data fields for charting are missing" }), _jsx("li", { children: "The data format is incompatible with chart rendering" })] })] })] }) })] }));
|
|
5
|
+
};
|
|
6
|
+
export default NoChartData;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ApiErrorResponse } from '../../../api';
|
|
2
|
+
import type { ChartOptionsProps } from '../../types';
|
|
3
|
+
interface VisualChartProps<T> {
|
|
4
|
+
topFivePerformingChartTitle?: string;
|
|
5
|
+
bottomFivePerformingChartTitle?: string;
|
|
6
|
+
isEmpty: boolean;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
refresh: () => void;
|
|
9
|
+
error?: ApiErrorResponse;
|
|
10
|
+
chartData?: ChartOptionsProps<T>;
|
|
11
|
+
top5PerformingItems?: ChartOptionsProps<unknown>;
|
|
12
|
+
bottom5NonPerformingItems?: ChartOptionsProps<unknown>;
|
|
13
|
+
renderChart: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const VisualChart: <T>({ topFivePerformingChartTitle, bottomFivePerformingChartTitle, isEmpty, loading, refresh, error, chartData, top5PerformingItems, bottom5NonPerformingItems, renderChart, }: VisualChartProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export default VisualChart;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import ReactECharts from 'echarts-for-react';
|
|
3
|
+
import Card from '../CardWrapper';
|
|
4
|
+
import ChartWrapper from '../ChartWrapper';
|
|
5
|
+
const VisualChart = ({ topFivePerformingChartTitle, bottomFivePerformingChartTitle, isEmpty, loading, refresh, error, chartData, top5PerformingItems, bottom5NonPerformingItems, renderChart, }) => {
|
|
6
|
+
return (_jsx(_Fragment, { children: renderChart ? (_jsx(ChartWrapper, { loading: loading, error: error, isEmpty: isEmpty, onRetry: refresh, children: _jsx("div", { className: "w-full overflow-x-auto overflow-y-auto rounded-lg shadow-lg bg-white p-4", children: _jsx("div", { className: "min-w-[600px] w-full h-[400px]", children: _jsx(ReactECharts, { option: chartData, style: { height: '100%', width: '100%' }, className: "w-full h-full" }) }) }) })) : (_jsxs("div", { className: "flex gap-5 mb-5", children: [_jsx("div", { className: "w-1/2", children: _jsx(Card, { title: topFivePerformingChartTitle ?? 'Top 5 Performing Items', children: _jsx(ChartWrapper, { loading: loading, error: error, isEmpty: isEmpty, onRetry: refresh, children: _jsx("div", { className: "w-full overflow-x-auto overflow-y-auto rounded-lg shadow-lg bg-white p-4", children: _jsx("div", { className: "min-w-[600px] w-full h-[400px]", children: _jsx(ReactECharts, { option: top5PerformingItems, style: { height: '100%', width: '100%' }, className: "w-full h-full", opts: { renderer: 'canvas' }, notMerge: true }) }) }) }) }) }), _jsx("div", { className: "w-1/2", children: _jsx(Card, { title: bottomFivePerformingChartTitle ?? 'Bottom 5 Performing Items', children: _jsx(ChartWrapper, { loading: loading, error: error, isEmpty: isEmpty, onRetry: refresh, children: _jsx("div", { className: "w-full overflow-x-auto overflow-y-auto rounded-lg shadow-lg bg-white p-4", children: _jsx("div", { className: "min-w-[600px] w-full h-[400px]", children: _jsx(ReactECharts, { option: bottom5NonPerformingItems, style: { height: '100%', width: '100%' }, className: "w-full h-full" }) }) }) }) }) })] })) }));
|
|
7
|
+
};
|
|
8
|
+
export default VisualChart;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type MRT_ColumnDef, type MRT_TableOptions, type MRT_TableState } from 'mantine-react-table';
|
|
2
|
+
import { type Row } from 'react-table';
|
|
3
|
+
import type React from 'react';
|
|
4
|
+
export interface ExtendedMRTColumnDef<TData extends Record<string, any>> extends MRT_ColumnDef<TData> {
|
|
5
|
+
/** Enable click to copy for this column */
|
|
6
|
+
enableCopy?: boolean;
|
|
7
|
+
formattedCellElement?: (value: string | number | TData) => React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export interface ReusableTableProps<TData extends Record<string, any>> {
|
|
10
|
+
/** Table column definitions */
|
|
11
|
+
columns: ExtendedMRTColumnDef<TData>[];
|
|
12
|
+
/** Data to be displayed in the table */
|
|
13
|
+
data: TData[];
|
|
14
|
+
/** Optional title for the table */
|
|
15
|
+
title?: string;
|
|
16
|
+
/** Initial state options for the table */
|
|
17
|
+
initialState?: Partial<MRT_TableState<TData>>;
|
|
18
|
+
/** Enable or disable global search */
|
|
19
|
+
enableGlobalSearch?: boolean;
|
|
20
|
+
/** Enable or disable column-specific filters */
|
|
21
|
+
enableColumnFilters?: boolean;
|
|
22
|
+
/** Enable or disable sorting */
|
|
23
|
+
enableSorting?: boolean;
|
|
24
|
+
/** Enable or disable pagination */
|
|
25
|
+
enablePagination?: boolean;
|
|
26
|
+
/** Enable or disable row selection */
|
|
27
|
+
enableRowSelection?: boolean;
|
|
28
|
+
/** Enable or disable column reordering */
|
|
29
|
+
enableColumnReordering?: boolean;
|
|
30
|
+
/** Enable or disable sticky header */
|
|
31
|
+
enableStickyHeader?: boolean;
|
|
32
|
+
/** Callback when a row is clicked */
|
|
33
|
+
onRowClick?: (row: Row<TData>, event: React.MouseEvent) => void;
|
|
34
|
+
/** Additional table options */
|
|
35
|
+
tableOptions?: Partial<MRT_TableOptions<TData>>;
|
|
36
|
+
}
|
|
37
|
+
export interface TableData {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
export interface FilterConfig {
|
|
41
|
+
name: string;
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
label: string;
|
|
44
|
+
type: string;
|
|
45
|
+
options: any;
|
|
46
|
+
valueKey?: string;
|
|
47
|
+
url?: string;
|
|
48
|
+
tourUrl?: string;
|
|
49
|
+
query?: any;
|
|
50
|
+
multi?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface Visual {
|
|
53
|
+
type: string;
|
|
54
|
+
dataKey?: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
columns?: any[];
|
|
57
|
+
}
|
|
58
|
+
export interface Section {
|
|
59
|
+
title?: string;
|
|
60
|
+
layout: string;
|
|
61
|
+
visuals: Visual[];
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { QueryProps } from '../../shared/types';
|
|
2
|
+
import type { MetricData } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for fetching chart data with optimized caching to reduce server load
|
|
5
|
+
* @template T The data type to be returned from the API
|
|
6
|
+
* @template TransformReturnType The type after transformation
|
|
7
|
+
*/
|
|
8
|
+
export declare const useChartData: <T = MetricData[], TransformReturnType = T>(url: string, query: QueryProps, transform?: (data: T) => TransformReturnType) => {
|
|
9
|
+
data: T | TransformReturnType | undefined;
|
|
10
|
+
error: import("../../api").ApiErrorResponse | undefined;
|
|
11
|
+
loading: boolean;
|
|
12
|
+
isEmpty: boolean;
|
|
13
|
+
refresh: () => Promise<any>;
|
|
14
|
+
lastRefreshed: Date | undefined;
|
|
15
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isEqual } from 'lodash';
|
|
2
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
3
|
+
import { useApiSWRWithMutation } from '../../api';
|
|
4
|
+
// Constants for cache control
|
|
5
|
+
const CACHE_EXPIRY_TIME = 5 * 60 * 1000; // 5 minutes in milliseconds
|
|
6
|
+
/**
|
|
7
|
+
* Hook for fetching chart data with optimized caching to reduce server load
|
|
8
|
+
* @template T The data type to be returned from the API
|
|
9
|
+
* @template TransformReturnType The type after transformation
|
|
10
|
+
*/
|
|
11
|
+
export const useChartData = (url, query, transform) => {
|
|
12
|
+
// Keep a reference to the last data received to compare with new data
|
|
13
|
+
const lastDataRef = useRef(null);
|
|
14
|
+
const lastFetchTimeRef = useRef(null);
|
|
15
|
+
// Custom comparison function to determine if data has changed
|
|
16
|
+
const isDataEqual = useCallback((a, b) => {
|
|
17
|
+
return isEqual(a, b);
|
|
18
|
+
}, []);
|
|
19
|
+
// Custom cache comparison function for SWR to determine if data needs to be revalidated
|
|
20
|
+
const compareCache = useCallback((cachedData, newData) => {
|
|
21
|
+
const areEqual = isDataEqual(cachedData, newData);
|
|
22
|
+
return areEqual;
|
|
23
|
+
}, [isDataEqual]);
|
|
24
|
+
const { data, error, isLoading: loading, refresh, } = useApiSWRWithMutation([url, query], {
|
|
25
|
+
// Explicitly disable automatic polling/refreshing
|
|
26
|
+
refreshInterval: 0,
|
|
27
|
+
refreshWhenHidden: false,
|
|
28
|
+
refreshWhenOffline: false,
|
|
29
|
+
// Only revalidate on initial mount
|
|
30
|
+
revalidateOnMount: true,
|
|
31
|
+
revalidateOnFocus: false,
|
|
32
|
+
revalidateOnReconnect: false,
|
|
33
|
+
revalidateIfStale: false,
|
|
34
|
+
// Set a long dedupe interval to prevent frequent requests for the same resource
|
|
35
|
+
dedupingInterval: 300000, // 5 minutes
|
|
36
|
+
method: 'POST',
|
|
37
|
+
body: JSON.stringify(query),
|
|
38
|
+
headers: {
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
},
|
|
41
|
+
// Use SWR's compare function to avoid unnecessary renders and revalidations
|
|
42
|
+
compare: compareCache,
|
|
43
|
+
// Keep previous data while fetching new data
|
|
44
|
+
keepPreviousData: true,
|
|
45
|
+
// Handle successful responses and update cache metadata
|
|
46
|
+
onSuccess: (data) => {
|
|
47
|
+
// Store the data for comparison
|
|
48
|
+
lastDataRef.current = data;
|
|
49
|
+
lastFetchTimeRef.current = Date.now();
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
// Effect to update last fetch time when data changes
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (data) {
|
|
55
|
+
lastDataRef.current = data;
|
|
56
|
+
lastFetchTimeRef.current = Date.now();
|
|
57
|
+
}
|
|
58
|
+
}, [data]);
|
|
59
|
+
const transformedData = transform ? transform(data) : data;
|
|
60
|
+
const isEmpty = !error && !loading && Array.isArray(transformedData) ? !transformedData.length : transformedData === undefined;
|
|
61
|
+
// Enhanced refresh function that uses intelligent caching without custom headers
|
|
62
|
+
const smartRefresh = useCallback(() => {
|
|
63
|
+
// Check if cache is still fresh (< 5 minutes old)
|
|
64
|
+
const now = Date.now();
|
|
65
|
+
const lastFetchTime = lastFetchTimeRef.current;
|
|
66
|
+
// If data was fetched less than 5 minutes ago, don't refresh
|
|
67
|
+
if (lastFetchTime && now - lastFetchTime < CACHE_EXPIRY_TIME) {
|
|
68
|
+
// Return a promise that resolves immediately to match the refresh API
|
|
69
|
+
return Promise.resolve();
|
|
70
|
+
}
|
|
71
|
+
// Otherwise, trigger a revalidation (standard SWR refresh, no custom headers)
|
|
72
|
+
return refresh();
|
|
73
|
+
}, [refresh]);
|
|
74
|
+
return {
|
|
75
|
+
data: transformedData,
|
|
76
|
+
error,
|
|
77
|
+
loading,
|
|
78
|
+
isEmpty,
|
|
79
|
+
refresh: smartRefresh,
|
|
80
|
+
lastRefreshed: lastFetchTimeRef.current ? new Date(lastFetchTimeRef.current) : undefined,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MetricData, TooltipField } from '../types';
|
|
2
|
+
export declare function useTooltipFormatter(tooltipValueFormat: string, tooltipTitle: string, tooltipUnit: string, tooltipAdditionalFields: (string | TooltipField)[], metricData: MetricData[], displaySymbol?: string): {
|
|
3
|
+
processedTooltipFields: {
|
|
4
|
+
toolTipkey: string;
|
|
5
|
+
valueKey: string;
|
|
6
|
+
nameKey: string;
|
|
7
|
+
label: string;
|
|
8
|
+
suffix: string;
|
|
9
|
+
format: string;
|
|
10
|
+
formatter: (value: any, currency?: string, displaySymbol?: string) => string;
|
|
11
|
+
}[];
|
|
12
|
+
tooltipFormatterFn: (params: any) => string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { createTooltipFormatter, processTooltipFields } from '../utils/tooltipUtils';
|
|
3
|
+
export function useTooltipFormatter(tooltipValueFormat, tooltipTitle, tooltipUnit, tooltipAdditionalFields, metricData, displaySymbol) {
|
|
4
|
+
const processedTooltipFields = useMemo(() => processTooltipFields(tooltipAdditionalFields), [tooltipAdditionalFields]);
|
|
5
|
+
const tooltipFormatterFn = useMemo(() => {
|
|
6
|
+
const currency = metricData?.[0]?.currency;
|
|
7
|
+
return createTooltipFormatter(tooltipValueFormat, tooltipTitle, tooltipUnit, processedTooltipFields, metricData, currency, displaySymbol);
|
|
8
|
+
}, [tooltipTitle, tooltipUnit, processedTooltipFields, metricData, tooltipValueFormat, displaySymbol]);
|
|
9
|
+
return { processedTooltipFields, tooltipFormatterFn };
|
|
10
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FilterConfig } from './components/types';
|
|
3
|
+
type FilterValue = string | string[] | Date | null;
|
|
4
|
+
interface Config {
|
|
5
|
+
title: string;
|
|
6
|
+
summary: string;
|
|
7
|
+
filters: FilterConfig[];
|
|
8
|
+
tourFilters?: FilterConfig[];
|
|
9
|
+
themeColor?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface MetricsDataProps {
|
|
12
|
+
id: number;
|
|
13
|
+
gridColSpan?: number;
|
|
14
|
+
metricData: any;
|
|
15
|
+
}
|
|
16
|
+
export interface VisualDataProps {
|
|
17
|
+
id: number;
|
|
18
|
+
sectionTitle: string;
|
|
19
|
+
data: MetricsDataProps[];
|
|
20
|
+
}
|
|
21
|
+
interface DashboardWrapperProps {
|
|
22
|
+
data: {
|
|
23
|
+
config: Config;
|
|
24
|
+
visualData: VisualDataProps[];
|
|
25
|
+
eventsVisualData?: VisualDataProps[];
|
|
26
|
+
};
|
|
27
|
+
showVisualHeader?: boolean;
|
|
28
|
+
showEventsTabbedLayout?: boolean;
|
|
29
|
+
handleFilterChange?: (name: string, value: FilterValue) => void;
|
|
30
|
+
handleTourFilterChange?: (name: string, value: FilterValue) => void;
|
|
31
|
+
selectedFilters?: Record<string, FilterValue>;
|
|
32
|
+
tourSelectedFilters?: Record<string, FilterValue>;
|
|
33
|
+
resetFilters?: () => void;
|
|
34
|
+
handleApplyFilters?: () => void;
|
|
35
|
+
handleApplyTourFilters?: () => void;
|
|
36
|
+
}
|
|
37
|
+
declare const DashboardWrapper: React.FC<DashboardWrapperProps>;
|
|
38
|
+
export default DashboardWrapper;
|
|
39
|
+
export type { DashboardWrapperProps };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Grid } from '@mantine/core';
|
|
3
|
+
import { Card } from 'flowbite-react';
|
|
4
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
5
|
+
import { useApi } from '../api';
|
|
6
|
+
import { FilterComponent, Tab } from '../components';
|
|
7
|
+
import { useMediaQueries } from '../shared';
|
|
8
|
+
import ErrorState from './components/ErrorState';
|
|
9
|
+
import FilterComponentSkeleton from './components/FilterComponentSkeleton';
|
|
10
|
+
import { DashboardPaths, getFilterOptionsData, getGridColProps } from './utils';
|
|
11
|
+
import componentRegistry from './visualRegistry';
|
|
12
|
+
const OverviewContent = ({ visualData, renderContent, renderVisual }) => {
|
|
13
|
+
return (_jsxs(_Fragment, { children: [renderContent(), _jsx("main", { children: visualData.map((section) => (_jsxs("div", { className: "mb-2", children: [section.sectionTitle && _jsx("h2", { className: "mb-2 text-1xl font-semibold", children: section.sectionTitle }), _jsx(Grid, { gutter: "md", align: "stretch", className: "mb-[6px]", children: section.data.map((visual) => {
|
|
14
|
+
const numVisuals = section.data.length;
|
|
15
|
+
const { span, offset } = getGridColProps(numVisuals, visual.id);
|
|
16
|
+
return renderVisual(visual, visual.id, section.sectionTitle, visual?.gridColSpan ?? span, offset);
|
|
17
|
+
}) })] }, section.id))) })] }));
|
|
18
|
+
};
|
|
19
|
+
const EventsContent = ({ eventsVisualData, renderContent, renderVisual }) => {
|
|
20
|
+
return (_jsxs(_Fragment, { children: [renderContent(), _jsx("main", { children: eventsVisualData
|
|
21
|
+
? eventsVisualData.map((section) => (_jsxs("div", { className: "mb-2", children: [section.sectionTitle && _jsx("h2", { className: "mb-2 text-1xl font-semibold", children: section.sectionTitle }), _jsx(Grid, { gutter: "md", align: "stretch", className: "mb-[6px]", children: section.data.map((visual) => {
|
|
22
|
+
const numVisuals = section.data.length;
|
|
23
|
+
const { span, offset } = getGridColProps(numVisuals, visual.id);
|
|
24
|
+
return renderVisual(visual, visual.id, section.sectionTitle, visual?.gridColSpan ?? span, offset);
|
|
25
|
+
}) })] }, section.id)))
|
|
26
|
+
: null })] }));
|
|
27
|
+
};
|
|
28
|
+
const renderFilterComponent = ({ isLoading, error, filters, filterOptions, selectedFilters, handleFilterChange, handleApplyFilters, resetFilters, handleRetry, isNarrow, }) => {
|
|
29
|
+
if (isLoading) {
|
|
30
|
+
return _jsx(FilterComponentSkeleton, {});
|
|
31
|
+
}
|
|
32
|
+
if (error) {
|
|
33
|
+
return (_jsx(Card, { className: "mb-5", children: _jsx(ErrorState, { error: error, onRetry: handleRetry }) }));
|
|
34
|
+
}
|
|
35
|
+
return (_jsx(FilterComponent, { filters: filters.map((filter) => ({
|
|
36
|
+
name: filter.name,
|
|
37
|
+
placeholder: filter.placeholder ?? `Select ${filter.name}`,
|
|
38
|
+
type: filter.multi ? 'multi-select' : 'select',
|
|
39
|
+
options: filterOptions[filter.name] || filter.options,
|
|
40
|
+
})), showClearFilters: true, selectedFilters: selectedFilters, handleFilterChange: handleFilterChange, handleApplyFilters: handleApplyFilters, resetFilters: resetFilters, isNarrow: isNarrow }));
|
|
41
|
+
};
|
|
42
|
+
const DashboardWrapper = ({ data, showVisualHeader = true, showEventsTabbedLayout = false, handleFilterChange = () => { }, selectedFilters = {}, tourSelectedFilters = {}, resetFilters = () => { }, handleApplyFilters = () => { }, handleApplyTourFilters = () => { }, handleTourFilterChange = () => { }, }) => {
|
|
43
|
+
const [loading, setLoading] = useState(true);
|
|
44
|
+
const [error, setError] = useState(null);
|
|
45
|
+
const [tourError, setTourError] = useState(null);
|
|
46
|
+
const [isRefreshOpttonsQuery, setIsRefreshOpttonsQuery] = useState(0);
|
|
47
|
+
const [filterOptions, setFilterOptions] = useState({});
|
|
48
|
+
const [tourFilterOptions, setTourFilterOptions] = useState({});
|
|
49
|
+
const { isSm, isXs } = useMediaQueries();
|
|
50
|
+
const apiClient = useApi();
|
|
51
|
+
const { config, visualData, eventsVisualData } = data;
|
|
52
|
+
const defaultTabIndex = 0;
|
|
53
|
+
const fetchFilterData = async (key, valueKey, url, query, isTourFilter = false) => {
|
|
54
|
+
try {
|
|
55
|
+
setLoading(true);
|
|
56
|
+
if (isTourFilter) {
|
|
57
|
+
setTourError(null);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
setError(null);
|
|
61
|
+
}
|
|
62
|
+
const response = await apiClient.post(url, query);
|
|
63
|
+
if (response) {
|
|
64
|
+
const { optionsData } = getFilterOptionsData(response, key, valueKey);
|
|
65
|
+
if (isTourFilter) {
|
|
66
|
+
setTourFilterOptions((prev) => ({ ...prev, [key]: optionsData }));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
setFilterOptions((prev) => ({ ...prev, [key]: optionsData }));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
const errorMessage = 'Failed to fetch metric filter data';
|
|
75
|
+
if (isTourFilter) {
|
|
76
|
+
setTourError(err instanceof Error ? err : new Error(errorMessage));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
setError(err instanceof Error ? err : new Error(errorMessage));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
setLoading(false);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
const fetchFilters = (filters, isTour = false) => {
|
|
88
|
+
filters.forEach((filter) => {
|
|
89
|
+
if (filter.query) {
|
|
90
|
+
const queryUrl = isTour ? (filter.tourUrl ?? DashboardPaths.QUERY) : (filter.url ?? DashboardPaths.QUERY);
|
|
91
|
+
fetchFilterData(filter.name, filter.valueKey, queryUrl, filter.query, isTour);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
fetchFilters(config.filters);
|
|
96
|
+
if (config.tourFilters) {
|
|
97
|
+
fetchFilters(config.tourFilters, true);
|
|
98
|
+
}
|
|
99
|
+
}, [config.filters, isRefreshOpttonsQuery]);
|
|
100
|
+
const handleRetry = () => {
|
|
101
|
+
setIsRefreshOpttonsQuery((prev) => prev + 1);
|
|
102
|
+
};
|
|
103
|
+
const renderTourFilter = () => {
|
|
104
|
+
return renderFilterComponent({
|
|
105
|
+
isLoading: loading,
|
|
106
|
+
error: tourError,
|
|
107
|
+
filters: config.tourFilters || [],
|
|
108
|
+
filterOptions: tourFilterOptions,
|
|
109
|
+
selectedFilters: tourSelectedFilters,
|
|
110
|
+
handleFilterChange: handleTourFilterChange,
|
|
111
|
+
handleApplyFilters: handleApplyTourFilters,
|
|
112
|
+
resetFilters,
|
|
113
|
+
handleRetry,
|
|
114
|
+
isNarrow: isSm,
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
const renderContent = () => {
|
|
118
|
+
return renderFilterComponent({
|
|
119
|
+
isLoading: loading,
|
|
120
|
+
error,
|
|
121
|
+
filters: config.filters,
|
|
122
|
+
filterOptions,
|
|
123
|
+
selectedFilters,
|
|
124
|
+
handleFilterChange,
|
|
125
|
+
handleApplyFilters,
|
|
126
|
+
resetFilters,
|
|
127
|
+
handleRetry,
|
|
128
|
+
isNarrow: isSm,
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
const renderVisual = useCallback((visual, index, sectionTitle, span, offset) => {
|
|
132
|
+
const { metricData } = visual;
|
|
133
|
+
const matchesSmall = isXs || isSm;
|
|
134
|
+
const VisualComponent = componentRegistry[metricData.type];
|
|
135
|
+
if (!VisualComponent) {
|
|
136
|
+
console.error(`Visual type "${metricData.type}" not recognized in section "${sectionTitle}" at visual index ${index}.`);
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const props = {
|
|
140
|
+
data: metricData.data,
|
|
141
|
+
options: metricData.options,
|
|
142
|
+
title: metricData.title,
|
|
143
|
+
label: metricData.label,
|
|
144
|
+
colors: metricData.colors,
|
|
145
|
+
columns: metricData.columns,
|
|
146
|
+
format: metricData.format,
|
|
147
|
+
stacked: metricData.stacked ?? undefined,
|
|
148
|
+
themeColor: config.themeColor,
|
|
149
|
+
currencyDisplaySymbol: metricData.currencyDisplaySymbol,
|
|
150
|
+
...metricData,
|
|
151
|
+
};
|
|
152
|
+
return (_jsx(Grid.Col, { span: matchesSmall ? 12 : span, offset: offset, children: _jsx(VisualComponent, { ...props }) }, `visual-${visual.id}`));
|
|
153
|
+
}, [config.themeColor, isXs, isSm]);
|
|
154
|
+
const tabs = [
|
|
155
|
+
{
|
|
156
|
+
id: 1,
|
|
157
|
+
title: 'Overview',
|
|
158
|
+
content: _jsx(OverviewContent, { visualData: visualData, renderContent: renderContent, renderVisual: renderVisual }),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: 2,
|
|
162
|
+
title: 'Tour',
|
|
163
|
+
content: (_jsx(EventsContent, { eventsVisualData: eventsVisualData, renderContent: renderTourFilter, renderVisual: renderVisual })),
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
return (_jsxs("div", { children: [showVisualHeader && (_jsxs("div", { className: "mb-4", children: [_jsx("h1", { className: "text-2xl font-bold", children: config.title }), _jsx("p", { className: "text-1xl text-gray-600", children: config.summary })] })), showEventsTabbedLayout ? (_jsx(Tab, { tabs: tabs, defaultTab: defaultTabIndex, className: "justify-end" })) : (_jsx(OverviewContent, { visualData: visualData, renderContent: renderContent, renderVisual: renderVisual }))] }));
|
|
167
|
+
};
|
|
168
|
+
export default DashboardWrapper;
|