@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,50 @@
|
|
|
1
|
+
import type { QueryProps } from 'src/shared/types';
|
|
2
|
+
import type { ChartToolTipProps, DistributionChartTooltip, DistributionQueryProps, MetricData, StatisticsQueryProps, TableColumn, TooltipField } from '../types';
|
|
3
|
+
export declare const sortMetricData: (data: MetricData[], valueKey: string, sortOrder?: "asc" | "desc") => MetricData[];
|
|
4
|
+
interface ChartProps<TData extends {
|
|
5
|
+
id: string | number;
|
|
6
|
+
}> {
|
|
7
|
+
title?: string;
|
|
8
|
+
colorScheme?: string[];
|
|
9
|
+
chartDetails?: {
|
|
10
|
+
columns?: any[];
|
|
11
|
+
data?: any[];
|
|
12
|
+
};
|
|
13
|
+
themeColor?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
query: QueryProps;
|
|
17
|
+
sortOrder?: 'asc' | 'desc';
|
|
18
|
+
tooltipValueFormat: string;
|
|
19
|
+
tooltipTitle?: string;
|
|
20
|
+
tooltipUnit?: string;
|
|
21
|
+
tooltipAdditionalFields?: TooltipField[];
|
|
22
|
+
currencyDisplaySymbol?: string;
|
|
23
|
+
metricDetailData: {
|
|
24
|
+
title: string;
|
|
25
|
+
topFiveChartTitle: string;
|
|
26
|
+
bottomFiveChartTitle: string;
|
|
27
|
+
statisticsUrl?: string;
|
|
28
|
+
itemStatisticsQuery: StatisticsQueryProps;
|
|
29
|
+
valueMetricsQuery: StatisticsQueryProps;
|
|
30
|
+
averageMetricsQuery: StatisticsQueryProps;
|
|
31
|
+
distributionMetricsQuery: DistributionQueryProps;
|
|
32
|
+
yAxisDataNameKey: string;
|
|
33
|
+
xAxisNameKey: string;
|
|
34
|
+
xAxisLabel: string;
|
|
35
|
+
yAxisLabel: string;
|
|
36
|
+
nameKey: string;
|
|
37
|
+
valueKey: string;
|
|
38
|
+
dataGridSearchKey: string;
|
|
39
|
+
dataGridColumns: TableColumn<TData>[];
|
|
40
|
+
dataSearchInputPlaceHolder: string;
|
|
41
|
+
chartToolTip: ChartToolTipProps;
|
|
42
|
+
detailsTableTitle?: string;
|
|
43
|
+
distributionChartTooltip: DistributionChartTooltip;
|
|
44
|
+
};
|
|
45
|
+
showDetailsModal?: boolean;
|
|
46
|
+
}
|
|
47
|
+
declare const HorizontalBarChart: <TData extends {
|
|
48
|
+
id: string | number;
|
|
49
|
+
}>({ title, colorScheme, className, url, tooltipValueFormat, query, sortOrder, tooltipTitle, tooltipUnit, tooltipAdditionalFields, currencyDisplaySymbol, metricDetailData, showDetailsModal, ...props }: ChartProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export default HorizontalBarChart;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import ReactECharts from 'echarts-for-react';
|
|
3
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
4
|
+
import Card from '../components/CardWrapper';
|
|
5
|
+
import ChartDetailsModalWrapper from '../components/ChartDetailsModalWrapper';
|
|
6
|
+
import ChartWrapper from '../components/ChartWrapper';
|
|
7
|
+
import { useChartData } from '../hooks/useChartData';
|
|
8
|
+
import { useTooltipFormatter } from '../hooks/useTooltipFormatter';
|
|
9
|
+
import { DashboardPaths, processTooltipFields } from '../utils';
|
|
10
|
+
import { createDistributionMetricOptions, getChartBarOptions } from '../utils/chartOptions';
|
|
11
|
+
import { createTooltipFormatter } from '../utils/tooltipUtils';
|
|
12
|
+
// Add sortMetricData function
|
|
13
|
+
export const sortMetricData = (data, valueKey, sortOrder = 'desc') => {
|
|
14
|
+
return [...data].sort((a, b) => {
|
|
15
|
+
const aValue = Number(a[valueKey]) || 0;
|
|
16
|
+
const bValue = Number(b[valueKey]) || 0;
|
|
17
|
+
return sortOrder === 'asc' ? aValue - bValue : bValue - aValue;
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const constructMetricData = (baseData, queryConfig, isEmpty, loading, error, refreshFn, currency) => ({
|
|
21
|
+
value: baseData?.[queryConfig.valueKey] ?? 0,
|
|
22
|
+
previousValue: queryConfig.previousValueKey ? (baseData?.[queryConfig.previousValueKey] ?? 0) : undefined,
|
|
23
|
+
change: baseData?.[queryConfig.changeKey] ?? 0,
|
|
24
|
+
title: queryConfig.title,
|
|
25
|
+
format: queryConfig.format,
|
|
26
|
+
isEmpty,
|
|
27
|
+
loading,
|
|
28
|
+
currency,
|
|
29
|
+
error,
|
|
30
|
+
refresh: () => {
|
|
31
|
+
refreshFn().catch(() => { });
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const HorizontalBarChart = ({ title, colorScheme = ['#60A5FA', '#93C5FD'], className = '', url = DashboardPaths.QUERY, tooltipValueFormat, query, sortOrder = 'desc', tooltipTitle = 'Value', tooltipUnit = '', tooltipAdditionalFields = [], currencyDisplaySymbol, metricDetailData, showDetailsModal = true, ...props }) => {
|
|
35
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
36
|
+
const { data: metricData = [], error, isEmpty, loading, refresh } = useChartData(url, query);
|
|
37
|
+
const statisticsUrl = metricDetailData?.statisticsUrl ?? DashboardPaths.METRICS;
|
|
38
|
+
const { data: fullMetricData = [], error: fullDataError, isEmpty: isfullMetricDataEmpty, loading: isLoadingFullMetricData, refresh: refreshFullMetricData, } = useChartData(url, {
|
|
39
|
+
...query,
|
|
40
|
+
limit: undefined,
|
|
41
|
+
});
|
|
42
|
+
const useStatisticData = (queryProps) => {
|
|
43
|
+
const { data, error, isEmpty, loading, refresh } = useChartData(statisticsUrl, {
|
|
44
|
+
...queryProps.query,
|
|
45
|
+
});
|
|
46
|
+
return { data, error, isEmpty, loading, refresh };
|
|
47
|
+
};
|
|
48
|
+
const { data: itemStatData, error: itemStatDataError, isEmpty: isitemStatMetricDataEmpty, loading: isLoadingItemStatlMetricData, refresh: refreshItemStatMetricData, } = useStatisticData(metricDetailData.itemStatisticsQuery);
|
|
49
|
+
const { data: valueStatData, error: valueStatDataError, isEmpty: isValueStatMetricDataEmpty, loading: isLoadingValueStatlMetricData, refresh: refreshValueStatMetricData, } = useStatisticData(metricDetailData.valueMetricsQuery);
|
|
50
|
+
const { data: averageStatData, error: averageStatDataError, isEmpty: isAverageStatMetricDataEmpty, loading: isLoadingAverageStatlMetricData, refresh: refreshAverageStatMetricData, } = useStatisticData(metricDetailData.averageMetricsQuery);
|
|
51
|
+
const { data: distributionStatData, error: distributionStatDataError, isEmpty: isDistributionStatMetricDataEmpty, loading: isLoadingDistributionStatlMetricData, refresh: refreshDistributionStatMetricData, } = useChartData(url, {
|
|
52
|
+
...metricDetailData.distributionMetricsQuery.query,
|
|
53
|
+
});
|
|
54
|
+
const sortedMetricData = useMemo(() => sortMetricData(metricData, metricDetailData.valueKey, sortOrder), [metricData, metricDetailData.valueKey, sortOrder]);
|
|
55
|
+
const sortedFullMetricData = useMemo(() => sortMetricData(fullMetricData, metricDetailData.valueKey, sortOrder), [fullMetricData, metricDetailData.valueKey, sortOrder]);
|
|
56
|
+
const { processedTooltipFields, tooltipFormatterFn } = useTooltipFormatter(tooltipValueFormat, tooltipTitle, tooltipUnit, tooltipAdditionalFields, metricData, currencyDisplaySymbol);
|
|
57
|
+
const processedDistributionTooltipFields = useMemo(() => processTooltipFields(metricDetailData.distributionChartTooltip.tooltipAdditionalFields), [metricDetailData.distributionChartTooltip.tooltipAdditionalFields]);
|
|
58
|
+
const createChartOptions = useCallback((data, title, colorScheme, metricDetailData, tooltipConfig) => {
|
|
59
|
+
const currency = data?.[0]?.currency;
|
|
60
|
+
const formatterFn = tooltipConfig
|
|
61
|
+
? createTooltipFormatter(tooltipValueFormat, tooltipConfig.tooltipTitle ?? tooltipTitle, tooltipConfig.tooltipUnit ?? tooltipUnit, tooltipConfig.tooltipFields ?? processedTooltipFields, tooltipConfig.data ?? data, currency, currencyDisplaySymbol)
|
|
62
|
+
: tooltipFormatterFn;
|
|
63
|
+
return getChartBarOptions({
|
|
64
|
+
title,
|
|
65
|
+
colorScheme,
|
|
66
|
+
yAxisDataNameKey: metricDetailData.yAxisDataNameKey,
|
|
67
|
+
xAxisNameKey: metricDetailData.xAxisNameKey,
|
|
68
|
+
xAxisLabel: metricDetailData.xAxisLabel,
|
|
69
|
+
yAxisLabel: metricDetailData.yAxisLabel,
|
|
70
|
+
chartToolTip: {
|
|
71
|
+
...metricDetailData.chartToolTip,
|
|
72
|
+
formatter: formatterFn,
|
|
73
|
+
},
|
|
74
|
+
data,
|
|
75
|
+
});
|
|
76
|
+
}, [tooltipFormatterFn, tooltipTitle, tooltipUnit, processedTooltipFields]);
|
|
77
|
+
const createChartOptionsWithData = useCallback((data, tooltipConfig) => createChartOptions(data, title, colorScheme, metricDetailData, tooltipConfig), [title, colorScheme, metricDetailData, createChartOptions]);
|
|
78
|
+
const chartBarOptions = useMemo(() => createChartOptionsWithData(sortedMetricData), [sortedMetricData, createChartOptionsWithData]);
|
|
79
|
+
const fullChartOptions = useMemo(() => createChartOptionsWithData(sortedFullMetricData), [sortedFullMetricData, createChartOptionsWithData]);
|
|
80
|
+
const { topFiveItems, bottomFiveItems } = useMemo(() => {
|
|
81
|
+
if (!sortedFullMetricData.length) {
|
|
82
|
+
return {
|
|
83
|
+
topFiveItems: [],
|
|
84
|
+
bottomFiveItems: [],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const topFiveMetric = sortedFullMetricData.slice(0, 5);
|
|
88
|
+
const bottomFiveMetric = sortedFullMetricData.slice(-5).reverse();
|
|
89
|
+
return {
|
|
90
|
+
topFiveItems: createChartOptionsWithData(topFiveMetric, {
|
|
91
|
+
tooltipTitle: metricDetailData.topFiveChartTitle,
|
|
92
|
+
tooltipUnit,
|
|
93
|
+
tooltipFields: processedTooltipFields,
|
|
94
|
+
data: topFiveMetric,
|
|
95
|
+
}),
|
|
96
|
+
bottomFiveItems: createChartOptionsWithData(bottomFiveMetric, {
|
|
97
|
+
tooltipTitle: metricDetailData.bottomFiveChartTitle,
|
|
98
|
+
tooltipUnit,
|
|
99
|
+
tooltipFields: processedTooltipFields,
|
|
100
|
+
data: bottomFiveMetric,
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
}, [sortedFullMetricData, createChartOptionsWithData, tooltipUnit, processedTooltipFields]);
|
|
104
|
+
const distributionMetricData = useMemo(() => {
|
|
105
|
+
return createDistributionMetricOptions({
|
|
106
|
+
distributionChartTooltip: metricDetailData.distributionChartTooltip,
|
|
107
|
+
distributionData: distributionStatData ?? [],
|
|
108
|
+
processedTooltipFields: processedDistributionTooltipFields,
|
|
109
|
+
xAxisDataValueKey: metricDetailData.distributionMetricsQuery.xAxisDataValueKey,
|
|
110
|
+
seriesDataValueKey: metricDetailData.distributionMetricsQuery.seriesDataValueKey,
|
|
111
|
+
});
|
|
112
|
+
}, [
|
|
113
|
+
distributionStatData,
|
|
114
|
+
metricDetailData.distributionMetricsQuery.seriesDataValueKey,
|
|
115
|
+
metricDetailData.distributionMetricsQuery.xAxisDataValueKey,
|
|
116
|
+
metricDetailData.distributionChartTooltip,
|
|
117
|
+
processedDistributionTooltipFields,
|
|
118
|
+
]);
|
|
119
|
+
return (_jsxs(_Fragment, { children: [_jsx(Card, { title: title, ...props, onOpenDetails: metricData ? () => setIsModalOpen(true) : undefined, children: _jsx(ChartWrapper, { loading: loading, error: error, isEmpty: isEmpty, onRetry: refresh, children: _jsx("div", { className: "mt-[19px]", children: _jsx(ReactECharts, { option: chartBarOptions, style: { height: '100%', minHeight: '300px' }, className: "h-[300px] md:h-[400px]", opts: { renderer: 'canvas' }, notMerge: true }) }) }) }), showDetailsModal && (_jsx(ChartDetailsModalWrapper, { metricDetailData: metricDetailData, isModalOpen: isModalOpen, setIsModalOpen: setIsModalOpen, fullData: fullMetricData, columns: metricDetailData.dataGridColumns, error: fullDataError, isEmpty: isfullMetricDataEmpty, loading: isLoadingFullMetricData, detailsTableTitle: metricDetailData.detailsTableTitle, refresh: refreshFullMetricData, renderDetailsChart: fullMetricData.length <= 40, chartData: fullChartOptions, top5PerformingItems: topFiveItems, bottom5NonPerformingItems: bottomFiveItems, valueKey: metricDetailData.valueKey, dataGridQuery: query, searchKey: metricDetailData.dataGridSearchKey, searchInputPlaceHolder: metricDetailData.dataSearchInputPlaceHolder, itemMetricsData: constructMetricData(itemStatData, metricDetailData.itemStatisticsQuery, isitemStatMetricDataEmpty, isLoadingItemStatlMetricData, itemStatDataError, refreshItemStatMetricData, itemStatData?.additionalData?.currency ?? undefined), valueMetricsData: constructMetricData(valueStatData, metricDetailData.valueMetricsQuery, isValueStatMetricDataEmpty, isLoadingValueStatlMetricData, valueStatDataError, refreshValueStatMetricData, valueStatData?.additionalData?.currency ?? undefined), averageMetricsData: constructMetricData(averageStatData, metricDetailData.averageMetricsQuery, isAverageStatMetricDataEmpty, isLoadingAverageStatlMetricData, averageStatDataError, refreshAverageStatMetricData, averageStatData?.additionalData?.currency ?? undefined), distributionMetricsData: {
|
|
120
|
+
data: distributionMetricData ?? [],
|
|
121
|
+
title: metricDetailData.distributionMetricsQuery.title,
|
|
122
|
+
isEmpty: isDistributionStatMetricDataEmpty,
|
|
123
|
+
loading: isLoadingDistributionStatlMetricData,
|
|
124
|
+
error: distributionStatDataError,
|
|
125
|
+
refresh: () => {
|
|
126
|
+
refreshDistributionStatMetricData().catch(() => { });
|
|
127
|
+
},
|
|
128
|
+
chartToolTip: metricDetailData.distributionMetricsQuery.chartToolTip,
|
|
129
|
+
}, topFivePerformingChartTitle: metricDetailData.topFiveChartTitle, bottomFivePerformingChartTitle: metricDetailData.bottomFiveChartTitle }))] }));
|
|
130
|
+
};
|
|
131
|
+
export default HorizontalBarChart;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { QueryProps } from 'src/shared/types';
|
|
2
|
+
import type { ChartToolTipProps, DistributionQueryProps, StatisticsQueryProps, TableColumn } from '../types';
|
|
3
|
+
interface ItemPerformanceCardProps<TData extends {
|
|
4
|
+
id: string | number;
|
|
5
|
+
}> {
|
|
6
|
+
title?: string;
|
|
7
|
+
query: QueryProps;
|
|
8
|
+
url?: string;
|
|
9
|
+
itemNameKey: string;
|
|
10
|
+
amountValueKey: string;
|
|
11
|
+
unitsValueKey: string;
|
|
12
|
+
metricDetailData?: {
|
|
13
|
+
statisticsUrl?: string;
|
|
14
|
+
itemStatisticsQuery: StatisticsQueryProps;
|
|
15
|
+
valueMetricsQuery: StatisticsQueryProps;
|
|
16
|
+
averageMetricsQuery: StatisticsQueryProps;
|
|
17
|
+
distributionMetricsQuery: DistributionQueryProps;
|
|
18
|
+
nameKey: string;
|
|
19
|
+
valueKey: string;
|
|
20
|
+
dataGridSearchKey: string;
|
|
21
|
+
dataGridColumns: TableColumn<TData>[];
|
|
22
|
+
dataSearchInputPlaceHolder: string;
|
|
23
|
+
chartToolTip?: ChartToolTipProps;
|
|
24
|
+
detailsTableTitle?: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
declare const ItemPerformanceCard: <TData extends {
|
|
28
|
+
id: string | number;
|
|
29
|
+
}>({ title, query, url, itemNameKey, amountValueKey, unitsValueKey, metricDetailData, }: ItemPerformanceCardProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export default ItemPerformanceCard;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Card from '../components/CardWrapper';
|
|
3
|
+
import ChartWrapper from '../components/ChartWrapper';
|
|
4
|
+
import { useChartData } from '../hooks/useChartData';
|
|
5
|
+
import { DashboardPaths } from '../utils';
|
|
6
|
+
// Format number with thousands separator
|
|
7
|
+
const formatNumber = (num) => {
|
|
8
|
+
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
9
|
+
};
|
|
10
|
+
// Format currency in ZAR
|
|
11
|
+
const formatCurrency = (amount) => {
|
|
12
|
+
return `R ${formatNumber(amount)}`;
|
|
13
|
+
};
|
|
14
|
+
const ItemPerformanceCard = ({ title, query, url = DashboardPaths.QUERY, itemNameKey, amountValueKey, unitsValueKey, metricDetailData, }) => {
|
|
15
|
+
const { data: metricData = [], error, isEmpty, loading, refresh } = useChartData(url, query);
|
|
16
|
+
const getRankBackground = (rank) => {
|
|
17
|
+
if (rank === 1)
|
|
18
|
+
return 'bg-core-add';
|
|
19
|
+
if (rank === 2)
|
|
20
|
+
return 'bg-blue-400';
|
|
21
|
+
return 'bg-amber-600';
|
|
22
|
+
};
|
|
23
|
+
return (_jsx(Card, { title: title, children: _jsx(ChartWrapper, { loading: loading, error: error, isEmpty: isEmpty, onRetry: refresh, children: _jsx("div", { className: "mt-[19px]", children: _jsx("div", { className: "space-y-4", children: metricData.map((item, index) => {
|
|
24
|
+
const itemIndex = index + 1;
|
|
25
|
+
return (_jsxs("div", { className: "flex flex-col sm:flex-row items-start sm:items-center gap-4 p-4 hover:bg-gray-50 rounded-lg transition-colors duration-200", children: [_jsx("div", { className: "flex-shrink-0", children: _jsx("span", { className: `
|
|
26
|
+
w-8 h-8 rounded-full flex items-center justify-center text-white font-semibold
|
|
27
|
+
${getRankBackground(itemIndex)}
|
|
28
|
+
`, children: itemIndex }) }), _jsxs("div", { className: "flex-grow", children: [_jsx("h3", { className: "font-medium text-gray-900 mb-1", children: item[itemNameKey] }), _jsxs("div", { className: "flex justify-between text-sm", children: [_jsxs("div", { className: "text-gray-600", children: ["Revenue:", ' ', _jsx("span", { className: "font-semibold text-gray-900", children: formatCurrency(item[amountValueKey]) })] }), _jsxs("div", { className: "text-gray-600", children: ["Units: ", _jsx("span", { className: "font-semibold text-gray-900", children: formatNumber(item[unitsValueKey]) })] })] })] })] }, item.name));
|
|
29
|
+
}) }) }) }) }));
|
|
30
|
+
};
|
|
31
|
+
export default ItemPerformanceCard;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { QueryProps } from 'src/shared/types';
|
|
2
|
+
import type { ChartToolTipProps, DistributionChartTooltip, DistributionQueryProps, StatisticsQueryProps, TableColumn, TooltipField } from '../types';
|
|
3
|
+
interface LineChartProps<TData extends {
|
|
4
|
+
id: string | number;
|
|
5
|
+
}> {
|
|
6
|
+
data: any;
|
|
7
|
+
title?: string;
|
|
8
|
+
colors?: string[];
|
|
9
|
+
url?: string;
|
|
10
|
+
xAxisLabel?: string;
|
|
11
|
+
yAxisLabel?: string;
|
|
12
|
+
chartDetails?: {
|
|
13
|
+
columns?: any[];
|
|
14
|
+
data?: any[];
|
|
15
|
+
};
|
|
16
|
+
query: QueryProps;
|
|
17
|
+
seriesDataNameKey: string;
|
|
18
|
+
seriesDataValueKey: string;
|
|
19
|
+
xAxisDataValueKey: string;
|
|
20
|
+
chartToolTip: ChartToolTipProps;
|
|
21
|
+
tooltipValueFormat: string;
|
|
22
|
+
tooltipTitle?: string;
|
|
23
|
+
tooltipUnit?: string;
|
|
24
|
+
tooltipAdditionalFields?: (string | TooltipField)[];
|
|
25
|
+
currencyDisplaySymbol?: string;
|
|
26
|
+
smooth?: boolean;
|
|
27
|
+
metricDetailData: {
|
|
28
|
+
statisticsUrl?: string;
|
|
29
|
+
title: string;
|
|
30
|
+
itemStatisticsQuery: StatisticsQueryProps;
|
|
31
|
+
valueMetricsQuery: StatisticsQueryProps;
|
|
32
|
+
averageMetricsQuery: StatisticsQueryProps;
|
|
33
|
+
distributionMetricsQuery: DistributionQueryProps;
|
|
34
|
+
yAxisDataNameKey: string;
|
|
35
|
+
xAxisNameKey: string;
|
|
36
|
+
xAxisLabel: string;
|
|
37
|
+
yAxisLabel: string;
|
|
38
|
+
nameKey: string;
|
|
39
|
+
valueKey: string;
|
|
40
|
+
dataGridSearchKey: string;
|
|
41
|
+
dataGridColumns: TableColumn<TData>[];
|
|
42
|
+
dataSearchInputPlaceHolder: string;
|
|
43
|
+
detailsTableTitle?: string;
|
|
44
|
+
chartToolTip?: ChartToolTipProps;
|
|
45
|
+
topFiveChartTitle?: string;
|
|
46
|
+
bottomFiveChartTitle?: string;
|
|
47
|
+
distributionChartTooltip: DistributionChartTooltip;
|
|
48
|
+
};
|
|
49
|
+
showDetailsModal?: boolean;
|
|
50
|
+
yAxisLabelFormatter?: (value: number) => string;
|
|
51
|
+
xAxisLabelFormatter?: (label: string) => string;
|
|
52
|
+
}
|
|
53
|
+
declare const LineChart: <TData extends {
|
|
54
|
+
id: string | number;
|
|
55
|
+
}>({ query, data, title, xAxisLabel, yAxisLabel, url, tooltipValueFormat, xAxisDataValueKey, seriesDataNameKey, seriesDataValueKey, tooltipTitle, tooltipUnit, tooltipAdditionalFields, smooth, metricDetailData, showDetailsModal, yAxisLabelFormatter, xAxisLabelFormatter, ...props }: LineChartProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export default LineChart;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import BaseChart from '../components/BaseChart';
|
|
5
|
+
import ChartFormatter from '../components/ChartFormatter';
|
|
6
|
+
import { DashboardPaths, defaultColors } from '../utils';
|
|
7
|
+
const LineChart = ({ query, data, title, xAxisLabel, yAxisLabel, url = DashboardPaths.QUERY, tooltipValueFormat, xAxisDataValueKey, seriesDataNameKey, seriesDataValueKey, tooltipTitle = 'Value', tooltipUnit = '', tooltipAdditionalFields = [], smooth = false, metricDetailData, showDetailsModal = true, yAxisLabelFormatter, xAxisLabelFormatter, ...props }) => {
|
|
8
|
+
const createChartOptions = useCallback(() => {
|
|
9
|
+
return {
|
|
10
|
+
tooltip: {
|
|
11
|
+
trigger: 'item',
|
|
12
|
+
axisPointer: { type: 'shadow' },
|
|
13
|
+
backgroundColor: '#fff',
|
|
14
|
+
borderColor: '#ddd',
|
|
15
|
+
textStyle: {
|
|
16
|
+
color: '#333',
|
|
17
|
+
},
|
|
18
|
+
formatter: Function,
|
|
19
|
+
extraCssText: 'box-shadow: 0 2px 8px rgba(0,0,0,0.1);',
|
|
20
|
+
...props.chartToolTip,
|
|
21
|
+
},
|
|
22
|
+
xAxis: {
|
|
23
|
+
type: 'category',
|
|
24
|
+
name: xAxisLabel,
|
|
25
|
+
nameLocation: 'middle',
|
|
26
|
+
nameGap: 30,
|
|
27
|
+
nameTextStyle: {
|
|
28
|
+
color: '#666',
|
|
29
|
+
fontSize: 12,
|
|
30
|
+
fontWeight: 'bold',
|
|
31
|
+
},
|
|
32
|
+
axisLabel: {
|
|
33
|
+
formatter: xAxisLabelFormatter ||
|
|
34
|
+
((value) => {
|
|
35
|
+
const date = dayjs(value);
|
|
36
|
+
return date.format('MMM DD HH:mm');
|
|
37
|
+
}),
|
|
38
|
+
rotate: 45,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
yAxis: {
|
|
42
|
+
type: 'value',
|
|
43
|
+
name: yAxisLabel,
|
|
44
|
+
nameLocation: 'middle',
|
|
45
|
+
nameGap: 35,
|
|
46
|
+
nameTextStyle: {
|
|
47
|
+
color: '#666',
|
|
48
|
+
fontSize: 12,
|
|
49
|
+
fontWeight: 'bold',
|
|
50
|
+
},
|
|
51
|
+
...(yAxisLabelFormatter && {
|
|
52
|
+
axisLabel: {
|
|
53
|
+
formatter: yAxisLabelFormatter,
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
color: props.colors ?? defaultColors[0],
|
|
58
|
+
};
|
|
59
|
+
}, [props.chartToolTip, props.colors, xAxisLabel, yAxisLabel, yAxisLabelFormatter, xAxisLabelFormatter]);
|
|
60
|
+
const getSymbolConfig = useCallback(() => {
|
|
61
|
+
return {
|
|
62
|
+
color: props.colors?.[0],
|
|
63
|
+
borderColor: props.colors?.[0] ?? defaultColors[0],
|
|
64
|
+
};
|
|
65
|
+
}, [props.colors]);
|
|
66
|
+
const getChartOptions = useCallback(() => {
|
|
67
|
+
const chartOptions = createChartOptions();
|
|
68
|
+
return chartOptions;
|
|
69
|
+
}, [createChartOptions]);
|
|
70
|
+
return (_jsx(BaseChart, { title: title, detailsModalTitle: metricDetailData.title ?? '', url: url, query: query, chartDetails: props.chartDetails, itemStatisticsQuery: metricDetailData.itemStatisticsQuery, valueMetricsQuery: metricDetailData.valueMetricsQuery, averageMetricsQuery: metricDetailData.averageMetricsQuery, distributionMetricsQuery: metricDetailData.distributionMetricsQuery, yAxisDataNameKey: metricDetailData.yAxisDataNameKey, xAxisNameKey: metricDetailData.xAxisNameKey, xAxisLabel: metricDetailData.xAxisLabel, yAxisLabel: metricDetailData.yAxisLabel, nameKey: metricDetailData.nameKey, valueKey: metricDetailData.valueKey, dataGridSearchKey: metricDetailData.dataGridSearchKey, dataGridColumns: metricDetailData.dataGridColumns, dataSearchInputPlaceHolder: metricDetailData.dataSearchInputPlaceHolder, detailsTableTitle: metricDetailData.detailsTableTitle, getChartOptions: getChartOptions, distributionChartTooltip: metricDetailData.distributionChartTooltip, tooltipValueFormat: tooltipValueFormat, tooltipTitle: tooltipTitle, tooltipUnit: tooltipUnit, tooltipAdditionalFields: tooltipAdditionalFields, topFivePerformingChartTitle: metricDetailData.topFiveChartTitle, bottomFivePerformingChartTitle: metricDetailData.bottomFiveChartTitle, showDetailsModal: showDetailsModal, ...props, children: ({ metricData, tooltipFormatterFn }) => {
|
|
71
|
+
const chartOptions = createChartOptions();
|
|
72
|
+
// Add tooltip formatter from BaseChart
|
|
73
|
+
if (tooltipFormatterFn) {
|
|
74
|
+
chartOptions.tooltip.formatter = tooltipFormatterFn;
|
|
75
|
+
}
|
|
76
|
+
const symbolConfig = getSymbolConfig();
|
|
77
|
+
return (_jsx(ChartFormatter, { metricData: metricData, xAxisDataValueKey: xAxisDataValueKey, seriesDataNameKey: seriesDataNameKey, seriesDataValueKey: seriesDataValueKey, chartType: "line", chartOptions: chartOptions, smooth: smooth, symbolConfig: symbolConfig }));
|
|
78
|
+
} }));
|
|
79
|
+
};
|
|
80
|
+
export default LineChart;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { QueryProps } from 'src/shared/types';
|
|
2
|
+
import type { ChartToolTipProps, DistributionChartTooltip, DistributionQueryProps, StatisticsQueryProps, TableColumn, TooltipField } from '../types';
|
|
3
|
+
interface LineGraphProps<TData extends {
|
|
4
|
+
id: string | number;
|
|
5
|
+
}> {
|
|
6
|
+
title: string;
|
|
7
|
+
yAxisLabel: string;
|
|
8
|
+
xAxisLabel?: string;
|
|
9
|
+
color?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
xAxisDataKey: string;
|
|
12
|
+
yAxisDataKey: string;
|
|
13
|
+
categoryDataKey: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
query: QueryProps;
|
|
16
|
+
chartToolTip: ChartToolTipProps;
|
|
17
|
+
tooltipValueFormat: string;
|
|
18
|
+
tooltipTitle?: string;
|
|
19
|
+
tooltipUnit?: string;
|
|
20
|
+
seriesName?: string;
|
|
21
|
+
tooltipAdditionalFields?: (string | TooltipField)[];
|
|
22
|
+
yAxisLabelFormatter?: (value: number) => string;
|
|
23
|
+
metricDetailData: {
|
|
24
|
+
title: string;
|
|
25
|
+
statisticsUrl?: string;
|
|
26
|
+
itemStatisticsQuery: StatisticsQueryProps;
|
|
27
|
+
valueMetricsQuery: StatisticsQueryProps;
|
|
28
|
+
averageMetricsQuery: StatisticsQueryProps;
|
|
29
|
+
distributionMetricsQuery: DistributionQueryProps;
|
|
30
|
+
yAxisDataNameKey: string;
|
|
31
|
+
xAxisNameKey: string;
|
|
32
|
+
xAxisLabel: string;
|
|
33
|
+
yAxisLabel: string;
|
|
34
|
+
nameKey: string;
|
|
35
|
+
valueKey: string;
|
|
36
|
+
dataGridSearchKey: string;
|
|
37
|
+
dataGridColumns: TableColumn<TData>[];
|
|
38
|
+
dataSearchInputPlaceHolder: string;
|
|
39
|
+
detailsTableTitle?: string;
|
|
40
|
+
topFiveChartTitle: string;
|
|
41
|
+
bottomFiveChartTitle: string;
|
|
42
|
+
distributionChartTooltip: DistributionChartTooltip;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
declare const LineGraph: <TData extends {
|
|
46
|
+
id: string | number;
|
|
47
|
+
}>({ title, yAxisLabel, xAxisLabel, color, className, xAxisDataKey, yAxisDataKey, categoryDataKey, url, query, chartToolTip, tooltipValueFormat, tooltipTitle, tooltipUnit, tooltipAdditionalFields, yAxisLabelFormatter, metricDetailData, showDetailsModal, ...props }: LineGraphProps<TData> & {
|
|
48
|
+
showDetailsModal?: boolean;
|
|
49
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export default LineGraph;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import ReactECharts from 'echarts-for-react';
|
|
3
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
4
|
+
import Card from '../components/CardWrapper';
|
|
5
|
+
import ChartDetailsModal from '../components/ChartDetailsModal';
|
|
6
|
+
import ChartWrapper from '../components/ChartWrapper';
|
|
7
|
+
import { useChartData } from '../hooks/useChartData';
|
|
8
|
+
import { DashboardPaths } from '../utils';
|
|
9
|
+
import { createDistributionMetricOptions, getChartBarOptions, getLineGraphOptions } from '../utils/chartOptions';
|
|
10
|
+
import { createTooltipFormatter, processTooltipFields } from '../utils/tooltipUtils';
|
|
11
|
+
const LineGraph = ({ title, yAxisLabel, xAxisLabel, color = '#60A5FA', className = '', xAxisDataKey, yAxisDataKey, categoryDataKey, url = DashboardPaths.QUERY, query, chartToolTip, tooltipValueFormat, tooltipTitle = 'Value', tooltipUnit = '', tooltipAdditionalFields = [], yAxisLabelFormatter, metricDetailData, showDetailsModal = true, ...props }) => {
|
|
12
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
13
|
+
const { data: metricData = [], error, isEmpty, loading, refresh } = useChartData(url, query);
|
|
14
|
+
const processData = useCallback((data) => {
|
|
15
|
+
return data.map((item) => ({
|
|
16
|
+
name: item[xAxisDataKey],
|
|
17
|
+
value: item[yAxisDataKey],
|
|
18
|
+
category: item[categoryDataKey],
|
|
19
|
+
}));
|
|
20
|
+
}, [xAxisDataKey, yAxisDataKey, categoryDataKey]);
|
|
21
|
+
const processLineGraphData = (data) => {
|
|
22
|
+
const groupedData = {};
|
|
23
|
+
data.forEach((transaction) => {
|
|
24
|
+
const category = transaction[categoryDataKey] ?? props.seriesName ?? xAxisLabel;
|
|
25
|
+
if (!groupedData[category]) {
|
|
26
|
+
groupedData[category] = [];
|
|
27
|
+
}
|
|
28
|
+
groupedData[category].push({
|
|
29
|
+
date: transaction[xAxisDataKey],
|
|
30
|
+
value: transaction[yAxisDataKey],
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return Object.entries(groupedData).map(([name, data]) => ({
|
|
34
|
+
name,
|
|
35
|
+
data,
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
38
|
+
const statisticsUrl = metricDetailData?.statisticsUrl ?? DashboardPaths.METRICS;
|
|
39
|
+
const statisticsHooks = {
|
|
40
|
+
item: useChartData(statisticsUrl, {
|
|
41
|
+
...metricDetailData.itemStatisticsQuery.query,
|
|
42
|
+
}),
|
|
43
|
+
value: useChartData(statisticsUrl, {
|
|
44
|
+
...metricDetailData.valueMetricsQuery.query,
|
|
45
|
+
}),
|
|
46
|
+
average: useChartData(statisticsUrl, {
|
|
47
|
+
...metricDetailData.averageMetricsQuery.query,
|
|
48
|
+
}),
|
|
49
|
+
distribution: useChartData(url, {
|
|
50
|
+
...metricDetailData.distributionMetricsQuery.query,
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
const processedTooltipFields = useMemo(() => processTooltipFields(tooltipAdditionalFields), [tooltipAdditionalFields]);
|
|
54
|
+
const processedDistributionTooltipFields = useMemo(() => processTooltipFields(metricDetailData.distributionChartTooltip.tooltipAdditionalFields), [metricDetailData.distributionChartTooltip.tooltipAdditionalFields]);
|
|
55
|
+
const createTooltipConfig = useCallback((tooltipOverrides) => ({
|
|
56
|
+
tooltipTitle: tooltipOverrides?.tooltipTitle ?? tooltipTitle,
|
|
57
|
+
tooltipUnit: tooltipOverrides?.tooltipUnit ?? tooltipUnit,
|
|
58
|
+
tooltipFields: tooltipOverrides?.tooltipFields?.map((field) => ({
|
|
59
|
+
...field,
|
|
60
|
+
label: field.label ?? '',
|
|
61
|
+
toolTipkey: field.toolTipkey ?? '',
|
|
62
|
+
valueKey: field.valueKey ?? '',
|
|
63
|
+
nameKey: field.nameKey ?? '',
|
|
64
|
+
suffix: field.suffix ?? '',
|
|
65
|
+
format: field.format ?? 'number',
|
|
66
|
+
formatter: field.formatter ?? ((value) => String(value)),
|
|
67
|
+
})) ?? processedTooltipFields,
|
|
68
|
+
data: tooltipOverrides?.data,
|
|
69
|
+
}), [tooltipTitle, tooltipUnit, processedTooltipFields]);
|
|
70
|
+
const createChartOptions = useCallback((data, config) => {
|
|
71
|
+
const currency = data?.[0]?.currency;
|
|
72
|
+
const tooltipSettings = createTooltipConfig(config.tooltipConfig);
|
|
73
|
+
const formatterFn = createTooltipFormatter(tooltipValueFormat, tooltipSettings.tooltipTitle, tooltipSettings.tooltipUnit, tooltipSettings.tooltipFields, tooltipSettings.data ?? data, currency);
|
|
74
|
+
if (config.processLineGraphOptions) {
|
|
75
|
+
return getLineGraphOptions({
|
|
76
|
+
title: config.title,
|
|
77
|
+
yAxisLabel: yAxisLabel,
|
|
78
|
+
chartToolTip: {
|
|
79
|
+
...chartToolTip,
|
|
80
|
+
formatter: formatterFn,
|
|
81
|
+
},
|
|
82
|
+
data,
|
|
83
|
+
yAxisLabelFormatter,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return getChartBarOptions({
|
|
88
|
+
title: config.title,
|
|
89
|
+
yAxisDataNameKey: metricDetailData.yAxisDataNameKey,
|
|
90
|
+
xAxisNameKey: metricDetailData.xAxisNameKey,
|
|
91
|
+
xAxisLabel: metricDetailData.xAxisLabel,
|
|
92
|
+
yAxisLabel: metricDetailData.yAxisLabel,
|
|
93
|
+
chartToolTip: {
|
|
94
|
+
...chartToolTip,
|
|
95
|
+
formatter: formatterFn,
|
|
96
|
+
},
|
|
97
|
+
data,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}, [createTooltipConfig, tooltipValueFormat, color, metricDetailData, chartToolTip]);
|
|
101
|
+
const fullDataHook = useChartData(url, {
|
|
102
|
+
...query,
|
|
103
|
+
limit: undefined,
|
|
104
|
+
});
|
|
105
|
+
const lineChartSeriesData = useMemo(() => processLineGraphData(metricData ?? []), [metricData]);
|
|
106
|
+
const chartBarOptions = useMemo(() => createChartOptions(lineChartSeriesData, { title, processLineGraphOptions: true }), [metricData]);
|
|
107
|
+
const fullChartSeriesData = useMemo(() => processData(fullDataHook.data ?? []), [fullDataHook.data]);
|
|
108
|
+
const fullChartOptions = createChartOptions(fullChartSeriesData, { title, processLineGraphOptions: false });
|
|
109
|
+
const { topFiveItems, bottomFiveItems } = useMemo(() => {
|
|
110
|
+
if (!fullDataHook.data?.length) {
|
|
111
|
+
return {
|
|
112
|
+
topFiveItems: getChartBarOptions({
|
|
113
|
+
data: [],
|
|
114
|
+
title: metricDetailData.topFiveChartTitle,
|
|
115
|
+
yAxisDataNameKey: metricDetailData.xAxisNameKey,
|
|
116
|
+
xAxisNameKey: metricDetailData.yAxisDataNameKey,
|
|
117
|
+
xAxisLabel: metricDetailData.yAxisLabel,
|
|
118
|
+
yAxisLabel: metricDetailData.xAxisLabel,
|
|
119
|
+
chartToolTip,
|
|
120
|
+
}),
|
|
121
|
+
bottomFiveItems: getChartBarOptions({
|
|
122
|
+
data: [],
|
|
123
|
+
title: metricDetailData.bottomFiveChartTitle,
|
|
124
|
+
yAxisDataNameKey: metricDetailData.xAxisNameKey,
|
|
125
|
+
xAxisNameKey: metricDetailData.yAxisDataNameKey,
|
|
126
|
+
xAxisLabel: metricDetailData.yAxisLabel,
|
|
127
|
+
yAxisLabel: metricDetailData.xAxisLabel,
|
|
128
|
+
chartToolTip,
|
|
129
|
+
}),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const topFiveMetric = fullDataHook.data.slice(0, 5);
|
|
133
|
+
const bottomFiveMetric = fullDataHook.data.slice(-5).reverse();
|
|
134
|
+
return {
|
|
135
|
+
topFiveItems: createChartOptions(topFiveMetric, {
|
|
136
|
+
title: metricDetailData.topFiveChartTitle,
|
|
137
|
+
tooltipConfig: { tooltipTitle: metricDetailData.topFiveChartTitle },
|
|
138
|
+
processLineGraphOptions: false,
|
|
139
|
+
}),
|
|
140
|
+
bottomFiveItems: createChartOptions(bottomFiveMetric, {
|
|
141
|
+
title: metricDetailData.bottomFiveChartTitle,
|
|
142
|
+
tooltipConfig: { tooltipTitle: metricDetailData.bottomFiveChartTitle },
|
|
143
|
+
processLineGraphOptions: false,
|
|
144
|
+
}),
|
|
145
|
+
};
|
|
146
|
+
}, [fullDataHook, createChartOptions, metricDetailData, processData, color, chartToolTip]);
|
|
147
|
+
const distributionMetricData = useMemo(() => {
|
|
148
|
+
return createDistributionMetricOptions({
|
|
149
|
+
distributionChartTooltip: metricDetailData.distributionChartTooltip,
|
|
150
|
+
distributionData: statisticsHooks.distribution.data ?? [],
|
|
151
|
+
processedTooltipFields: processedDistributionTooltipFields,
|
|
152
|
+
xAxisDataValueKey: metricDetailData.distributionMetricsQuery.xAxisDataValueKey,
|
|
153
|
+
seriesDataValueKey: metricDetailData.distributionMetricsQuery.seriesDataValueKey,
|
|
154
|
+
});
|
|
155
|
+
}, [
|
|
156
|
+
statisticsHooks.distribution.data,
|
|
157
|
+
metricDetailData.distributionMetricsQuery.seriesDataValueKey,
|
|
158
|
+
metricDetailData.distributionMetricsQuery.xAxisDataValueKey,
|
|
159
|
+
metricDetailData.distributionChartTooltip,
|
|
160
|
+
processedDistributionTooltipFields,
|
|
161
|
+
]);
|
|
162
|
+
const createMetricsData = useCallback((hook, query) => ({
|
|
163
|
+
value: hook.data?.[query.valueKey] ?? 0,
|
|
164
|
+
previousValue: query.previousValueKey ? (hook.data?.[query.previousValueKey] ?? 0) : undefined,
|
|
165
|
+
change: hook.data?.[query.changeKey] ?? 0,
|
|
166
|
+
title: query.title,
|
|
167
|
+
format: query.format,
|
|
168
|
+
isEmpty: hook.isEmpty,
|
|
169
|
+
loading: hook.loading,
|
|
170
|
+
error: hook.error,
|
|
171
|
+
currency: hook.data?.additionalData?.currency,
|
|
172
|
+
refresh: () => hook.refresh().catch(() => { }),
|
|
173
|
+
}), []);
|
|
174
|
+
const metricsData = useMemo(() => ({
|
|
175
|
+
item: createMetricsData(statisticsHooks.item, metricDetailData.itemStatisticsQuery),
|
|
176
|
+
value: createMetricsData(statisticsHooks.value, metricDetailData.valueMetricsQuery),
|
|
177
|
+
average: createMetricsData(statisticsHooks.average, metricDetailData.averageMetricsQuery),
|
|
178
|
+
}), [createMetricsData, statisticsHooks, metricDetailData]);
|
|
179
|
+
return (_jsxs(_Fragment, { children: [_jsx(Card, { title: title, ...props, onOpenDetails: metricData ? () => setIsModalOpen(true) : undefined, children: _jsx(ChartWrapper, { loading: loading, error: error, isEmpty: isEmpty, onRetry: refresh, children: _jsx("div", { className: "mt-[19px]", children: _jsx(ReactECharts, { option: chartBarOptions, style: { height: '350px' } }) }) }) }), showDetailsModal && (_jsx(ChartDetailsModal, { title: metricDetailData.title, isOpen: isModalOpen, onClose: () => setIsModalOpen(false), data: fullDataHook.data ?? [], columns: metricDetailData.dataGridColumns, error: fullDataHook.error, isEmpty: fullDataHook.isEmpty, loading: fullDataHook.loading, detailsTableTitle: metricDetailData.detailsTableTitle, refresh: fullDataHook.refresh, renderDetailsChart: fullDataHook.data ? fullDataHook.data.length <= 40 : false, chartData: fullChartOptions, top5PerformingItems: topFiveItems, bottom5NonPerformingItems: bottomFiveItems, valueKey: metricDetailData.valueKey, dataGridQuery: query, searchKey: metricDetailData.dataGridSearchKey, searchInputPlaceHolder: metricDetailData.dataSearchInputPlaceHolder, itemMetricsData: metricsData.item, valueMetricsData: metricsData.value, averageMetricsData: metricsData.average, distributionMetricsData: {
|
|
180
|
+
data: distributionMetricData ?? [],
|
|
181
|
+
title: metricDetailData.distributionMetricsQuery.title,
|
|
182
|
+
isEmpty: statisticsHooks.distribution.isEmpty,
|
|
183
|
+
loading: statisticsHooks.distribution.loading,
|
|
184
|
+
error: statisticsHooks.distribution.error,
|
|
185
|
+
refresh: () => statisticsHooks.distribution.refresh().catch(() => { }),
|
|
186
|
+
chartToolTip: metricDetailData.distributionMetricsQuery.chartToolTip,
|
|
187
|
+
} }))] }));
|
|
188
|
+
};
|
|
189
|
+
export default LineGraph;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ApiErrorResponse } from '../../api';
|
|
2
|
+
interface MetricSummaryCardProps {
|
|
3
|
+
title: string;
|
|
4
|
+
format: string;
|
|
5
|
+
value: number;
|
|
6
|
+
previousValue?: number;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
isEmpty: boolean;
|
|
9
|
+
currency?: string;
|
|
10
|
+
error?: ApiErrorResponse;
|
|
11
|
+
refresh: () => void;
|
|
12
|
+
}
|
|
13
|
+
declare const MetricSummaryCard: ({ title, format, value, previousValue, loading, isEmpty, currency, error, refresh, }: MetricSummaryCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default MetricSummaryCard;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Card from '../components/CardWrapper';
|
|
3
|
+
import ChartWrapper from '../components/ChartWrapper';
|
|
4
|
+
import { formatValue } from '../utils';
|
|
5
|
+
const MetricSummaryCard = ({ title, format, value, previousValue, loading, isEmpty, currency, error, refresh, }) => {
|
|
6
|
+
return (_jsx(Card, { title: title, children: _jsx(ChartWrapper, { loading: loading, error: error, isEmpty: isEmpty, onRetry: refresh, children: _jsx("div", { className: "flex justify-between", style: { height: '50px' }, children: _jsxs("div", { children: [_jsx("div", { className: "text-xl font-400", children: formatValue(value, format, { currency, locale: 'en-US' }) }), previousValue !== undefined && (_jsxs("div", { className: "text-gray-400 text-sm", children: ["Prev: ", formatValue(previousValue, format, { currency, locale: 'en-US' })] }))] }) }) }) }));
|
|
7
|
+
};
|
|
8
|
+
export default MetricSummaryCard;
|