@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,115 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Generic Login Page component that works with different authentication configurations.
|
|
4
|
+
* Provides a customizable login interface with support for different branding and text options.
|
|
5
|
+
*
|
|
6
|
+
* @template T - Type extending CustomAuthConfig that defines the shape of authentication data
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* // Usage with Pagamio configuration
|
|
11
|
+
* <PagamioLoginPage<PagamioAuthConfig>
|
|
12
|
+
* logo={{
|
|
13
|
+
* src: "/logo.svg",
|
|
14
|
+
* alt: "Company Logo",
|
|
15
|
+
* width: 280,
|
|
16
|
+
* height: 250
|
|
17
|
+
* }}
|
|
18
|
+
* onLoginSuccess={(response) => {
|
|
19
|
+
* // Handle successful login
|
|
20
|
+
* }}
|
|
21
|
+
* />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import { useRef, useState } from 'react';
|
|
25
|
+
import { useToast } from '../../context';
|
|
26
|
+
import { FormEngine } from '../../form-engine';
|
|
27
|
+
import { AuthenticatorFactory } from '../authenticators';
|
|
28
|
+
import { useAuth } from '../context';
|
|
29
|
+
import { createFormSubmissionHandler } from './AuthFormUtils';
|
|
30
|
+
import { AuthPageLayout } from './AuthPageLayout';
|
|
31
|
+
export const loginPageDefaultText = {
|
|
32
|
+
welcomeTitle: 'Welcome Back!',
|
|
33
|
+
welcomeSubtitle: 'Sign in to your account to continue',
|
|
34
|
+
usernameLabel: 'Username',
|
|
35
|
+
passwordLabel: 'Password',
|
|
36
|
+
rememberMeLabel: 'Remember me',
|
|
37
|
+
loginButtonLabel: 'Login',
|
|
38
|
+
loadingButtonLabel: 'Logging in...',
|
|
39
|
+
forgotPasswordLabel: 'Forgot Password?',
|
|
40
|
+
createAccountLabel: 'Create Account',
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Generic Login Page component
|
|
44
|
+
* @template T - Authentication configuration type
|
|
45
|
+
*/
|
|
46
|
+
export function PagamioLoginPage({ logo, text = loginPageDefaultText, appLabel, onForgotPassword, onLoginSuccess, onLoginError, hasCreateAccount = false, createAccountRoute, onCreateAccount, transformLoginData, authenticatorType, className = '', }) {
|
|
47
|
+
const { login, error: authError } = useAuth();
|
|
48
|
+
const { addToast } = useToast();
|
|
49
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
50
|
+
const [error, setError] = useState(null);
|
|
51
|
+
const formRef = useRef();
|
|
52
|
+
const loginFields = [
|
|
53
|
+
{
|
|
54
|
+
name: 'username',
|
|
55
|
+
label: text.usernameLabel,
|
|
56
|
+
type: 'text',
|
|
57
|
+
placeholder: 'Enter username',
|
|
58
|
+
gridSpan: 12,
|
|
59
|
+
validation: {
|
|
60
|
+
required: 'Username is required',
|
|
61
|
+
validate: (value) => !/\s/.test(value) || 'Username should not contain spaces',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'password',
|
|
66
|
+
label: text.passwordLabel,
|
|
67
|
+
type: 'password',
|
|
68
|
+
placeholder: 'Enter password',
|
|
69
|
+
gridSpan: 12,
|
|
70
|
+
validation: {
|
|
71
|
+
required: 'Password is required',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'rememberMe',
|
|
76
|
+
label: text.rememberMeLabel,
|
|
77
|
+
type: 'checkbox',
|
|
78
|
+
gridSpan: 12,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
const handleSubmit = createFormSubmissionHandler({
|
|
82
|
+
setIsLoading,
|
|
83
|
+
setError,
|
|
84
|
+
addToast,
|
|
85
|
+
formRef,
|
|
86
|
+
onSuccess: (response) => onLoginSuccess?.(response),
|
|
87
|
+
onError: onLoginError,
|
|
88
|
+
}, async (data) => {
|
|
89
|
+
// Get the appropriate authenticator processor from the factory
|
|
90
|
+
const authenticator = AuthenticatorFactory.getProcessor(authenticatorType);
|
|
91
|
+
// Prepare credentials data
|
|
92
|
+
let credentials;
|
|
93
|
+
if (transformLoginData) {
|
|
94
|
+
// Use the custom transform function if provided
|
|
95
|
+
credentials = transformLoginData(data);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// Default behavior - extract username and password
|
|
99
|
+
const { username, password } = data;
|
|
100
|
+
credentials = { username, password };
|
|
101
|
+
}
|
|
102
|
+
// Process the login with the selected authenticator
|
|
103
|
+
return authenticator.processLogin(credentials, data.rememberMe ?? false, login);
|
|
104
|
+
}, 'Logged in successfully', 'Login failed. Please check your credentials and try again.');
|
|
105
|
+
const handleCreateAccount = () => {
|
|
106
|
+
if (onCreateAccount) {
|
|
107
|
+
onCreateAccount();
|
|
108
|
+
}
|
|
109
|
+
else if (createAccountRoute) {
|
|
110
|
+
window.location.href = createAccountRoute;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return (_jsx(AuthPageLayout, { appLabel: appLabel, title: text.welcomeTitle, subtitle: text.welcomeSubtitle, errorMessage: error ?? authError?.message, logo: logo, className: className, horizontal: false, children: _jsxs("div", { className: "mt-8", children: [_jsx(FormEngine, { fields: loginFields, onSubmit: handleSubmit, layout: "vertical", className: "mb-0 px-0", submitButtonClass: "w-full", submitButtonText: isLoading ? text.loadingButtonLabel : text.loginButtonLabel, onCancel: () => { }, showCancelButton: false, showSubmittingText: false, formRef: formRef }), _jsxs("div", { className: "flex items-center justify-center gap-x-4 mt-4", children: [onForgotPassword && (_jsx("button", { type: "button", onClick: onForgotPassword, className: "text-sm text-primary-500 hover:underline dark:text-primary-500", children: text.forgotPasswordLabel })), hasCreateAccount && (_jsxs(_Fragment, { children: [onForgotPassword && _jsx("span", { className: "text-gray-500", children: "|" }), _jsx("button", { type: "button", onClick: handleCreateAccount, className: "text-sm text-primary-500 hover:underline dark:text-primary-500", children: text.createAccountLabel })] }))] })] }) }));
|
|
114
|
+
}
|
|
115
|
+
export default PagamioLoginPage;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for LogoutButton component
|
|
3
|
+
*/
|
|
4
|
+
interface LogoutButtonProps {
|
|
5
|
+
/** Additional class names to apply to the button */
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Button variant from the UI component library */
|
|
8
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
9
|
+
/** Callback function called after successful logout */
|
|
10
|
+
onLogoutSuccess?: () => void;
|
|
11
|
+
/** Callback function called when logout fails */
|
|
12
|
+
onLogoutError?: (error: Error) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* LogoutButton Component
|
|
16
|
+
*
|
|
17
|
+
* A reusable button component that handles user logout with loading state
|
|
18
|
+
* and error handling.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <LogoutButton
|
|
23
|
+
* variant="destructive"
|
|
24
|
+
* onLogoutSuccess={() => navigate('/login')}
|
|
25
|
+
* onLogoutError={(error) => console.error('Logout failed:', error)}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare const LogoutButton: ({ className, variant, onLogoutSuccess, onLogoutError }: LogoutButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export default LogoutButton;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Reusable logout button component with loading state
|
|
4
|
+
* and callback handlers
|
|
5
|
+
*/
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import { Button } from '../../components';
|
|
8
|
+
import { cn } from '../../helpers';
|
|
9
|
+
import { useAuth } from '../context';
|
|
10
|
+
/**
|
|
11
|
+
* LogoutButton Component
|
|
12
|
+
*
|
|
13
|
+
* A reusable button component that handles user logout with loading state
|
|
14
|
+
* and error handling.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <LogoutButton
|
|
19
|
+
* variant="destructive"
|
|
20
|
+
* onLogoutSuccess={() => navigate('/login')}
|
|
21
|
+
* onLogoutError={(error) => console.error('Logout failed:', error)}
|
|
22
|
+
* />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const LogoutButton = ({ className = '', variant = 'default', onLogoutSuccess, onLogoutError }) => {
|
|
26
|
+
const { logout } = useAuth();
|
|
27
|
+
const [isLoggingOut, setIsLoggingOut] = useState(false);
|
|
28
|
+
const handleLogout = async () => {
|
|
29
|
+
if (isLoggingOut)
|
|
30
|
+
return; // Prevent multiple clicks
|
|
31
|
+
setIsLoggingOut(true);
|
|
32
|
+
try {
|
|
33
|
+
await logout();
|
|
34
|
+
onLogoutSuccess?.();
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const logoutError = error instanceof Error ? error : new Error('Logout failed');
|
|
38
|
+
console.error('Logout failed:', logoutError);
|
|
39
|
+
onLogoutError?.(logoutError);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
setIsLoggingOut(false);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return (_jsx(Button, { onClick: handleLogout, disabled: isLoggingOut, variant: variant, className: cn('mt-4', className), children: isLoggingOut ? 'Logging out...' : 'Logout' }));
|
|
46
|
+
};
|
|
47
|
+
export default LogoutButton;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CustomAuthConfig } from '../types';
|
|
2
|
+
import type { BaseAuthPageProps } from './AuthFormUtils';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the PagamioResetPasswordPage component
|
|
5
|
+
* @template T - Authentication configuration type
|
|
6
|
+
*/
|
|
7
|
+
interface PagamioResetPasswordPageProps<T extends CustomAuthConfig> extends BaseAuthPageProps {
|
|
8
|
+
/** Reset token from URL or other source */
|
|
9
|
+
token: string;
|
|
10
|
+
/** Customizable text content */
|
|
11
|
+
text?: {
|
|
12
|
+
title: string;
|
|
13
|
+
subtitle: string;
|
|
14
|
+
passwordLabel: string;
|
|
15
|
+
confirmPasswordLabel: string;
|
|
16
|
+
submitButtonLabel: string;
|
|
17
|
+
loadingButtonLabel: string;
|
|
18
|
+
backToLoginLabel: string;
|
|
19
|
+
successMessage: string;
|
|
20
|
+
};
|
|
21
|
+
/** Callback handlers */
|
|
22
|
+
onSuccess?: () => void;
|
|
23
|
+
onError?: (error: Error) => void;
|
|
24
|
+
onBackToLogin?: () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare const resetPasswordDefaultText: {
|
|
27
|
+
title: string;
|
|
28
|
+
subtitle: string;
|
|
29
|
+
passwordLabel: string;
|
|
30
|
+
confirmPasswordLabel: string;
|
|
31
|
+
submitButtonLabel: string;
|
|
32
|
+
loadingButtonLabel: string;
|
|
33
|
+
backToLoginLabel: string;
|
|
34
|
+
successMessage: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Generic Reset Password Page component
|
|
38
|
+
* @template T - Authentication configuration type
|
|
39
|
+
*/
|
|
40
|
+
export declare function PagamioResetPasswordPage<T extends CustomAuthConfig>({ logo, text, appLabel, token, onSuccess, onError, onBackToLogin, className, }: Readonly<PagamioResetPasswordPageProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export default PagamioResetPasswordPage;
|
|
42
|
+
export type { PagamioResetPasswordPageProps };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Generic Reset Password Page component that works with different authentication configurations.
|
|
4
|
+
* Provides a customizable interface for users to reset their password after receiving a reset token.
|
|
5
|
+
*
|
|
6
|
+
* @template T - Type extending CustomAuthConfig that defines the shape of authentication data
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* // Usage with Pagamio configuration
|
|
11
|
+
* <PagamioResetPasswordPage<PagamioAuthConfig>
|
|
12
|
+
* logo={{
|
|
13
|
+
* src: "/logo.svg",
|
|
14
|
+
* alt: "Company Logo",
|
|
15
|
+
* width: 280,
|
|
16
|
+
* height: 250
|
|
17
|
+
* }}
|
|
18
|
+
* token="reset-token-from-url"
|
|
19
|
+
* onSuccess={() => {
|
|
20
|
+
* // Handle successful password reset
|
|
21
|
+
* }}
|
|
22
|
+
* />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import { useRef, useState } from 'react';
|
|
26
|
+
import { useToast } from '../../context';
|
|
27
|
+
import { FormEngine } from '../../form-engine';
|
|
28
|
+
import { useAuth } from '../context';
|
|
29
|
+
import { BackToLoginButton, createFormSubmissionHandler, passwordValidation } from './AuthFormUtils';
|
|
30
|
+
import { AuthPageLayout } from './AuthPageLayout';
|
|
31
|
+
export const resetPasswordDefaultText = {
|
|
32
|
+
title: 'Reset Your Password',
|
|
33
|
+
subtitle: 'Enter your new password to regain access to your account.',
|
|
34
|
+
passwordLabel: 'New Password',
|
|
35
|
+
confirmPasswordLabel: 'Confirm New Password',
|
|
36
|
+
submitButtonLabel: 'Reset Password',
|
|
37
|
+
loadingButtonLabel: 'Resetting...',
|
|
38
|
+
backToLoginLabel: 'Back to Login',
|
|
39
|
+
successMessage: 'Password has been reset successfully.',
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Generic Reset Password Page component
|
|
43
|
+
* @template T - Authentication configuration type
|
|
44
|
+
*/
|
|
45
|
+
export function PagamioResetPasswordPage({ logo, text = resetPasswordDefaultText, appLabel, token, onSuccess, onError, onBackToLogin, className = '', }) {
|
|
46
|
+
const { authService } = useAuth();
|
|
47
|
+
const { addToast } = useToast();
|
|
48
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
49
|
+
const [error, setError] = useState(null);
|
|
50
|
+
const formRef = useRef();
|
|
51
|
+
const resetPasswordFields = [
|
|
52
|
+
{
|
|
53
|
+
name: 'password',
|
|
54
|
+
label: text.passwordLabel,
|
|
55
|
+
type: 'password',
|
|
56
|
+
placeholder: 'Enter new password',
|
|
57
|
+
gridSpan: 12,
|
|
58
|
+
validation: passwordValidation,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'confirmPassword',
|
|
62
|
+
label: text.confirmPasswordLabel,
|
|
63
|
+
type: 'password',
|
|
64
|
+
placeholder: 'Confirm new password',
|
|
65
|
+
gridSpan: 12,
|
|
66
|
+
validation: {
|
|
67
|
+
required: 'Please confirm your password',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
const handleSubmit = createFormSubmissionHandler({
|
|
72
|
+
setIsLoading,
|
|
73
|
+
setError,
|
|
74
|
+
addToast,
|
|
75
|
+
formRef,
|
|
76
|
+
onSuccess,
|
|
77
|
+
onError,
|
|
78
|
+
}, async (data) => {
|
|
79
|
+
const { password, confirmPassword } = data;
|
|
80
|
+
await authService.resetPassword({
|
|
81
|
+
token,
|
|
82
|
+
newPassword: password,
|
|
83
|
+
newPasswordConfirm: confirmPassword,
|
|
84
|
+
});
|
|
85
|
+
}, text.successMessage, 'Reset password failed. Please try again.');
|
|
86
|
+
return (_jsx(AuthPageLayout, { appLabel: appLabel, title: text.title, subtitle: text.subtitle, errorMessage: error, logo: logo, className: className, horizontal: false, children: _jsxs("div", { className: "mt-8", children: [_jsx(FormEngine, { fields: resetPasswordFields, onSubmit: handleSubmit, layout: "vertical", className: "mb-0 p-0", submitButtonClass: "w-full", submitButtonText: isLoading ? text.loadingButtonLabel : text.submitButtonLabel, onCancel: () => { }, showCancelButton: false, showSubmittingText: false, formRef: formRef }), onBackToLogin && _jsx(BackToLoginButton, { onBackToLogin: onBackToLogin, label: text.backToLoginLabel })] }) }));
|
|
87
|
+
}
|
|
88
|
+
export default PagamioResetPasswordPage;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface PostDataProps {
|
|
2
|
+
oldPassword: string;
|
|
3
|
+
newPassword: string;
|
|
4
|
+
confirmationPassword: string;
|
|
5
|
+
}
|
|
6
|
+
interface UseChangeUserPasswordProps {
|
|
7
|
+
onSuccess: () => void;
|
|
8
|
+
onError: (error: Error) => void;
|
|
9
|
+
handleUpdatePassword: (data: PostDataProps) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
declare const useChangeUserPassword: ({ onSuccess, onError, handleUpdatePassword }: UseChangeUserPasswordProps) => {
|
|
12
|
+
form: {
|
|
13
|
+
passwordMatchError: string | null;
|
|
14
|
+
showTextFieldError: boolean;
|
|
15
|
+
oldPassword: string;
|
|
16
|
+
newPassword: string;
|
|
17
|
+
confirmationPassword: string;
|
|
18
|
+
setOldPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
19
|
+
setNewPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
20
|
+
setConfirmationPassword: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
21
|
+
};
|
|
22
|
+
isLoading: boolean;
|
|
23
|
+
error: string | null;
|
|
24
|
+
handleSubmit: (e: React.FormEvent) => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
export default useChangeUserPassword;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { useAuth } from '../../context';
|
|
3
|
+
const useChangeUserPassword = ({ onSuccess, onError, handleUpdatePassword }) => {
|
|
4
|
+
const { logout } = useAuth();
|
|
5
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
6
|
+
const [error, setError] = useState(null);
|
|
7
|
+
const [oldPassword, setOldPassword] = useState('');
|
|
8
|
+
const [newPassword, setNewPassword] = useState('');
|
|
9
|
+
const [showTextFieldError, setShowTextFieldError] = useState(false);
|
|
10
|
+
const [passwordMatchError, setPasswordMatchError] = useState(null);
|
|
11
|
+
const [confirmationPassword, setConfirmationPassword] = useState('');
|
|
12
|
+
const handleResetFields = () => {
|
|
13
|
+
setOldPassword('');
|
|
14
|
+
setNewPassword('');
|
|
15
|
+
setConfirmationPassword('');
|
|
16
|
+
};
|
|
17
|
+
const handleSubmit = async (e) => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
setError(null);
|
|
20
|
+
setPasswordMatchError(null);
|
|
21
|
+
setShowTextFieldError(false);
|
|
22
|
+
if (newPassword !== confirmationPassword) {
|
|
23
|
+
setShowTextFieldError(true);
|
|
24
|
+
setPasswordMatchError('New password and confirm password do not match.');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const postData = {
|
|
28
|
+
oldPassword,
|
|
29
|
+
newPassword,
|
|
30
|
+
confirmationPassword,
|
|
31
|
+
};
|
|
32
|
+
setIsLoading(true);
|
|
33
|
+
try {
|
|
34
|
+
await handleUpdatePassword(postData);
|
|
35
|
+
handleResetFields();
|
|
36
|
+
onSuccess();
|
|
37
|
+
logout();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
onError(error);
|
|
41
|
+
setError(error.message);
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
setIsLoading(false);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
form: {
|
|
49
|
+
passwordMatchError,
|
|
50
|
+
showTextFieldError,
|
|
51
|
+
oldPassword,
|
|
52
|
+
newPassword,
|
|
53
|
+
confirmationPassword,
|
|
54
|
+
setOldPassword,
|
|
55
|
+
setNewPassword,
|
|
56
|
+
setConfirmationPassword,
|
|
57
|
+
},
|
|
58
|
+
isLoading,
|
|
59
|
+
error,
|
|
60
|
+
handleSubmit,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export default useChangeUserPassword;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as LogoutButton } from './LogoutButton';
|
|
2
|
+
export { default as PagamioLoginPage, loginPageDefaultText, type PagamioLoginCredentials, type PagamioLoginPageProps, } from './LoginPage';
|
|
3
|
+
export { default as ChangePasswordPage, type ChangePasswordPageProps } from './ChangePasswordPage';
|
|
4
|
+
export { type PostDataProps } from './hooks/useChangeUserPassword';
|
|
5
|
+
export { default as PagamioCustomerRegistrationPage, customerRegistrationPageDefaultText, type PagamioCustomerRegistrationPageProps, } from './CustomerRegistrationPage';
|
|
6
|
+
export { default as PagamioForgotPasswordPage, forgotPasswordDefaultText, type PagamioForgotPasswordPageProps, } from './ForgotPasswordPage';
|
|
7
|
+
export { default as PagamioResetPasswordPage, resetPasswordDefaultText, type PagamioResetPasswordPageProps, } from './ResetPasswordPage';
|
|
8
|
+
export { AuthPageLayout as PagamioAuthPageLayout } from './AuthPageLayout';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as LogoutButton } from './LogoutButton';
|
|
2
|
+
export { default as PagamioLoginPage, loginPageDefaultText, } from './LoginPage';
|
|
3
|
+
export { default as ChangePasswordPage } from './ChangePasswordPage';
|
|
4
|
+
export { default as PagamioCustomerRegistrationPage, customerRegistrationPageDefaultText, } from './CustomerRegistrationPage';
|
|
5
|
+
export { default as PagamioForgotPasswordPage, forgotPasswordDefaultText, } from './ForgotPasswordPage';
|
|
6
|
+
export { default as PagamioResetPasswordPage, resetPasswordDefaultText, } from './ResetPasswordPage';
|
|
7
|
+
export { AuthPageLayout as PagamioAuthPageLayout } from './AuthPageLayout';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type AuthService } from '../services';
|
|
3
|
+
import type { AuthResponse, CustomAuthConfig } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Base auth configuration interface that can be extended
|
|
6
|
+
*/
|
|
7
|
+
export interface AppAuthConfig extends CustomAuthConfig {
|
|
8
|
+
UserInfo: {
|
|
9
|
+
id: string | number;
|
|
10
|
+
userName: string;
|
|
11
|
+
roles: string[];
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
TokenInfo: {
|
|
15
|
+
token: string;
|
|
16
|
+
expiresIn: number;
|
|
17
|
+
};
|
|
18
|
+
Credentials: {
|
|
19
|
+
username: string;
|
|
20
|
+
password: string;
|
|
21
|
+
};
|
|
22
|
+
Error: {
|
|
23
|
+
code: string;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Authentication context state with generic type parameter
|
|
29
|
+
*/
|
|
30
|
+
type AuthContextState<T extends AppAuthConfig> = {
|
|
31
|
+
user: T['UserInfo'] | null;
|
|
32
|
+
isAuthenticated: boolean;
|
|
33
|
+
isLoading: boolean;
|
|
34
|
+
error: T['Error'] | null;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Authentication context actions with generic type parameter
|
|
38
|
+
*/
|
|
39
|
+
interface AuthContextActions<T extends AppAuthConfig> {
|
|
40
|
+
login: (response: T['Credentials'], rememberMe?: boolean) => Promise<AuthResponse<T>>;
|
|
41
|
+
logout: () => Promise<void>;
|
|
42
|
+
updateUser: (userData: Partial<T['UserInfo']>) => void;
|
|
43
|
+
clearError: () => void;
|
|
44
|
+
}
|
|
45
|
+
type AuthContextValue<T extends AppAuthConfig> = AuthContextState<T> & AuthContextActions<T> & {
|
|
46
|
+
authService: AuthService<T>;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Authentication context with generic type parameter
|
|
50
|
+
*/
|
|
51
|
+
export declare const AuthContext: React.Context<AuthContextValue<AppAuthConfig>>;
|
|
52
|
+
interface AuthProviderProps<T extends AppAuthConfig> {
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
authService: AuthService<T>;
|
|
55
|
+
validateOnInit?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Authentication context provider component with generic type parameter
|
|
59
|
+
*/
|
|
60
|
+
export declare function AuthProvider<T extends AppAuthConfig>({ children, authService, validateOnInit, }: Readonly<AuthProviderProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
61
|
+
/**
|
|
62
|
+
* Custom hook for using auth context with generic type parameter
|
|
63
|
+
*/
|
|
64
|
+
export declare function useAuth<T extends AppAuthConfig>(): AuthContextValue<T>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
function createInitialState() {
|
|
4
|
+
return {
|
|
5
|
+
user: null,
|
|
6
|
+
isAuthenticated: false,
|
|
7
|
+
isLoading: true,
|
|
8
|
+
error: null,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Authentication context with generic type parameter
|
|
13
|
+
*/
|
|
14
|
+
export const AuthContext = createContext({
|
|
15
|
+
...createInitialState(),
|
|
16
|
+
login: async () => {
|
|
17
|
+
return {};
|
|
18
|
+
},
|
|
19
|
+
logout: async () => { },
|
|
20
|
+
updateUser: () => { },
|
|
21
|
+
clearError: () => { },
|
|
22
|
+
authService: {},
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Authentication context provider component with generic type parameter
|
|
26
|
+
*/
|
|
27
|
+
export function AuthProvider({ children, authService, validateOnInit = false, }) {
|
|
28
|
+
const [state, setState] = useState(() => createInitialState());
|
|
29
|
+
const setPartialState = useCallback((newState) => {
|
|
30
|
+
setState((prev) => ({ ...prev, ...newState }));
|
|
31
|
+
}, []);
|
|
32
|
+
// Initialize auth state from service
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const initializeAuth = async () => {
|
|
35
|
+
try {
|
|
36
|
+
const user = authService.getUser();
|
|
37
|
+
if (!user) {
|
|
38
|
+
setPartialState({
|
|
39
|
+
isAuthenticated: false,
|
|
40
|
+
isLoading: false,
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (validateOnInit) {
|
|
45
|
+
const isValid = await authService.validateSession();
|
|
46
|
+
if (!isValid) {
|
|
47
|
+
await authService.logout();
|
|
48
|
+
setPartialState({
|
|
49
|
+
user: null,
|
|
50
|
+
isAuthenticated: false,
|
|
51
|
+
isLoading: false,
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
setPartialState({
|
|
57
|
+
user,
|
|
58
|
+
isAuthenticated: true,
|
|
59
|
+
isLoading: false,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
setPartialState({
|
|
64
|
+
error: {
|
|
65
|
+
code: 'AUTH_INIT_ERROR',
|
|
66
|
+
message: 'Failed to initialize authentication',
|
|
67
|
+
},
|
|
68
|
+
isLoading: false,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
initializeAuth().then();
|
|
73
|
+
}, [authService, setPartialState, validateOnInit]);
|
|
74
|
+
const login = useCallback(async (credentials, rememberMe = false) => {
|
|
75
|
+
try {
|
|
76
|
+
const response = await authService.login(credentials, rememberMe);
|
|
77
|
+
setPartialState({
|
|
78
|
+
user: response.user,
|
|
79
|
+
isAuthenticated: true,
|
|
80
|
+
error: null,
|
|
81
|
+
});
|
|
82
|
+
return response;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
setPartialState({
|
|
86
|
+
error: {
|
|
87
|
+
code: 'LOGIN_ERROR',
|
|
88
|
+
message: 'Failed to process login response',
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}, [authService, setPartialState]);
|
|
94
|
+
const logout = useCallback(async () => {
|
|
95
|
+
try {
|
|
96
|
+
await authService.logout();
|
|
97
|
+
setPartialState({
|
|
98
|
+
user: null,
|
|
99
|
+
isAuthenticated: false,
|
|
100
|
+
error: null,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
setPartialState({
|
|
105
|
+
error: {
|
|
106
|
+
code: 'LOGOUT_ERROR',
|
|
107
|
+
message: 'Failed to logout properly',
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}, [authService, setPartialState]);
|
|
112
|
+
const updateUser = useCallback(async (userData) => {
|
|
113
|
+
try {
|
|
114
|
+
const updatedUser = await authService.updateProfile(userData);
|
|
115
|
+
setPartialState({
|
|
116
|
+
user: updatedUser,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
setPartialState({
|
|
121
|
+
error: {
|
|
122
|
+
code: 'UPDATE_USER_ERROR',
|
|
123
|
+
message: 'Failed to update user profile',
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}, [authService, setPartialState]);
|
|
128
|
+
const clearError = useCallback(() => {
|
|
129
|
+
setPartialState({ error: null });
|
|
130
|
+
}, [setPartialState]);
|
|
131
|
+
const contextValue = useMemo(() => ({
|
|
132
|
+
...state,
|
|
133
|
+
authService,
|
|
134
|
+
login,
|
|
135
|
+
logout,
|
|
136
|
+
updateUser,
|
|
137
|
+
clearError,
|
|
138
|
+
}), [state, login, logout, updateUser, clearError, authService]);
|
|
139
|
+
return _jsx(AuthContext.Provider, { value: contextValue, children: children });
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Custom hook for using auth context with generic type parameter
|
|
143
|
+
*/
|
|
144
|
+
export function useAuth() {
|
|
145
|
+
const context = useContext(AuthContext);
|
|
146
|
+
if (!context) {
|
|
147
|
+
throw new Error('useAuth must be used within an AuthProvider');
|
|
148
|
+
}
|
|
149
|
+
return context;
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AuthContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AuthContext';
|