@greatapps/common 1.1.790 → 1.1.791
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/account/AccountHubLinkHandler.mjs +36 -0
- package/dist/components/account/AccountHubLinkHandler.mjs.map +1 -0
- package/dist/components/account/AccountModalLayout.mjs +137 -0
- package/dist/components/account/AccountModalLayout.mjs.map +1 -0
- package/dist/components/account/AccountModals.mjs +10 -3
- package/dist/components/account/AccountModals.mjs.map +1 -1
- package/dist/components/account/DeleteAccountModal.mjs +1 -1
- package/dist/components/account/DeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +8 -1
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/MyAccountModal.mjs +167 -0
- package/dist/components/account/MyAccountModal.mjs.map +1 -0
- package/dist/components/account/TwoFactorAuthModal.mjs +1 -1
- package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/hooks/useAccountHubActions.mjs +85 -0
- package/dist/components/account/hooks/useAccountHubActions.mjs.map +1 -0
- package/dist/components/account/hooks/useAddCardWithPaymentSwitch.mjs +44 -0
- package/dist/components/account/hooks/useAddCardWithPaymentSwitch.mjs.map +1 -0
- package/dist/components/account/hooks/useAffiliatesActions.mjs +69 -0
- package/dist/components/account/hooks/useAffiliatesActions.mjs.map +1 -0
- package/dist/components/account/hooks/useMyAccountModal.mjs +27 -0
- package/dist/components/account/hooks/useMyAccountModal.mjs.map +1 -0
- package/dist/components/account/hooks/useProjectsActions.mjs +40 -0
- package/dist/components/account/hooks/useProjectsActions.mjs.map +1 -0
- package/dist/components/account/hooks/useSubscriptionActions.mjs +87 -0
- package/dist/components/account/hooks/useSubscriptionActions.mjs.map +1 -0
- package/dist/components/account/hooks/useTeamActions.mjs +31 -0
- package/dist/components/account/hooks/useTeamActions.mjs.map +1 -0
- package/dist/components/account/sections/AffiliatesSection.mjs +313 -0
- package/dist/components/account/sections/AffiliatesSection.mjs.map +1 -0
- package/dist/components/account/sections/ChangePasswordSection.mjs +5 -5
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -1
- package/dist/components/account/sections/MyProfileSection.mjs +194 -144
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
- package/dist/components/account/sections/PreferencesSection.mjs +60 -49
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
- package/dist/components/account/sections/ProjectsSection.mjs +77 -0
- package/dist/components/account/sections/ProjectsSection.mjs.map +1 -0
- package/dist/components/account/sections/SecuritySection.mjs +55 -36
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -1
- package/dist/components/account/sections/SubscriptionSection.mjs +29 -0
- package/dist/components/account/sections/SubscriptionSection.mjs.map +1 -0
- package/dist/components/account/sections/TeamSection.mjs +119 -0
- package/dist/components/account/sections/TeamSection.mjs.map +1 -0
- package/dist/components/account/sections/TokenSection.mjs +41 -43
- package/dist/components/account/sections/TokenSection.mjs.map +1 -1
- package/dist/components/account/sections/affiliates/AffiliateCommissionCard.mjs +73 -0
- package/dist/components/account/sections/affiliates/AffiliateCommissionCard.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/AffiliateFlows.mjs +20 -0
- package/dist/components/account/sections/affiliates/AffiliateFlows.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/AffiliateLeadsSheet.mjs +99 -0
- package/dist/components/account/sections/affiliates/AffiliateLeadsSheet.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/AffiliateStatsCard.mjs +31 -0
- package/dist/components/account/sections/affiliates/AffiliateStatsCard.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/AffiliateStepCard.mjs +15 -0
- package/dist/components/account/sections/affiliates/AffiliateStepCard.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/AffiliateTransactionsList.mjs +108 -0
- package/dist/components/account/sections/affiliates/AffiliateTransactionsList.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/NoReceivingAccountModal.mjs +49 -0
- package/dist/components/account/sections/affiliates/NoReceivingAccountModal.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/ReceivingAccountModal.mjs +182 -0
- package/dist/components/account/sections/affiliates/ReceivingAccountModal.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/RequestWithdrawalSheet.mjs +476 -0
- package/dist/components/account/sections/affiliates/RequestWithdrawalSheet.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/ViewAttachmentModal.mjs +34 -0
- package/dist/components/account/sections/affiliates/ViewAttachmentModal.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/reports/AffiliatesIndicatorsChart.mjs +27 -0
- package/dist/components/account/sections/affiliates/reports/AffiliatesIndicatorsChart.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/reports/AffiliatesReportsTab.mjs +30 -0
- package/dist/components/account/sections/affiliates/reports/AffiliatesReportsTab.mjs.map +1 -0
- package/dist/components/account/sections/affiliates/reports/useAffiliatesIndicatorsChart.mjs +120 -0
- package/dist/components/account/sections/affiliates/reports/useAffiliatesIndicatorsChart.mjs.map +1 -0
- package/dist/components/account/sections/projects/DeleteProjectModal.mjs +205 -0
- package/dist/components/account/sections/projects/DeleteProjectModal.mjs.map +1 -0
- package/dist/components/account/sections/projects/ProjectFlows.mjs +16 -0
- package/dist/components/account/sections/projects/ProjectFlows.mjs.map +1 -0
- package/dist/components/account/sections/projects/ProjectMembersStack.mjs +53 -0
- package/dist/components/account/sections/projects/ProjectMembersStack.mjs.map +1 -0
- package/dist/components/account/sections/projects/ProjectRow.mjs +85 -0
- package/dist/components/account/sections/projects/ProjectRow.mjs.map +1 -0
- package/dist/components/account/sections/projects/ProjectSheet.mjs +499 -0
- package/dist/components/account/sections/projects/ProjectSheet.mjs.map +1 -0
- package/dist/components/account/sections/projects/ProjectsDisabledModal.mjs +55 -0
- package/dist/components/account/sections/projects/ProjectsDisabledModal.mjs.map +1 -0
- package/dist/components/account/sections/projects/project-form.schema.mjs +28 -0
- package/dist/components/account/sections/projects/project-form.schema.mjs.map +1 -0
- package/dist/components/account/sections/shared/ConnectListRow.mjs +45 -0
- package/dist/components/account/sections/shared/ConnectListRow.mjs.map +1 -0
- package/dist/components/account/sections/shared/DateFilterPopover.mjs +51 -0
- package/dist/components/account/sections/shared/DateFilterPopover.mjs.map +1 -0
- package/dist/components/account/sections/shared/EntityAvatar.mjs +41 -0
- package/dist/components/account/sections/shared/EntityAvatar.mjs.map +1 -0
- package/dist/components/account/sections/shared/FilterPopover.mjs +62 -0
- package/dist/components/account/sections/shared/FilterPopover.mjs.map +1 -0
- package/dist/components/account/sections/shared/FormSection.mjs +14 -0
- package/dist/components/account/sections/shared/FormSection.mjs.map +1 -0
- package/dist/components/account/sections/shared/IconBox.mjs +18 -0
- package/dist/components/account/sections/shared/IconBox.mjs.map +1 -0
- package/dist/components/account/sections/shared/InfiniteScrollList.mjs +36 -0
- package/dist/components/account/sections/shared/InfiniteScrollList.mjs.map +1 -0
- package/dist/components/account/sections/shared/ListPagination.mjs +69 -0
- package/dist/components/account/sections/shared/ListPagination.mjs.map +1 -0
- package/dist/components/account/sections/shared/RowActionsMenu.mjs +52 -0
- package/dist/components/account/sections/shared/RowActionsMenu.mjs.map +1 -0
- package/dist/components/account/sections/shared/SectionLoadError.mjs +20 -0
- package/dist/components/account/sections/shared/SectionLoadError.mjs.map +1 -0
- package/dist/components/account/sections/shared/StatusBadge.mjs +26 -0
- package/dist/components/account/sections/shared/StatusBadge.mjs.map +1 -0
- package/dist/components/account/sections/shared/WorkspaceSection.mjs +10 -0
- package/dist/components/account/sections/shared/WorkspaceSection.mjs.map +1 -0
- package/dist/components/account/sections/subscription/AiCreditsUsage.mjs +106 -0
- package/dist/components/account/sections/subscription/AiCreditsUsage.mjs.map +1 -0
- package/dist/components/account/sections/subscription/BillingAddressSheet.mjs +407 -0
- package/dist/components/account/sections/subscription/BillingAddressSheet.mjs.map +1 -0
- package/dist/components/account/sections/subscription/BoletoDetailsDialog.mjs +73 -0
- package/dist/components/account/sections/subscription/BoletoDetailsDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/BoletoGeneratedDialog.mjs +22 -0
- package/dist/components/account/sections/subscription/BoletoGeneratedDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/CancelPlanDialog.mjs +161 -0
- package/dist/components/account/sections/subscription/CancelPlanDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/ChargeRow.mjs +127 -0
- package/dist/components/account/sections/subscription/ChargeRow.mjs.map +1 -0
- package/dist/components/account/sections/subscription/ChargeStatusBadge.mjs +27 -0
- package/dist/components/account/sections/subscription/ChargeStatusBadge.mjs.map +1 -0
- package/dist/components/account/sections/subscription/ChargesList.mjs +88 -0
- package/dist/components/account/sections/subscription/ChargesList.mjs.map +1 -0
- package/dist/components/account/sections/subscription/ManageCardsSheet.mjs +49 -0
- package/dist/components/account/sections/subscription/ManageCardsSheet.mjs.map +1 -0
- package/dist/components/account/sections/subscription/OverdueReceiptOpener.mjs +26 -0
- package/dist/components/account/sections/subscription/OverdueReceiptOpener.mjs.map +1 -0
- package/dist/components/account/sections/subscription/PayChargeDialog.mjs +222 -0
- package/dist/components/account/sections/subscription/PayChargeDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/PaymentConfirmationDialog.mjs +61 -0
- package/dist/components/account/sections/subscription/PaymentConfirmationDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/PaymentMethodsCard.mjs +72 -0
- package/dist/components/account/sections/subscription/PaymentMethodsCard.mjs.map +1 -0
- package/dist/components/account/sections/subscription/PendingChangeDialog.mjs +117 -0
- package/dist/components/account/sections/subscription/PendingChangeDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/PixDetailsDialog.mjs +165 -0
- package/dist/components/account/sections/subscription/PixDetailsDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/PixPaymentDialog.mjs +155 -0
- package/dist/components/account/sections/subscription/PixPaymentDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/PlanDetailsSheet.mjs +253 -0
- package/dist/components/account/sections/subscription/PlanDetailsSheet.mjs.map +1 -0
- package/dist/components/account/sections/subscription/ReceiptDetailsSheet.mjs +237 -0
- package/dist/components/account/sections/subscription/ReceiptDetailsSheet.mjs.map +1 -0
- package/dist/components/account/sections/subscription/SubscriptionFlows.mjs +40 -0
- package/dist/components/account/sections/subscription/SubscriptionFlows.mjs.map +1 -0
- package/dist/components/account/sections/subscription/SubscriptionPlanCard.mjs +303 -0
- package/dist/components/account/sections/subscription/SubscriptionPlanCard.mjs.map +1 -0
- package/dist/components/account/sections/subscription/UsageReportSheet.mjs +163 -0
- package/dist/components/account/sections/subscription/UsageReportSheet.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/ChangePlanSheet.mjs +75 -0
- package/dist/components/account/sections/subscription/change-plan/ChangePlanSheet.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/components/AbTestDetailsDialog.mjs +55 -0
- package/dist/components/account/sections/subscription/change-plan/components/AbTestDetailsDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/components/AddonsBlock.mjs +188 -0
- package/dist/components/account/sections/subscription/change-plan/components/AddonsBlock.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/components/AlternativeBucketsSection.mjs +66 -0
- package/dist/components/account/sections/subscription/change-plan/components/AlternativeBucketsSection.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/components/CouponBlock.mjs +42 -0
- package/dist/components/account/sections/subscription/change-plan/components/CouponBlock.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/components/CouponDialog.mjs +119 -0
- package/dist/components/account/sections/subscription/change-plan/components/CouponDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/components/PricePreview.mjs +17 -0
- package/dist/components/account/sections/subscription/change-plan/components/PricePreview.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/components/SummaryBlock.mjs +130 -0
- package/dist/components/account/sections/subscription/change-plan/components/SummaryBlock.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/plan-comparison.mjs +38 -0
- package/dist/components/account/sections/subscription/change-plan/plan-comparison.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/steps/PaymentSummaryStep.mjs +127 -0
- package/dist/components/account/sections/subscription/change-plan/steps/PaymentSummaryStep.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/steps/PlanComparisonStep.mjs +111 -0
- package/dist/components/account/sections/subscription/change-plan/steps/PlanComparisonStep.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/steps/PlanViewStep.mjs +69 -0
- package/dist/components/account/sections/subscription/change-plan/steps/PlanViewStep.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/steps/ReactivationConfigStep.mjs +88 -0
- package/dist/components/account/sections/subscription/change-plan/steps/ReactivationConfigStep.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/steps/ReactivationPaymentStep.mjs +115 -0
- package/dist/components/account/sections/subscription/change-plan/steps/ReactivationPaymentStep.mjs.map +1 -0
- package/dist/components/account/sections/subscription/change-plan/useChangePlanState.mjs +918 -0
- package/dist/components/account/sections/subscription/change-plan/useChangePlanState.mjs.map +1 -0
- package/dist/components/account/sections/subscription/downgrade/CannotDowngradeDialog.mjs +216 -0
- package/dist/components/account/sections/subscription/downgrade/CannotDowngradeDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/downgrade/DowngradeReasonDialog.mjs +128 -0
- package/dist/components/account/sections/subscription/downgrade/DowngradeReasonDialog.mjs.map +1 -0
- package/dist/components/account/sections/subscription/plans/PlanCard.mjs +281 -0
- package/dist/components/account/sections/subscription/plans/PlanCard.mjs.map +1 -0
- package/dist/components/account/sections/subscription/plans/PlanCardSkeleton.mjs +53 -0
- package/dist/components/account/sections/subscription/plans/PlanCardSkeleton.mjs.map +1 -0
- package/dist/components/account/sections/subscription/plans/PlansCatalogDialog.mjs +119 -0
- package/dist/components/account/sections/subscription/plans/PlansCatalogDialog.mjs.map +1 -0
- package/dist/components/account/sections/team/DeleteUserModal.mjs +116 -0
- package/dist/components/account/sections/team/DeleteUserModal.mjs.map +1 -0
- package/dist/components/account/sections/team/TeamFlows.mjs +14 -0
- package/dist/components/account/sections/team/TeamFlows.mjs.map +1 -0
- package/dist/components/account/sections/team/TeamMemberRow.mjs +99 -0
- package/dist/components/account/sections/team/TeamMemberRow.mjs.map +1 -0
- package/dist/components/account/sections/team/UserSheet.mjs +570 -0
- package/dist/components/account/sections/team/UserSheet.mjs.map +1 -0
- package/dist/components/account/sections/team/steps/NotificationsStep.mjs +80 -0
- package/dist/components/account/sections/team/steps/NotificationsStep.mjs.map +1 -0
- package/dist/components/account/sections/team/steps/ProjectSelectionStep.mjs +180 -0
- package/dist/components/account/sections/team/steps/ProjectSelectionStep.mjs.map +1 -0
- package/dist/components/account/sections/team/steps/UserInformationStep.mjs +371 -0
- package/dist/components/account/sections/team/steps/UserInformationStep.mjs.map +1 -0
- package/dist/components/account/sections/team/user-form.schema.mjs +37 -0
- package/dist/components/account/sections/team/user-form.schema.mjs.map +1 -0
- package/dist/components/account/types/workspace-actions.type.mjs +1 -0
- package/dist/components/account/types/workspace-actions.type.mjs.map +1 -0
- package/dist/components/layouts/ProfilePopover.mjs +10 -12
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -1
- package/dist/components/layouts/UsersSelectorPopover.mjs +7 -4
- package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -1
- package/dist/components/modals/AccountDeletionWarningModal.mjs +4 -5
- package/dist/components/modals/AccountDeletionWarningModal.mjs.map +1 -1
- package/dist/components/modals/AccountFrozenModal.mjs +6 -3
- package/dist/components/modals/AccountFrozenModal.mjs.map +1 -1
- package/dist/components/modals/Modals.mjs +3 -3
- package/dist/components/modals/Modals.mjs.map +1 -1
- package/dist/components/modals/PaidPlanRequiredModal.mjs +4 -5
- package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -1
- package/dist/components/modals/cards/AddFirstCardWarningModal.mjs +63 -0
- package/dist/components/modals/cards/AddFirstCardWarningModal.mjs.map +1 -0
- package/dist/components/modals/cards/SwitchPaymentToCardModal.mjs +187 -0
- package/dist/components/modals/cards/SwitchPaymentToCardModal.mjs.map +1 -0
- package/dist/components/modals/promo/AiCreditsOfferModal/AiCreditsOfferModal.mjs +5 -4
- package/dist/components/modals/promo/AiCreditsOfferModal/AiCreditsOfferModal.mjs.map +1 -1
- package/dist/components/ui/data-display/CardItem.mjs +9 -1
- package/dist/components/ui/data-display/CardItem.mjs.map +1 -1
- package/dist/components/ui/data-display/PaymentMethodIcons.mjs +50 -0
- package/dist/components/ui/data-display/PaymentMethodIcons.mjs.map +1 -0
- package/dist/components/ui/form/BillingPeriodSelector.mjs +108 -0
- package/dist/components/ui/form/BillingPeriodSelector.mjs.map +1 -0
- package/dist/components/ui/form/PaymentMethodToggle.mjs +82 -0
- package/dist/components/ui/form/PaymentMethodToggle.mjs.map +1 -0
- package/dist/components/ui/form/RadioOptionFieldIcon.mjs +57 -0
- package/dist/components/ui/form/RadioOptionFieldIcon.mjs.map +1 -0
- package/dist/components/ui/form/SegmentedControl.mjs +56 -0
- package/dist/components/ui/form/SegmentedControl.mjs.map +1 -0
- package/dist/components/ui/overlay/Dialog.mjs +21 -4
- package/dist/components/ui/overlay/Dialog.mjs.map +1 -1
- package/dist/components/ui/overlay/Sheet.mjs +26 -8
- package/dist/components/ui/overlay/Sheet.mjs.map +1 -1
- package/dist/components/ui/overlay/layers.mjs +52 -5
- package/dist/components/ui/overlay/layers.mjs.map +1 -1
- package/dist/enums/AccountHubFlow.mjs +13 -0
- package/dist/enums/AccountHubFlow.mjs.map +1 -0
- package/dist/enums/DateFilterPeriod.mjs +22 -0
- package/dist/enums/DateFilterPeriod.mjs.map +1 -0
- package/dist/enums/WorkspaceSectionType.mjs +11 -0
- package/dist/enums/WorkspaceSectionType.mjs.map +1 -0
- package/dist/handlers.mjs +24 -0
- package/dist/handlers.mjs.map +1 -1
- package/dist/hooks/useDebounce.mjs +5 -3
- package/dist/hooks/useDebounce.mjs.map +1 -1
- package/dist/hooks/useUploadProgress.mjs +33 -0
- package/dist/hooks/useUploadProgress.mjs.map +1 -0
- package/dist/i18n/messages/en-us.mjs +863 -3
- package/dist/i18n/messages/en-us.mjs.map +1 -1
- package/dist/i18n/messages/es-es.mjs +863 -3
- package/dist/i18n/messages/es-es.mjs.map +1 -1
- package/dist/i18n/messages/pt-br.mjs +863 -3
- package/dist/i18n/messages/pt-br.mjs.map +1 -1
- package/dist/index.mjs +87 -7
- package/dist/index.mjs.map +1 -1
- package/dist/infra/http/paged.mjs +20 -0
- package/dist/infra/http/paged.mjs.map +1 -0
- package/dist/middleware.mjs +2 -0
- package/dist/middleware.mjs.map +1 -1
- package/dist/middlewares/create-auth-middleware.mjs +1 -3
- package/dist/middlewares/create-auth-middleware.mjs.map +1 -1
- package/dist/middlewares/create-legacy-account-routes-middleware.mjs +44 -0
- package/dist/middlewares/create-legacy-account-routes-middleware.mjs.map +1 -0
- package/dist/middlewares/is-route-equals.mjs +7 -0
- package/dist/middlewares/is-route-equals.mjs.map +1 -0
- package/dist/modules/accounts/actions/account-management.action.mjs +20 -1
- package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -1
- package/dist/modules/accounts/constants/account-hub-link.constants.mjs +9 -0
- package/dist/modules/accounts/constants/account-hub-link.constants.mjs.map +1 -0
- package/dist/modules/accounts/constants/legacy-account-routes.constants.mjs +5 -0
- package/dist/modules/accounts/constants/legacy-account-routes.constants.mjs.map +1 -0
- package/dist/modules/accounts/handlers/list-account-members.handler.mjs +22 -0
- package/dist/modules/accounts/handlers/list-account-members.handler.mjs.map +1 -0
- package/dist/modules/accounts/hooks/add-user-projects.hook.mjs +51 -0
- package/dist/modules/accounts/hooks/add-user-projects.hook.mjs.map +1 -0
- package/dist/modules/accounts/hooks/create-account-user.hook.mjs +20 -0
- package/dist/modules/accounts/hooks/create-account-user.hook.mjs.map +1 -0
- package/dist/modules/accounts/hooks/remove-user-projects.hook.mjs +47 -0
- package/dist/modules/accounts/hooks/remove-user-projects.hook.mjs.map +1 -0
- package/dist/modules/accounts/hooks/use-account-members.hook.mjs +20 -0
- package/dist/modules/accounts/hooks/use-account-members.hook.mjs.map +1 -0
- package/dist/modules/accounts/services/account.service.mjs +59 -0
- package/dist/modules/accounts/services/account.service.mjs.map +1 -1
- package/dist/modules/accounts/types/account-hub-link.type.mjs +1 -0
- package/dist/modules/accounts/types/account-hub-link.type.mjs.map +1 -0
- package/dist/modules/accounts/utils/build-account-hub-url.mjs +16 -0
- package/dist/modules/accounts/utils/build-account-hub-url.mjs.map +1 -0
- package/dist/modules/accounts/utils/is-account-hub-flow.mjs +9 -0
- package/dist/modules/accounts/utils/is-account-hub-flow.mjs.map +1 -0
- package/dist/modules/accounts/utils/is-account-section.mjs +9 -0
- package/dist/modules/accounts/utils/is-account-section.mjs.map +1 -0
- package/dist/modules/accounts/utils/is-my-account-section.mjs +13 -0
- package/dist/modules/accounts/utils/is-my-account-section.mjs.map +1 -0
- package/dist/modules/accounts/utils/map-legacy-account-route.mjs +93 -0
- package/dist/modules/accounts/utils/map-legacy-account-route.mjs.map +1 -0
- package/dist/modules/accounts/utils/parse-account-hub-link.mjs +20 -0
- package/dist/modules/accounts/utils/parse-account-hub-link.mjs.map +1 -0
- package/dist/modules/affiliates/actions/ensure-affiliate.action.mjs +10 -0
- package/dist/modules/affiliates/actions/ensure-affiliate.action.mjs.map +1 -0
- package/dist/modules/affiliates/actions/request-deposit.action.mjs +10 -0
- package/dist/modules/affiliates/actions/request-deposit.action.mjs.map +1 -0
- package/dist/modules/affiliates/actions/update-affiliate.action.mjs +10 -0
- package/dist/modules/affiliates/actions/update-affiliate.action.mjs.map +1 -0
- package/dist/modules/affiliates/constants/affiliate.constants.mjs +11 -0
- package/dist/modules/affiliates/constants/affiliate.constants.mjs.map +1 -0
- package/dist/modules/affiliates/constants/query-keys.constants.mjs +15 -0
- package/dist/modules/affiliates/constants/query-keys.constants.mjs.map +1 -0
- package/dist/modules/affiliates/handlers/affiliate-report-analytics.handler.mjs +16 -0
- package/dist/modules/affiliates/handlers/affiliate-report-analytics.handler.mjs.map +1 -0
- package/dist/modules/affiliates/handlers/affiliate-withdrawal-limits.handler.mjs +12 -0
- package/dist/modules/affiliates/handlers/affiliate-withdrawal-limits.handler.mjs.map +1 -0
- package/dist/modules/affiliates/handlers/current-affiliate.handler.mjs +12 -0
- package/dist/modules/affiliates/handlers/current-affiliate.handler.mjs.map +1 -0
- package/dist/modules/affiliates/handlers/list-affiliate-coupons.handler.mjs +12 -0
- package/dist/modules/affiliates/handlers/list-affiliate-coupons.handler.mjs.map +1 -0
- package/dist/modules/affiliates/handlers/list-affiliate-leads.handler.mjs +22 -0
- package/dist/modules/affiliates/handlers/list-affiliate-leads.handler.mjs.map +1 -0
- package/dist/modules/affiliates/handlers/list-affiliate-transactions.handler.mjs +22 -0
- package/dist/modules/affiliates/handlers/list-affiliate-transactions.handler.mjs.map +1 -0
- package/dist/modules/affiliates/hooks/use-affiliate-coupons.hook.mjs +17 -0
- package/dist/modules/affiliates/hooks/use-affiliate-coupons.hook.mjs.map +1 -0
- package/dist/modules/affiliates/hooks/use-affiliate-leads.hook.mjs +22 -0
- package/dist/modules/affiliates/hooks/use-affiliate-leads.hook.mjs.map +1 -0
- package/dist/modules/affiliates/hooks/use-affiliate-report-analytics.hook.mjs +17 -0
- package/dist/modules/affiliates/hooks/use-affiliate-report-analytics.hook.mjs.map +1 -0
- package/dist/modules/affiliates/hooks/use-affiliate-transactions.hook.mjs +20 -0
- package/dist/modules/affiliates/hooks/use-affiliate-transactions.hook.mjs.map +1 -0
- package/dist/modules/affiliates/hooks/use-current-affiliate.hook.mjs +17 -0
- package/dist/modules/affiliates/hooks/use-current-affiliate.hook.mjs.map +1 -0
- package/dist/modules/affiliates/hooks/use-ensure-affiliate.hook.mjs +23 -0
- package/dist/modules/affiliates/hooks/use-ensure-affiliate.hook.mjs.map +1 -0
- package/dist/modules/affiliates/hooks/use-request-deposit.hook.mjs +28 -0
- package/dist/modules/affiliates/hooks/use-request-deposit.hook.mjs.map +1 -0
- package/dist/modules/affiliates/hooks/use-update-affiliate.hook.mjs +22 -0
- package/dist/modules/affiliates/hooks/use-update-affiliate.hook.mjs.map +1 -0
- package/dist/modules/affiliates/hooks/use-withdrawal-limits.hook.mjs +17 -0
- package/dist/modules/affiliates/hooks/use-withdrawal-limits.hook.mjs.map +1 -0
- package/dist/modules/affiliates/services/affiliates.service.mjs +183 -0
- package/dist/modules/affiliates/services/affiliates.service.mjs.map +1 -0
- package/dist/modules/affiliates/types/affiliate.type.mjs +100 -0
- package/dist/modules/affiliates/types/affiliate.type.mjs.map +1 -0
- package/dist/modules/affiliates/utils/get-affiliate-share-link.mjs +9 -0
- package/dist/modules/affiliates/utils/get-affiliate-share-link.mjs.map +1 -0
- package/dist/modules/charges/actions/get-nota-fiscal.action.mjs +10 -0
- package/dist/modules/charges/actions/get-nota-fiscal.action.mjs.map +1 -0
- package/dist/modules/charges/actions/refresh-pix.action.mjs +10 -0
- package/dist/modules/charges/actions/refresh-pix.action.mjs.map +1 -0
- package/dist/modules/charges/hooks/nota-fiscal.hook.mjs +13 -0
- package/dist/modules/charges/hooks/nota-fiscal.hook.mjs.map +1 -0
- package/dist/modules/charges/hooks/refresh-pix.hook.mjs +13 -0
- package/dist/modules/charges/hooks/refresh-pix.hook.mjs.map +1 -0
- package/dist/modules/charges/services/charges.service.mjs +67 -0
- package/dist/modules/charges/services/charges.service.mjs.map +1 -1
- package/dist/modules/charges/types/nota-fiscal.type.mjs +1 -0
- package/dist/modules/charges/types/nota-fiscal.type.mjs.map +1 -0
- package/dist/modules/charges/types/refresh-pix.type.mjs +1 -0
- package/dist/modules/charges/types/refresh-pix.type.mjs.map +1 -0
- package/dist/modules/charges/utils/get-charge-download-url.mjs +8 -0
- package/dist/modules/charges/utils/get-charge-download-url.mjs.map +1 -0
- package/dist/modules/coupons/constants/query-keys.constants.mjs +5 -0
- package/dist/modules/coupons/constants/query-keys.constants.mjs.map +1 -0
- package/dist/modules/coupons/handlers/find-coupon-by-code.handler.mjs +17 -0
- package/dist/modules/coupons/handlers/find-coupon-by-code.handler.mjs.map +1 -0
- package/dist/modules/coupons/handlers/find-coupon-by-id.handler.mjs +16 -0
- package/dist/modules/coupons/handlers/find-coupon-by-id.handler.mjs.map +1 -0
- package/dist/modules/coupons/hooks/use-coupon-by-code.hook.mjs +15 -0
- package/dist/modules/coupons/hooks/use-coupon-by-code.hook.mjs.map +1 -0
- package/dist/modules/coupons/hooks/use-coupon-by-id.hook.mjs +18 -0
- package/dist/modules/coupons/hooks/use-coupon-by-id.hook.mjs.map +1 -0
- package/dist/modules/coupons/services/coupons.service.mjs +44 -0
- package/dist/modules/coupons/services/coupons.service.mjs.map +1 -0
- package/dist/modules/coupons/types/coupon.type.mjs +61 -0
- package/dist/modules/coupons/types/coupon.type.mjs.map +1 -0
- package/dist/modules/coupons/utils/coupon-restrictions.mjs +60 -0
- package/dist/modules/coupons/utils/coupon-restrictions.mjs.map +1 -0
- package/dist/modules/domains/handlers/count-domains.handler.mjs +12 -0
- package/dist/modules/domains/handlers/count-domains.handler.mjs.map +1 -0
- package/dist/modules/domains/hooks/count-domains.hook.mjs +17 -0
- package/dist/modules/domains/hooks/count-domains.hook.mjs.map +1 -0
- package/dist/modules/domains/services/domains.service.mjs +18 -0
- package/dist/modules/domains/services/domains.service.mjs.map +1 -0
- package/dist/modules/ia-credits/handlers/list-ia-credit-operations.handler.mjs +15 -0
- package/dist/modules/ia-credits/handlers/list-ia-credit-operations.handler.mjs.map +1 -0
- package/dist/modules/ia-credits/hooks/ia-credit-operations.hook.mjs +28 -0
- package/dist/modules/ia-credits/hooks/ia-credit-operations.hook.mjs.map +1 -0
- package/dist/modules/ia-credits/services/ia-credits.service.mjs +23 -2
- package/dist/modules/ia-credits/services/ia-credits.service.mjs.map +1 -1
- package/dist/modules/pages/handlers/count-pages.handler.mjs +4 -2
- package/dist/modules/pages/handlers/count-pages.handler.mjs.map +1 -1
- package/dist/modules/pages/hooks/count-published-pages.hook.mjs +26 -0
- package/dist/modules/pages/hooks/count-published-pages.hook.mjs.map +1 -0
- package/dist/modules/pages/services/pages.service.mjs +3 -2
- package/dist/modules/pages/services/pages.service.mjs.map +1 -1
- package/dist/modules/plans/constants/plan-tooltips.constants.mjs +14 -0
- package/dist/modules/plans/constants/plan-tooltips.constants.mjs.map +1 -0
- package/dist/modules/plans/hooks/use-enriched-plans.hook.mjs +28 -0
- package/dist/modules/plans/hooks/use-enriched-plans.hook.mjs.map +1 -0
- package/dist/modules/plans/hooks/use-ui-plans.hook.mjs +20 -0
- package/dist/modules/plans/hooks/use-ui-plans.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/add-project-users.hook.mjs +25 -0
- package/dist/modules/projects/hooks/add-project-users.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +3 -6
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs +3 -6
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs +3 -6
- package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-project-users.hook.mjs +3 -6
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/remove-project-users.hook.mjs +25 -0
- package/dist/modules/projects/hooks/remove-project-users.hook.mjs.map +1 -0
- package/dist/modules/projects/services/project-users.service.mjs +5 -0
- package/dist/modules/projects/services/project-users.service.mjs.map +1 -1
- package/dist/modules/projects/types.mjs +3 -2
- package/dist/modules/projects/types.mjs.map +1 -1
- package/dist/modules/subscriptions/actions/cancel-subscription.action.mjs +10 -0
- package/dist/modules/subscriptions/actions/cancel-subscription.action.mjs.map +1 -0
- package/dist/modules/subscriptions/actions/create-subscription.action.mjs +10 -0
- package/dist/modules/subscriptions/actions/create-subscription.action.mjs.map +1 -0
- package/dist/modules/subscriptions/actions/find-pending-pix-status.action.mjs +10 -0
- package/dist/modules/subscriptions/actions/find-pending-pix-status.action.mjs.map +1 -0
- package/dist/modules/subscriptions/actions/find-subscription-by-id.action.mjs +10 -0
- package/dist/modules/subscriptions/actions/find-subscription-by-id.action.mjs.map +1 -0
- package/dist/modules/subscriptions/constants/addons.constants.mjs +35 -0
- package/dist/modules/subscriptions/constants/addons.constants.mjs.map +1 -1
- package/dist/modules/subscriptions/constants/downgrade.constants.mjs +25 -0
- package/dist/modules/subscriptions/constants/downgrade.constants.mjs.map +1 -0
- package/dist/modules/subscriptions/constants/subscription.constants.mjs +2 -0
- package/dist/modules/subscriptions/constants/subscription.constants.mjs.map +1 -1
- package/dist/modules/subscriptions/handlers/pending-pix-status.handler.mjs +15 -0
- package/dist/modules/subscriptions/handlers/pending-pix-status.handler.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/cancel-subscription.hook.mjs +25 -0
- package/dist/modules/subscriptions/hooks/cancel-subscription.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/create-subscription.hook.mjs +33 -0
- package/dist/modules/subscriptions/hooks/create-subscription.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/find-subscription-by-id.hook.mjs +18 -0
- package/dist/modules/subscriptions/hooks/find-subscription-by-id.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/pending-pix-status.hook.mjs +25 -0
- package/dist/modules/subscriptions/hooks/pending-pix-status.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/services/subscriptions.service.mjs +71 -0
- package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -1
- package/dist/modules/subscriptions/types/cancel-subscription.type.mjs +9 -0
- package/dist/modules/subscriptions/types/cancel-subscription.type.mjs.map +1 -0
- package/dist/modules/subscriptions/types/create-subscription.type.mjs +62 -0
- package/dist/modules/subscriptions/types/create-subscription.type.mjs.map +1 -0
- package/dist/modules/subscriptions/types/pending-pix-status.type.mjs +28 -0
- package/dist/modules/subscriptions/types/pending-pix-status.type.mjs.map +1 -0
- package/dist/modules/subscriptions/types/subscription.type.mjs +9 -1
- package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -1
- package/dist/modules/subscriptions/utils/addon-buckets.mjs +69 -0
- package/dist/modules/subscriptions/utils/addon-buckets.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/confirm-payment-if-required.mjs +8 -2
- package/dist/modules/subscriptions/utils/confirm-payment-if-required.mjs.map +1 -1
- package/dist/modules/subscriptions/utils/first-period-pricing.mjs +25 -0
- package/dist/modules/subscriptions/utils/first-period-pricing.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/is-api-subscription.mjs +8 -0
- package/dist/modules/subscriptions/utils/is-api-subscription.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/is-boleto-payer.mjs +17 -0
- package/dist/modules/subscriptions/utils/is-boleto-payer.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/is-free-subscription.mjs +8 -0
- package/dist/modules/subscriptions/utils/is-free-subscription.mjs.map +1 -0
- package/dist/modules/subscriptions/utils/periodicity.mjs +55 -1
- package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -1
- package/dist/modules/subscriptions/utils/resolve-subscription-plan-name.mjs +27 -0
- package/dist/modules/subscriptions/utils/resolve-subscription-plan-name.mjs.map +1 -0
- package/dist/modules/users/hooks/messages.hook.mjs +3 -5
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -1
- package/dist/server.mjs +6 -0
- package/dist/server.mjs.map +1 -1
- package/dist/store/useAccountModals.mjs +9 -2
- package/dist/store/useAccountModals.mjs.map +1 -1
- package/dist/store/useAffiliateFlows.mjs +23 -0
- package/dist/store/useAffiliateFlows.mjs.map +1 -0
- package/dist/store/useProjectFlows.mjs +18 -0
- package/dist/store/useProjectFlows.mjs.map +1 -0
- package/dist/store/useSubscriptionFlows.mjs +58 -0
- package/dist/store/useSubscriptionFlows.mjs.map +1 -0
- package/dist/store/useTeamFlows.mjs +15 -0
- package/dist/store/useTeamFlows.mjs.map +1 -0
- package/dist/testing/factories/coupon.factory.mjs +19 -0
- package/dist/testing/factories/coupon.factory.mjs.map +1 -0
- package/dist/testing/factories/index.mjs +6 -0
- package/dist/testing/factories/index.mjs.map +1 -1
- package/dist/testing/factories/project-user.factory.mjs +17 -0
- package/dist/testing/factories/project-user.factory.mjs.map +1 -0
- package/dist/testing/factories/project.factory.mjs +21 -0
- package/dist/testing/factories/project.factory.mjs.map +1 -0
- package/dist/testing/react/providers.mjs +1 -1
- package/dist/testing/react/providers.mjs.map +1 -1
- package/dist/utils/browser/chart-custom-tooltip.mjs +69 -0
- package/dist/utils/browser/chart-custom-tooltip.mjs.map +1 -0
- package/dist/utils/browser/get-css-variable.mjs +9 -0
- package/dist/utils/browser/get-css-variable.mjs.map +1 -0
- package/dist/utils/constants/scrollbar.mjs +5 -0
- package/dist/utils/constants/scrollbar.mjs.map +1 -0
- package/dist/utils/date-filter-period.mjs +34 -0
- package/dist/utils/date-filter-period.mjs.map +1 -0
- package/dist/utils/file/index.mjs +11 -1
- package/dist/utils/file/index.mjs.map +1 -1
- package/dist/utils/format/initials.mjs +8 -0
- package/dist/utils/format/initials.mjs.map +1 -0
- package/dist/utils/format/masks.mjs +32 -1
- package/dist/utils/format/masks.mjs.map +1 -1
- package/dist/utils/qrcode/to-data-url.mjs +12 -0
- package/dist/utils/qrcode/to-data-url.mjs.map +1 -0
- package/dist/utils/validators/account.mjs +1 -7
- package/dist/utils/validators/account.mjs.map +1 -1
- package/package.json +15 -2
- package/src/components/account/AccountHubLinkHandler.tsx +39 -0
- package/src/components/account/AccountModalLayout.tsx +190 -0
- package/src/components/account/AccountModals.tsx +12 -2
- package/src/components/account/DeleteAccountModal.tsx +1 -1
- package/src/components/account/IsntPossibleDeleteAccountModal.tsx +9 -1
- package/src/components/account/MyAccountModal.tsx +215 -0
- package/src/components/account/TwoFactorAuthModal.tsx +1 -1
- package/src/components/account/hooks/useAccountHubActions.ts +95 -0
- package/src/components/account/hooks/useAddCardWithPaymentSwitch.ts +70 -0
- package/src/components/account/hooks/useAffiliatesActions.tsx +78 -0
- package/src/components/account/hooks/useMyAccountModal.ts +40 -0
- package/src/components/account/hooks/useProjectsActions.ts +44 -0
- package/src/components/account/hooks/useSubscriptionActions.ts +99 -0
- package/src/components/account/hooks/useTeamActions.ts +35 -0
- package/src/components/account/sections/AffiliatesSection.tsx +342 -0
- package/src/components/account/sections/ChangePasswordSection.tsx +6 -10
- package/src/components/account/sections/MyProfileSection.tsx +207 -143
- package/src/components/account/sections/PreferencesSection.tsx +55 -51
- package/src/components/account/sections/ProjectsSection.tsx +110 -0
- package/src/components/account/sections/SecuritySection.tsx +72 -62
- package/src/components/account/sections/SubscriptionSection.tsx +36 -0
- package/src/components/account/sections/TeamSection.tsx +161 -0
- package/src/components/account/sections/TokenSection.tsx +4 -8
- package/src/components/account/sections/affiliates/AffiliateCommissionCard.tsx +83 -0
- package/src/components/account/sections/affiliates/AffiliateFlows.tsx +20 -0
- package/src/components/account/sections/affiliates/AffiliateLeadsSheet.tsx +143 -0
- package/src/components/account/sections/affiliates/AffiliateStatsCard.tsx +56 -0
- package/src/components/account/sections/affiliates/AffiliateStepCard.tsx +20 -0
- package/src/components/account/sections/affiliates/AffiliateTransactionsList.tsx +194 -0
- package/src/components/account/sections/affiliates/NoReceivingAccountModal.tsx +63 -0
- package/src/components/account/sections/affiliates/ReceivingAccountModal.tsx +213 -0
- package/src/components/account/sections/affiliates/RequestWithdrawalSheet.tsx +586 -0
- package/src/components/account/sections/affiliates/ViewAttachmentModal.tsx +47 -0
- package/src/components/account/sections/affiliates/reports/AffiliatesIndicatorsChart.tsx +45 -0
- package/src/components/account/sections/affiliates/reports/AffiliatesReportsTab.tsx +44 -0
- package/src/components/account/sections/affiliates/reports/useAffiliatesIndicatorsChart.ts +148 -0
- package/src/components/account/sections/projects/DeleteProjectModal.tsx +246 -0
- package/src/components/account/sections/projects/ProjectFlows.tsx +16 -0
- package/src/components/account/sections/projects/ProjectMembersStack.tsx +75 -0
- package/src/components/account/sections/projects/ProjectRow.tsx +96 -0
- package/src/components/account/sections/projects/ProjectSheet.tsx +603 -0
- package/src/components/account/sections/projects/ProjectsDisabledModal.tsx +69 -0
- package/src/components/account/sections/projects/project-form.schema.ts +30 -0
- package/src/components/account/sections/shared/ConnectListRow.tsx +68 -0
- package/src/components/account/sections/shared/DateFilterPopover.tsx +58 -0
- package/src/components/account/sections/shared/EntityAvatar.tsx +54 -0
- package/src/components/account/sections/shared/FilterPopover.tsx +79 -0
- package/src/components/account/sections/shared/FormSection.tsx +23 -0
- package/src/components/account/sections/shared/IconBox.tsx +21 -0
- package/src/components/account/sections/shared/InfiniteScrollList.tsx +57 -0
- package/src/components/account/sections/shared/ListPagination.tsx +84 -0
- package/src/components/account/sections/shared/RowActionsMenu.tsx +66 -0
- package/src/components/account/sections/shared/SectionLoadError.tsx +27 -0
- package/src/components/account/sections/shared/StatusBadge.tsx +33 -0
- package/src/components/account/sections/shared/WorkspaceSection.tsx +22 -0
- package/src/components/account/sections/subscription/AiCreditsUsage.tsx +152 -0
- package/src/components/account/sections/subscription/BillingAddressSheet.tsx +460 -0
- package/src/components/account/sections/subscription/BoletoDetailsDialog.tsx +104 -0
- package/src/components/account/sections/subscription/BoletoGeneratedDialog.tsx +24 -0
- package/src/components/account/sections/subscription/CancelPlanDialog.tsx +221 -0
- package/src/components/account/sections/subscription/ChargeRow.tsx +161 -0
- package/src/components/account/sections/subscription/ChargeStatusBadge.tsx +29 -0
- package/src/components/account/sections/subscription/ChargesList.tsx +125 -0
- package/src/components/account/sections/subscription/ManageCardsSheet.tsx +93 -0
- package/src/components/account/sections/subscription/OverdueReceiptOpener.tsx +29 -0
- package/src/components/account/sections/subscription/PayChargeDialog.tsx +306 -0
- package/src/components/account/sections/subscription/PaymentConfirmationDialog.tsx +70 -0
- package/src/components/account/sections/subscription/PaymentMethodsCard.tsx +117 -0
- package/src/components/account/sections/subscription/PendingChangeDialog.tsx +168 -0
- package/src/components/account/sections/subscription/PixDetailsDialog.tsx +246 -0
- package/src/components/account/sections/subscription/PixPaymentDialog.tsx +242 -0
- package/src/components/account/sections/subscription/PlanDetailsSheet.tsx +380 -0
- package/src/components/account/sections/subscription/ReceiptDetailsSheet.tsx +318 -0
- package/src/components/account/sections/subscription/SubscriptionFlows.tsx +40 -0
- package/src/components/account/sections/subscription/SubscriptionPlanCard.tsx +433 -0
- package/src/components/account/sections/subscription/UsageReportSheet.tsx +244 -0
- package/src/components/account/sections/subscription/change-plan/ChangePlanSheet.tsx +95 -0
- package/src/components/account/sections/subscription/change-plan/components/AbTestDetailsDialog.tsx +57 -0
- package/src/components/account/sections/subscription/change-plan/components/AddonsBlock.tsx +214 -0
- package/src/components/account/sections/subscription/change-plan/components/AlternativeBucketsSection.tsx +92 -0
- package/src/components/account/sections/subscription/change-plan/components/CouponBlock.tsx +42 -0
- package/src/components/account/sections/subscription/change-plan/components/CouponDialog.tsx +134 -0
- package/src/components/account/sections/subscription/change-plan/components/PricePreview.tsx +28 -0
- package/src/components/account/sections/subscription/change-plan/components/SummaryBlock.tsx +194 -0
- package/src/components/account/sections/subscription/change-plan/plan-comparison.ts +52 -0
- package/src/components/account/sections/subscription/change-plan/steps/PaymentSummaryStep.tsx +161 -0
- package/src/components/account/sections/subscription/change-plan/steps/PlanComparisonStep.tsx +165 -0
- package/src/components/account/sections/subscription/change-plan/steps/PlanViewStep.tsx +89 -0
- package/src/components/account/sections/subscription/change-plan/steps/ReactivationConfigStep.tsx +117 -0
- package/src/components/account/sections/subscription/change-plan/steps/ReactivationPaymentStep.tsx +139 -0
- package/src/components/account/sections/subscription/change-plan/useChangePlanState.tsx +1158 -0
- package/src/components/account/sections/subscription/downgrade/CannotDowngradeDialog.tsx +297 -0
- package/src/components/account/sections/subscription/downgrade/DowngradeReasonDialog.tsx +154 -0
- package/src/components/account/sections/subscription/plans/PlanCard.tsx +417 -0
- package/src/components/account/sections/subscription/plans/PlanCardSkeleton.tsx +70 -0
- package/src/components/account/sections/subscription/plans/PlansCatalogDialog.tsx +156 -0
- package/src/components/account/sections/team/DeleteUserModal.tsx +134 -0
- package/src/components/account/sections/team/TeamFlows.tsx +14 -0
- package/src/components/account/sections/team/TeamMemberRow.tsx +151 -0
- package/src/components/account/sections/team/UserSheet.tsx +688 -0
- package/src/components/account/sections/team/steps/NotificationsStep.tsx +109 -0
- package/src/components/account/sections/team/steps/ProjectSelectionStep.tsx +219 -0
- package/src/components/account/sections/team/steps/UserInformationStep.tsx +423 -0
- package/src/components/account/sections/team/user-form.schema.ts +43 -0
- package/src/components/account/types/workspace-actions.type.ts +56 -0
- package/src/components/layouts/ProfilePopover.tsx +11 -12
- package/src/components/layouts/UsersSelectorPopover.tsx +7 -4
- package/src/components/modals/AccountDeletionWarningModal.tsx +4 -5
- package/src/components/modals/AccountFrozenModal.tsx +6 -3
- package/src/components/modals/Modals.tsx +6 -3
- package/src/components/modals/PaidPlanRequiredModal.tsx +4 -5
- package/src/components/modals/cards/AddFirstCardWarningModal.tsx +72 -0
- package/src/components/modals/cards/SwitchPaymentToCardModal.tsx +232 -0
- package/src/components/modals/promo/AiCreditsOfferModal/AiCreditsOfferModal.tsx +5 -4
- package/src/components/ui/data-display/CardItem.tsx +9 -5
- package/src/components/ui/data-display/PaymentMethodIcons.tsx +43 -0
- package/src/components/ui/form/BillingPeriodSelector.tsx +173 -0
- package/src/components/ui/form/PaymentMethodToggle.tsx +119 -0
- package/src/components/ui/form/RadioOptionFieldIcon.tsx +64 -0
- package/src/components/ui/form/SegmentedControl.tsx +77 -0
- package/src/components/ui/overlay/Dialog.tsx +21 -2
- package/src/components/ui/overlay/Sheet.tsx +26 -5
- package/src/components/ui/overlay/layers.tsx +88 -4
- package/src/enums/AccountHubFlow.ts +8 -0
- package/src/enums/DateFilterPeriod.ts +17 -0
- package/src/enums/WorkspaceSectionType.ts +6 -0
- package/src/handlers.ts +14 -0
- package/src/hooks/useDebounce.ts +5 -3
- package/src/hooks/useUploadProgress.ts +42 -0
- package/src/i18n/messages/en-us.ts +904 -2
- package/src/i18n/messages/es-es.ts +908 -2
- package/src/i18n/messages/pt-br.ts +908 -2
- package/src/index.ts +56 -1
- package/src/infra/http/paged.ts +24 -0
- package/src/middleware.ts +1 -0
- package/src/middlewares/create-auth-middleware.ts +1 -4
- package/src/middlewares/create-legacy-account-routes-middleware.ts +54 -0
- package/src/middlewares/is-route-equals.ts +3 -0
- package/src/modules/accounts/actions/account-management.action.ts +22 -1
- package/src/modules/accounts/constants/account-hub-link.constants.ts +3 -0
- package/src/modules/accounts/constants/legacy-account-routes.constants.ts +1 -0
- package/src/modules/accounts/handlers/list-account-members.handler.ts +23 -0
- package/src/modules/accounts/hooks/add-user-projects.hook.ts +72 -0
- package/src/modules/accounts/hooks/create-account-user.hook.ts +21 -0
- package/src/modules/accounts/hooks/remove-user-projects.hook.ts +68 -0
- package/src/modules/accounts/hooks/use-account-members.hook.ts +31 -0
- package/src/modules/accounts/services/account.service.ts +71 -0
- package/src/modules/accounts/types/account-hub-link.type.ts +13 -0
- package/src/modules/accounts/types.ts +9 -0
- package/src/modules/accounts/utils/build-account-hub-url.ts +14 -0
- package/src/modules/accounts/utils/is-account-hub-flow.ts +7 -0
- package/src/modules/accounts/utils/is-account-section.ts +7 -0
- package/src/modules/accounts/utils/is-my-account-section.ts +12 -0
- package/src/modules/accounts/utils/map-legacy-account-route.ts +108 -0
- package/src/modules/accounts/utils/parse-account-hub-link.ts +21 -0
- package/src/modules/affiliates/actions/ensure-affiliate.action.ts +9 -0
- package/src/modules/affiliates/actions/request-deposit.action.ts +9 -0
- package/src/modules/affiliates/actions/update-affiliate.action.ts +9 -0
- package/src/modules/affiliates/constants/affiliate.constants.ts +11 -0
- package/src/modules/affiliates/constants/query-keys.constants.ts +7 -0
- package/src/modules/affiliates/handlers/affiliate-report-analytics.handler.ts +16 -0
- package/src/modules/affiliates/handlers/affiliate-withdrawal-limits.handler.ts +10 -0
- package/src/modules/affiliates/handlers/current-affiliate.handler.ts +10 -0
- package/src/modules/affiliates/handlers/list-affiliate-coupons.handler.ts +10 -0
- package/src/modules/affiliates/handlers/list-affiliate-leads.handler.ts +23 -0
- package/src/modules/affiliates/handlers/list-affiliate-transactions.handler.ts +23 -0
- package/src/modules/affiliates/hooks/use-affiliate-coupons.hook.ts +19 -0
- package/src/modules/affiliates/hooks/use-affiliate-leads.hook.ts +27 -0
- package/src/modules/affiliates/hooks/use-affiliate-report-analytics.hook.ts +19 -0
- package/src/modules/affiliates/hooks/use-affiliate-transactions.hook.ts +25 -0
- package/src/modules/affiliates/hooks/use-current-affiliate.hook.ts +19 -0
- package/src/modules/affiliates/hooks/use-ensure-affiliate.hook.ts +24 -0
- package/src/modules/affiliates/hooks/use-request-deposit.hook.ts +29 -0
- package/src/modules/affiliates/hooks/use-update-affiliate.hook.ts +24 -0
- package/src/modules/affiliates/hooks/use-withdrawal-limits.hook.ts +20 -0
- package/src/modules/affiliates/services/affiliates.service.ts +240 -0
- package/src/modules/affiliates/types/affiliate.type.ts +180 -0
- package/src/modules/affiliates/utils/get-affiliate-share-link.ts +8 -0
- package/src/modules/charges/actions/get-nota-fiscal.action.ts +8 -0
- package/src/modules/charges/actions/refresh-pix.action.ts +8 -0
- package/src/modules/charges/hooks/nota-fiscal.hook.ts +13 -0
- package/src/modules/charges/hooks/refresh-pix.hook.ts +13 -0
- package/src/modules/charges/services/charges.service.ts +121 -0
- package/src/modules/charges/types/nota-fiscal.type.ts +20 -0
- package/src/modules/charges/types/refresh-pix.type.ts +14 -0
- package/src/modules/charges/utils/get-charge-download-url.ts +10 -0
- package/src/modules/coupons/constants/query-keys.constants.ts +1 -0
- package/src/modules/coupons/handlers/find-coupon-by-code.handler.ts +16 -0
- package/src/modules/coupons/handlers/find-coupon-by-id.handler.ts +15 -0
- package/src/modules/coupons/hooks/use-coupon-by-code.hook.ts +16 -0
- package/src/modules/coupons/hooks/use-coupon-by-id.hook.ts +20 -0
- package/src/modules/coupons/services/coupons.service.ts +54 -0
- package/src/modules/coupons/types/coupon.type.ts +70 -0
- package/src/modules/coupons/utils/coupon-restrictions.ts +112 -0
- package/src/modules/domains/handlers/count-domains.handler.ts +10 -0
- package/src/modules/domains/hooks/count-domains.hook.ts +17 -0
- package/src/modules/domains/services/domains.service.ts +18 -0
- package/src/modules/ia-credits/handlers/list-ia-credit-operations.handler.ts +14 -0
- package/src/modules/ia-credits/hooks/ia-credit-operations.hook.ts +33 -0
- package/src/modules/ia-credits/services/ia-credits.service.ts +32 -1
- package/src/modules/pages/handlers/count-pages.handler.ts +5 -2
- package/src/modules/pages/hooks/count-published-pages.hook.ts +26 -0
- package/src/modules/pages/services/pages.service.ts +3 -2
- package/src/modules/plans/constants/plan-tooltips.constants.ts +16 -0
- package/src/modules/plans/hooks/use-enriched-plans.hook.ts +31 -0
- package/src/modules/plans/hooks/use-ui-plans.hook.ts +22 -0
- package/src/modules/projects/hooks/add-project-users.hook.ts +29 -0
- package/src/modules/projects/hooks/list-all-account-users.hook.ts +3 -6
- package/src/modules/projects/hooks/list-available-users.hook.ts +3 -6
- package/src/modules/projects/hooks/list-infinite-projects.hook.ts +3 -6
- package/src/modules/projects/hooks/list-project-users.hook.ts +3 -6
- package/src/modules/projects/hooks/remove-project-users.hook.ts +29 -0
- package/src/modules/projects/services/project-users.service.ts +135 -130
- package/src/modules/projects/types.ts +89 -88
- package/src/modules/subscriptions/actions/cancel-subscription.action.ts +12 -0
- package/src/modules/subscriptions/actions/create-subscription.action.ts +9 -0
- package/src/modules/subscriptions/actions/find-pending-pix-status.action.ts +8 -0
- package/src/modules/subscriptions/actions/find-subscription-by-id.action.ts +8 -0
- package/src/modules/subscriptions/constants/addons.constants.ts +50 -0
- package/src/modules/subscriptions/constants/downgrade.constants.ts +30 -0
- package/src/modules/subscriptions/constants/subscription.constants.ts +3 -0
- package/src/modules/subscriptions/handlers/pending-pix-status.handler.ts +17 -0
- package/src/modules/subscriptions/hooks/cancel-subscription.hook.ts +28 -0
- package/src/modules/subscriptions/hooks/create-subscription.hook.ts +34 -0
- package/src/modules/subscriptions/hooks/find-subscription-by-id.hook.ts +17 -0
- package/src/modules/subscriptions/hooks/pending-pix-status.hook.ts +30 -0
- package/src/modules/subscriptions/services/subscriptions.service.ts +401 -301
- package/src/modules/subscriptions/types/cancel-subscription.type.ts +8 -0
- package/src/modules/subscriptions/types/create-subscription.type.ts +79 -0
- package/src/modules/subscriptions/types/pending-pix-status.type.ts +33 -0
- package/src/modules/subscriptions/types/subscription.type.ts +157 -147
- package/src/modules/subscriptions/utils/addon-buckets.ts +129 -0
- package/src/modules/subscriptions/utils/confirm-payment-if-required.ts +9 -2
- package/src/modules/subscriptions/utils/first-period-pricing.ts +63 -0
- package/src/modules/subscriptions/utils/is-api-subscription.ts +6 -0
- package/src/modules/subscriptions/utils/is-boleto-payer.ts +21 -0
- package/src/modules/subscriptions/utils/is-free-subscription.ts +6 -0
- package/src/modules/subscriptions/utils/periodicity.ts +101 -0
- package/src/modules/subscriptions/utils/resolve-subscription-plan-name.ts +44 -0
- package/src/modules/users/hooks/messages.hook.ts +3 -5
- package/src/server.ts +102 -99
- package/src/store/useAccountModals.ts +22 -5
- package/src/store/useAffiliateFlows.ts +46 -0
- package/src/store/useProjectFlows.ts +42 -0
- package/src/store/useSubscriptionFlows.ts +176 -0
- package/src/store/useTeamFlows.ts +34 -0
- package/src/testing/factories/coupon.factory.ts +17 -0
- package/src/testing/factories/index.ts +3 -0
- package/src/testing/factories/project-user.factory.ts +15 -0
- package/src/testing/factories/project.factory.ts +19 -0
- package/src/testing/react/providers.tsx +2 -1
- package/src/utils/browser/chart-custom-tooltip.ts +85 -0
- package/src/utils/browser/get-css-variable.ts +6 -0
- package/src/utils/constants/scrollbar.ts +10 -0
- package/src/utils/date-filter-period.ts +34 -0
- package/src/utils/file/index.ts +13 -0
- package/src/utils/format/initials.ts +10 -0
- package/src/utils/format/masks.ts +41 -0
- package/src/utils/qrcode/to-data-url.ts +23 -0
- package/src/utils/validators/account.ts +0 -8
- package/dist/components/account/ConfigurationsMyAccountModal.mjs +0 -143
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +0 -1
- package/dist/components/account/hooks/useConfigurationsModal.mjs +0 -34
- package/dist/components/account/hooks/useConfigurationsModal.mjs.map +0 -1
- package/src/components/account/ConfigurationsMyAccountModal.tsx +0 -179
- package/src/components/account/hooks/useConfigurationsModal.ts +0 -45
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/affiliates/hooks/use-withdrawal-limits.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { apiFetch } from '../../../infra/http/api-fetch';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport type { SuccessResult } from '../../../infra/api/types';\nimport type { WithdrawalLimits } from '../types/affiliate.type';\nimport { WITHDRAWAL_LIMITS_QUERY_KEY } from '../constants/query-keys.constants';\n\n/** Regras de saque do afiliado da conta: mínimo, teto mensal, nota fiscal e bloqueios. */\nexport function useWithdrawalLimits(options: { enabled?: boolean } = {}) {\n const queryKey = useAuthQueryKey([...WITHDRAWAL_LIMITS_QUERY_KEY, 'current']);\n\n return useQuery({\n queryKey,\n queryFn: ({ signal }) =>\n apiFetch<SuccessResult<WithdrawalLimits>>('/api/affiliates/current/withdrawal-limits', { signal }),\n enabled: options.enabled ?? true,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAGhC,SAAS,mCAAmC;AAGrC,SAAS,oBAAoB,UAAiC,CAAC,GAAG;AACvE,QAAM,WAAW,gBAAgB,CAAC,GAAG,6BAA6B,SAAS,CAAC;AAE5E,SAAO,SAAS;AAAA,IACd;AAAA,IACA,SAAS,CAAC,EAAE,OAAO,MACjB,SAA0C,6CAA6C,EAAE,OAAO,CAAC;AAAA,IACnG,SAAS,QAAQ,WAAW;AAAA,EAC9B,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { api } from "../../../infra/api/client";
|
|
3
|
+
import {
|
|
4
|
+
ApiError
|
|
5
|
+
} from "../../../infra/api/types";
|
|
6
|
+
import { buildQueryParams } from "../../../infra/utils/params";
|
|
7
|
+
import { assertManagementSubscription } from "../../auth/utils/assert-management-subscription";
|
|
8
|
+
import { getUserContext } from "../../auth/utils/get-user-context";
|
|
9
|
+
import {
|
|
10
|
+
AffiliateCouponSchema,
|
|
11
|
+
AffiliateLeadSchema,
|
|
12
|
+
AffiliateSchema,
|
|
13
|
+
AffiliateTransactionSchema,
|
|
14
|
+
EMPTY_REPORT_ANALYTICS_DATA,
|
|
15
|
+
ReportAnalyticsDataSchema,
|
|
16
|
+
WithdrawalLimitsSchema
|
|
17
|
+
} from "../types/affiliate.type";
|
|
18
|
+
class AffiliatesService {
|
|
19
|
+
async findCurrent() {
|
|
20
|
+
const { id_account } = await getUserContext();
|
|
21
|
+
const response = await api.apps.get(
|
|
22
|
+
`/affiliates?${buildQueryParams({ id_account, limit: 1, page: 1 })}`
|
|
23
|
+
);
|
|
24
|
+
if (response.status === 0) {
|
|
25
|
+
throw new ApiError(
|
|
26
|
+
response.message || "Erro ao buscar afiliado",
|
|
27
|
+
"FIND_CURRENT_AFFILIATE_FAILED",
|
|
28
|
+
400
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
const affiliate = response.data?.[0];
|
|
32
|
+
return { success: true, data: affiliate ? AffiliateSchema.parse(affiliate) : null };
|
|
33
|
+
}
|
|
34
|
+
async reportAnalytics(params) {
|
|
35
|
+
const affiliateId = await this.requireCurrentAffiliateId();
|
|
36
|
+
const response = await api.apps.get(
|
|
37
|
+
`/affiliates/${affiliateId}/action/reportAnalytics?${buildQueryParams({ ...params })}`
|
|
38
|
+
);
|
|
39
|
+
if (response.status === 0) {
|
|
40
|
+
throw new ApiError(
|
|
41
|
+
response.message || "Erro ao buscar relat\xF3rio de afiliado",
|
|
42
|
+
"REPORT_ANALYTICS_FAILED",
|
|
43
|
+
400
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
const raw = response.data?.[0];
|
|
47
|
+
return { success: true, data: raw ? ReportAnalyticsDataSchema.parse(raw) : EMPTY_REPORT_ANALYTICS_DATA };
|
|
48
|
+
}
|
|
49
|
+
async listTransactions(params) {
|
|
50
|
+
const affiliateId = await this.requireCurrentAffiliateId();
|
|
51
|
+
const response = await api.apps.get(
|
|
52
|
+
`/affiliates/${affiliateId}/action/listTransactions?${buildQueryParams({ ...params })}`
|
|
53
|
+
);
|
|
54
|
+
if (response.status === 0) {
|
|
55
|
+
throw new ApiError(
|
|
56
|
+
response.message || "Erro ao listar transa\xE7\xF5es de afiliado",
|
|
57
|
+
"LIST_TRANSACTIONS_FAILED",
|
|
58
|
+
400
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
success: true,
|
|
63
|
+
data: (response.data ?? []).map((item) => AffiliateTransactionSchema.parse(item)),
|
|
64
|
+
total: response.total ?? 0
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async listCoupons() {
|
|
68
|
+
const affiliateId = await this.requireCurrentAffiliateId();
|
|
69
|
+
const response = await api.apps.get(
|
|
70
|
+
`/coupons?${buildQueryParams({ id_affiliate: affiliateId })}`
|
|
71
|
+
);
|
|
72
|
+
if (response.status === 0) {
|
|
73
|
+
throw new ApiError(response.message || "Erro ao listar cupons", "LIST_COUPONS_FAILED", 400);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
success: true,
|
|
77
|
+
data: (response.data ?? []).map((item) => AffiliateCouponSchema.parse(item)),
|
|
78
|
+
total: response.total ?? 0
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Leads indicados pelo afiliado da conta (a listagem de contas filtrada por `id_affiliate`). */
|
|
82
|
+
async listLeads(params) {
|
|
83
|
+
const affiliateId = await this.requireCurrentAffiliateId();
|
|
84
|
+
const response = await api.apps.get(
|
|
85
|
+
`/accounts?${buildQueryParams({ ...params, id_affiliate: affiliateId })}`
|
|
86
|
+
);
|
|
87
|
+
if (response.status === 0) {
|
|
88
|
+
throw new ApiError(
|
|
89
|
+
response.message || "Erro ao listar leads do afiliado",
|
|
90
|
+
"LIST_AFFILIATE_LEADS_FAILED",
|
|
91
|
+
400
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
success: true,
|
|
96
|
+
data: (response.data ?? []).map((item) => AffiliateLeadSchema.parse(item)),
|
|
97
|
+
total: response.total ?? 0
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
async getWithdrawalLimits() {
|
|
101
|
+
const affiliateId = await this.requireCurrentAffiliateId();
|
|
102
|
+
const response = await api.apps.get(
|
|
103
|
+
`/affiliates/${affiliateId}/action/withdrawalLimits`
|
|
104
|
+
);
|
|
105
|
+
if (response.status === 0 || !response.data?.[0]) {
|
|
106
|
+
throw new ApiError(
|
|
107
|
+
response.message || "Erro ao buscar limites de saque",
|
|
108
|
+
"GET_WITHDRAWAL_LIMITS_FAILED",
|
|
109
|
+
400
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
return { success: true, data: WithdrawalLimitsSchema.parse(response.data[0]) };
|
|
113
|
+
}
|
|
114
|
+
/** Entrada no programa: cria o afiliado da conta com os cupons padrão, ou devolve o que já existe. */
|
|
115
|
+
async ensureAffiliate(body) {
|
|
116
|
+
await assertManagementSubscription();
|
|
117
|
+
const { id_account } = await getUserContext();
|
|
118
|
+
const response = await api.apps.post(
|
|
119
|
+
"/affiliates/action/ensure",
|
|
120
|
+
{ id_account, ...body }
|
|
121
|
+
);
|
|
122
|
+
if (response.status === 0 || !response.data?.length) {
|
|
123
|
+
throw new ApiError(
|
|
124
|
+
response.message || "Erro ao entrar no programa de afiliados",
|
|
125
|
+
"ENSURE_AFFILIATE_FAILED",
|
|
126
|
+
400
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const raw = response.data[0];
|
|
130
|
+
return {
|
|
131
|
+
success: true,
|
|
132
|
+
data: {
|
|
133
|
+
affiliate: AffiliateSchema.parse(raw.affiliate),
|
|
134
|
+
coupons: raw.coupons ?? [],
|
|
135
|
+
created: raw.created ?? [],
|
|
136
|
+
failed: raw.failed ?? []
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
async requestDeposit(body) {
|
|
141
|
+
const affiliateId = await this.requireCurrentAffiliateId();
|
|
142
|
+
const response = await api.apps.post(
|
|
143
|
+
`/affiliates/${affiliateId}/action/requestDeposit`,
|
|
144
|
+
body
|
|
145
|
+
);
|
|
146
|
+
if (response.status === 0) {
|
|
147
|
+
throw new ApiError(
|
|
148
|
+
response.message || "Erro ao solicitar saque",
|
|
149
|
+
"REQUEST_DEPOSIT_FAILED",
|
|
150
|
+
400
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return { success: true, message: response.message || "Solicita\xE7\xE3o enviada com sucesso." };
|
|
154
|
+
}
|
|
155
|
+
/** Conta de recebimento (PIX e titular) do afiliado da conta. */
|
|
156
|
+
async updateAffiliate(body) {
|
|
157
|
+
const affiliateId = await this.requireCurrentAffiliateId();
|
|
158
|
+
const response = await api.apps.put(
|
|
159
|
+
`/affiliates/${affiliateId}`,
|
|
160
|
+
body
|
|
161
|
+
);
|
|
162
|
+
if (response.status === 0 || !response.data?.[0]) {
|
|
163
|
+
throw new ApiError(
|
|
164
|
+
response.message || "Erro ao atualizar conta de recebimento",
|
|
165
|
+
"UPDATE_AFFILIATE_FAILED",
|
|
166
|
+
400
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
return { success: true, data: AffiliateSchema.parse(response.data[0]) };
|
|
170
|
+
}
|
|
171
|
+
async requireCurrentAffiliateId() {
|
|
172
|
+
const { data: affiliate } = await this.findCurrent();
|
|
173
|
+
if (!affiliate) {
|
|
174
|
+
throw new ApiError("Afiliado n\xE3o encontrado", "AFFILIATE_NOT_FOUND", 404);
|
|
175
|
+
}
|
|
176
|
+
return affiliate.id;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const affiliatesService = new AffiliatesService();
|
|
180
|
+
export {
|
|
181
|
+
affiliatesService
|
|
182
|
+
};
|
|
183
|
+
//# sourceMappingURL=affiliates.service.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/affiliates/services/affiliates.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport {\n ApiError,\n type ApiPaginatedActionResult,\n type PaginatedSuccessResult,\n type SuccessResult,\n} from '../../../infra/api/types';\nimport { buildQueryParams } from '../../../infra/utils/params';\nimport { assertManagementSubscription } from '../../auth/utils/assert-management-subscription';\nimport { getUserContext } from '../../auth/utils/get-user-context';\nimport {\n AffiliateCouponSchema,\n AffiliateLeadSchema,\n AffiliateSchema,\n AffiliateTransactionSchema,\n EMPTY_REPORT_ANALYTICS_DATA,\n ReportAnalyticsDataSchema,\n WithdrawalLimitsSchema,\n type Affiliate,\n type AffiliateCoupon,\n type AffiliateLead,\n type AffiliateTransaction,\n type EnsureAffiliateData,\n type EnsureAffiliateRequest,\n type ListAffiliateLeadsParams,\n type ListAffiliateTransactionsParams,\n type ReportAnalyticsData,\n type ReportAnalyticsParams,\n type RequestDepositRequest,\n type UpdateAffiliateRequest,\n type WithdrawalLimits,\n} from '../types/affiliate.type';\n\ninterface ApiDataResponse<T> {\n status: 0 | 1;\n message?: string;\n data?: T[];\n total?: number;\n}\n\n/**\n * Leituras do programa de afiliados sempre a partir da conta da sessão: o afiliado nunca vem do\n * client, então uma conta não lê relatório, transações ou cupons do afiliado de outra.\n */\nclass AffiliatesService {\n async findCurrent(): Promise<SuccessResult<Affiliate | null>> {\n const { id_account } = await getUserContext();\n const response = await api.apps.get<ApiPaginatedActionResult<Affiliate>>(\n `/affiliates?${buildQueryParams({ id_account, limit: 1, page: 1 })}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao buscar afiliado',\n 'FIND_CURRENT_AFFILIATE_FAILED',\n 400\n );\n }\n\n const affiliate = response.data?.[0];\n return { success: true, data: affiliate ? AffiliateSchema.parse(affiliate) : null };\n }\n\n async reportAnalytics(params: ReportAnalyticsParams): Promise<SuccessResult<ReportAnalyticsData>> {\n const affiliateId = await this.requireCurrentAffiliateId();\n const response = await api.apps.get<ApiDataResponse<ReportAnalyticsData>>(\n `/affiliates/${affiliateId}/action/reportAnalytics?${buildQueryParams({ ...params })}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao buscar relatório de afiliado',\n 'REPORT_ANALYTICS_FAILED',\n 400\n );\n }\n\n const raw = response.data?.[0];\n return { success: true, data: raw ? ReportAnalyticsDataSchema.parse(raw) : EMPTY_REPORT_ANALYTICS_DATA };\n }\n\n async listTransactions(\n params: ListAffiliateTransactionsParams\n ): Promise<PaginatedSuccessResult<AffiliateTransaction>> {\n const affiliateId = await this.requireCurrentAffiliateId();\n const response = await api.apps.get<ApiDataResponse<AffiliateTransaction>>(\n `/affiliates/${affiliateId}/action/listTransactions?${buildQueryParams({ ...params })}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao listar transações de afiliado',\n 'LIST_TRANSACTIONS_FAILED',\n 400\n );\n }\n\n return {\n success: true,\n data: (response.data ?? []).map((item) => AffiliateTransactionSchema.parse(item)),\n total: response.total ?? 0,\n };\n }\n\n async listCoupons(): Promise<PaginatedSuccessResult<AffiliateCoupon>> {\n const affiliateId = await this.requireCurrentAffiliateId();\n const response = await api.apps.get<ApiDataResponse<AffiliateCoupon>>(\n `/coupons?${buildQueryParams({ id_affiliate: affiliateId })}`\n );\n\n if (response.status === 0) {\n throw new ApiError(response.message || 'Erro ao listar cupons', 'LIST_COUPONS_FAILED', 400);\n }\n\n return {\n success: true,\n data: (response.data ?? []).map((item) => AffiliateCouponSchema.parse(item)),\n total: response.total ?? 0,\n };\n }\n\n /** Leads indicados pelo afiliado da conta (a listagem de contas filtrada por `id_affiliate`). */\n async listLeads(params: ListAffiliateLeadsParams): Promise<PaginatedSuccessResult<AffiliateLead>> {\n const affiliateId = await this.requireCurrentAffiliateId();\n const response = await api.apps.get<ApiDataResponse<AffiliateLead>>(\n `/accounts?${buildQueryParams({ ...params, id_affiliate: affiliateId })}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao listar leads do afiliado',\n 'LIST_AFFILIATE_LEADS_FAILED',\n 400\n );\n }\n\n return {\n success: true,\n data: (response.data ?? []).map((item) => AffiliateLeadSchema.parse(item)),\n total: response.total ?? 0,\n };\n }\n\n async getWithdrawalLimits(): Promise<SuccessResult<WithdrawalLimits>> {\n const affiliateId = await this.requireCurrentAffiliateId();\n const response = await api.apps.get<ApiDataResponse<WithdrawalLimits>>(\n `/affiliates/${affiliateId}/action/withdrawalLimits`\n );\n\n if (response.status === 0 || !response.data?.[0]) {\n throw new ApiError(\n response.message || 'Erro ao buscar limites de saque',\n 'GET_WITHDRAWAL_LIMITS_FAILED',\n 400\n );\n }\n\n return { success: true, data: WithdrawalLimitsSchema.parse(response.data[0]) };\n }\n\n /** Entrada no programa: cria o afiliado da conta com os cupons padrão, ou devolve o que já existe. */\n async ensureAffiliate(body: EnsureAffiliateRequest): Promise<SuccessResult<EnsureAffiliateData>> {\n await assertManagementSubscription();\n const { id_account } = await getUserContext();\n\n const response = await api.apps.post<ApiDataResponse<EnsureAffiliateData>>(\n '/affiliates/action/ensure',\n { id_account, ...body }\n );\n\n if (response.status === 0 || !response.data?.length) {\n throw new ApiError(\n response.message || 'Erro ao entrar no programa de afiliados',\n 'ENSURE_AFFILIATE_FAILED',\n 400\n );\n }\n\n const raw = response.data[0];\n\n return {\n success: true,\n data: {\n affiliate: AffiliateSchema.parse(raw.affiliate),\n coupons: raw.coupons ?? [],\n created: raw.created ?? [],\n failed: raw.failed ?? [],\n },\n };\n }\n\n async requestDeposit(body: RequestDepositRequest): Promise<{ success: true; message: string }> {\n const affiliateId = await this.requireCurrentAffiliateId();\n const response = await api.apps.post<{ status: 0 | 1; message?: string }>(\n `/affiliates/${affiliateId}/action/requestDeposit`,\n body\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao solicitar saque',\n 'REQUEST_DEPOSIT_FAILED',\n 400\n );\n }\n\n return { success: true, message: response.message || 'Solicitação enviada com sucesso.' };\n }\n\n /** Conta de recebimento (PIX e titular) do afiliado da conta. */\n async updateAffiliate(body: UpdateAffiliateRequest): Promise<SuccessResult<Affiliate>> {\n const affiliateId = await this.requireCurrentAffiliateId();\n const response = await api.apps.put<ApiDataResponse<Affiliate>>(\n `/affiliates/${affiliateId}`,\n body\n );\n\n if (response.status === 0 || !response.data?.[0]) {\n throw new ApiError(\n response.message || 'Erro ao atualizar conta de recebimento',\n 'UPDATE_AFFILIATE_FAILED',\n 400\n );\n }\n\n return { success: true, data: AffiliateSchema.parse(response.data[0]) };\n }\n\n private async requireCurrentAffiliateId(): Promise<number> {\n const { data: affiliate } = await this.findCurrent();\n if (!affiliate) {\n throw new ApiError('Afiliado não encontrado', 'AFFILIATE_NOT_FOUND', 404);\n }\n return affiliate.id;\n }\n}\n\nexport const affiliatesService = new AffiliatesService();\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB;AAAA,EACE;AAAA,OAIK;AACP,SAAS,wBAAwB;AACjC,SAAS,oCAAoC;AAC7C,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAcK;AAaP,MAAM,kBAAkB;AAAA,EACtB,MAAM,cAAwD;AAC5D,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAC5C,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,eAAe,iBAAiB,EAAE,YAAY,OAAO,GAAG,MAAM,EAAE,CAAC,CAAC;AAAA,IACpE;AAEA,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F;AAAA,IACF;AAEA,WAAO,EAAE,SAAS,MAAM,MAAM,gBAAgB,MAAM,SAAS,KAAK,CAAC,CAAC,EAAE;AAAA,EACxE;AAAA,EAEA,MAAc,4BAA6C;AACzD,UAAM,EAAE,MAAM,UAAU,IAAI,MAAM,KAAK,YAAY;AACnD,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,SAAS,8BAA2B,uBAAuB,GAAG;AAAA,IAC1E;AACA,WAAO,UAAU;AAAA,EACnB;AACF;AAEO,MAAM,oBAAoB,IAAI,kBAAkB;","names":[]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
const AffiliateSchema = z.object({
|
|
3
|
+
id: z.number(),
|
|
4
|
+
deleted: z.number().transform((val) => val === 1).optional().default(false),
|
|
5
|
+
datetime_alt: z.union([z.date(), z.coerce.date()]).nullable().optional(),
|
|
6
|
+
datetime_del: z.union([z.date(), z.coerce.date()]).nullable().optional(),
|
|
7
|
+
datetime_add: z.union([z.date(), z.coerce.date()]).nullable().optional(),
|
|
8
|
+
id_wl: z.number(),
|
|
9
|
+
id_account: z.number(),
|
|
10
|
+
active: z.boolean(),
|
|
11
|
+
balance: z.union([z.number(), z.string()]).nullable().optional(),
|
|
12
|
+
pix: z.string().nullable().optional(),
|
|
13
|
+
bank: z.string().nullable().optional(),
|
|
14
|
+
agency: z.string().nullable().optional(),
|
|
15
|
+
account: z.string().nullable().optional(),
|
|
16
|
+
holder_document: z.string().nullable().optional(),
|
|
17
|
+
holder_name: z.string().nullable().optional()
|
|
18
|
+
});
|
|
19
|
+
const ReportAnalyticsPeriodSchema = z.object({
|
|
20
|
+
period: z.coerce.number(),
|
|
21
|
+
total: z.coerce.number()
|
|
22
|
+
});
|
|
23
|
+
const ReportAnalyticsGraphicDataItemSchema = z.object({
|
|
24
|
+
date: z.string(),
|
|
25
|
+
views: z.coerce.number(),
|
|
26
|
+
leads: z.coerce.number(),
|
|
27
|
+
customers: z.coerce.number().optional()
|
|
28
|
+
});
|
|
29
|
+
const ReportAnalyticsDataSchema = z.object({
|
|
30
|
+
leads: ReportAnalyticsPeriodSchema,
|
|
31
|
+
views: ReportAnalyticsPeriodSchema,
|
|
32
|
+
customers: ReportAnalyticsPeriodSchema,
|
|
33
|
+
income: z.coerce.number(),
|
|
34
|
+
graphicData: z.array(ReportAnalyticsGraphicDataItemSchema)
|
|
35
|
+
});
|
|
36
|
+
const EMPTY_REPORT_ANALYTICS_DATA = {
|
|
37
|
+
leads: { period: 0, total: 0 },
|
|
38
|
+
views: { period: 0, total: 0 },
|
|
39
|
+
customers: { period: 0, total: 0 },
|
|
40
|
+
income: 0,
|
|
41
|
+
graphicData: []
|
|
42
|
+
};
|
|
43
|
+
const AffiliateTransactionSchema = z.object({
|
|
44
|
+
id: z.number(),
|
|
45
|
+
datetime_add: z.string(),
|
|
46
|
+
value: z.coerce.number(),
|
|
47
|
+
status: z.string().transform((s) => s.toLowerCase()).pipe(z.enum(["pending", "consolidated", "canceled", "refused"])),
|
|
48
|
+
type: z.number(),
|
|
49
|
+
email: z.string().optional(),
|
|
50
|
+
comission: z.coerce.number().optional(),
|
|
51
|
+
attachment: z.string().nullable().optional(),
|
|
52
|
+
refused_reason: z.string().nullable().optional()
|
|
53
|
+
});
|
|
54
|
+
const AffiliateCouponSchema = z.object({
|
|
55
|
+
id: z.number(),
|
|
56
|
+
id_affiliate: z.number().nullable().optional(),
|
|
57
|
+
title: z.string(),
|
|
58
|
+
code: z.string(),
|
|
59
|
+
discount: z.number(),
|
|
60
|
+
discount_type: z.number().nullable(),
|
|
61
|
+
active: z.boolean()
|
|
62
|
+
});
|
|
63
|
+
const DEFAULT_AFFILIATE_DISCOUNTS = [0, 5, 10];
|
|
64
|
+
const AffiliateLeadSchema = z.object({
|
|
65
|
+
id: z.number(),
|
|
66
|
+
name: z.string().nullable().optional(),
|
|
67
|
+
datetime_add: z.string().nullable().optional()
|
|
68
|
+
});
|
|
69
|
+
const DEFAULT_LIST_AFFILIATE_LEADS_PARAMS = {
|
|
70
|
+
page: 1,
|
|
71
|
+
limit: 50,
|
|
72
|
+
sort: "id:DESC"
|
|
73
|
+
};
|
|
74
|
+
const WithdrawalLimitsSchema = z.object({
|
|
75
|
+
personType: z.enum(["cpf", "cnpj"]),
|
|
76
|
+
financialDocumentType: z.number(),
|
|
77
|
+
requiresInvoice: z.boolean(),
|
|
78
|
+
minValue: z.number(),
|
|
79
|
+
maxValuePerMonth: z.number().nullable(),
|
|
80
|
+
monthlyUsed: z.number().nullable(),
|
|
81
|
+
monthlyRemaining: z.number().nullable(),
|
|
82
|
+
balance: z.number(),
|
|
83
|
+
availableToWithdraw: z.number(),
|
|
84
|
+
canWithdraw: z.boolean(),
|
|
85
|
+
blockReason: z.enum(["PIX_DOCUMENT_MISMATCH"]).nullable()
|
|
86
|
+
});
|
|
87
|
+
export {
|
|
88
|
+
AffiliateCouponSchema,
|
|
89
|
+
AffiliateLeadSchema,
|
|
90
|
+
AffiliateSchema,
|
|
91
|
+
AffiliateTransactionSchema,
|
|
92
|
+
DEFAULT_AFFILIATE_DISCOUNTS,
|
|
93
|
+
DEFAULT_LIST_AFFILIATE_LEADS_PARAMS,
|
|
94
|
+
EMPTY_REPORT_ANALYTICS_DATA,
|
|
95
|
+
ReportAnalyticsDataSchema,
|
|
96
|
+
ReportAnalyticsGraphicDataItemSchema,
|
|
97
|
+
ReportAnalyticsPeriodSchema,
|
|
98
|
+
WithdrawalLimitsSchema
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=affiliate.type.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/affiliates/types/affiliate.type.ts"],"sourcesContent":["import z from 'zod';\n\nexport const AffiliateSchema = z.object({\n id: z.number(),\n deleted: z\n .number()\n .transform((val) => val === 1)\n .optional()\n .default(false),\n datetime_alt: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_del: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_add: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n id_wl: z.number(),\n id_account: z.number(),\n active: z.boolean(),\n balance: z.union([z.number(), z.string()]).nullable().optional(),\n pix: z.string().nullable().optional(),\n bank: z.string().nullable().optional(),\n agency: z.string().nullable().optional(),\n account: z.string().nullable().optional(),\n holder_document: z.string().nullable().optional(),\n holder_name: z.string().nullable().optional(),\n});\n\nexport type Affiliate = z.infer<typeof AffiliateSchema>;\n\nexport const ReportAnalyticsPeriodSchema = z.object({\n period: z.coerce.number(),\n total: z.coerce.number(),\n});\n\nexport const ReportAnalyticsGraphicDataItemSchema = z.object({\n date: z.string(),\n views: z.coerce.number(),\n leads: z.coerce.number(),\n customers: z.coerce.number().optional(),\n});\n\nexport const ReportAnalyticsDataSchema = z.object({\n leads: ReportAnalyticsPeriodSchema,\n views: ReportAnalyticsPeriodSchema,\n customers: ReportAnalyticsPeriodSchema,\n income: z.coerce.number(),\n graphicData: z.array(ReportAnalyticsGraphicDataItemSchema),\n});\n\nexport type ReportAnalyticsData = z.infer<typeof ReportAnalyticsDataSchema>;\n\nexport interface ReportAnalyticsParams {\n date_start: string;\n date_end: string;\n}\n\nexport const EMPTY_REPORT_ANALYTICS_DATA: ReportAnalyticsData = {\n leads: { period: 0, total: 0 },\n views: { period: 0, total: 0 },\n customers: { period: 0, total: 0 },\n income: 0,\n graphicData: [],\n};\n\nexport const AffiliateTransactionSchema = z.object({\n id: z.number(),\n datetime_add: z.string(),\n value: z.coerce.number(),\n status: z\n .string()\n .transform((s) => s.toLowerCase())\n .pipe(z.enum(['pending', 'consolidated', 'canceled', 'refused'])),\n type: z.number(),\n email: z.string().optional(),\n comission: z.coerce.number().optional(),\n attachment: z.string().nullable().optional(),\n refused_reason: z.string().nullable().optional(),\n});\n\nexport type AffiliateTransaction = z.infer<typeof AffiliateTransactionSchema>;\n\nexport interface ListAffiliateTransactionsParams {\n page?: number;\n limit?: number;\n sort?: string;\n date_start?: string;\n date_end?: string;\n}\n\n/** Cupom de afiliado: só o que a aba de afiliados usa do cupom. */\nexport const AffiliateCouponSchema = z.object({\n id: z.number(),\n id_affiliate: z.number().nullable().optional(),\n title: z.string(),\n code: z.string(),\n discount: z.number(),\n discount_type: z.number().nullable(),\n active: z.boolean(),\n});\n\nexport type AffiliateCoupon = z.infer<typeof AffiliateCouponSchema>;\n\n// ============================================================================\n// Programa de afiliados: entrada, saque e conta de recebimento\n// ============================================================================\n\n/** Descontos dos cupons criados junto com o afiliado. */\nexport const DEFAULT_AFFILIATE_DISCOUNTS = [0, 5, 10];\n\nexport interface EnsureAffiliateRequest {\n gestor_name: string;\n discounts?: number[];\n}\n\nexport interface EnsureAffiliateCoupon {\n id: number;\n code: string;\n discount: number;\n discount_type: number | null;\n active: boolean;\n id_affiliate: number;\n id_wl: number;\n title?: string;\n}\n\nexport interface EnsureAffiliateData {\n affiliate: Affiliate;\n coupons: EnsureAffiliateCoupon[];\n created: EnsureAffiliateCoupon[];\n failed: { discount: number; error: string }[];\n}\n\nexport interface RequestDepositRequest {\n value: number;\n attachment?: string;\n}\n\nexport interface UpdateAffiliateRequest {\n bank?: string;\n pix?: string;\n agency?: string;\n account?: string;\n holder_name?: string;\n holder_document?: string;\n}\n\nexport const AffiliateLeadSchema = z.object({\n id: z.number(),\n name: z.string().nullable().optional(),\n datetime_add: z.string().nullable().optional(),\n});\n\nexport type AffiliateLead = z.infer<typeof AffiliateLeadSchema>;\n\nexport interface ListAffiliateLeadsParams {\n page?: number;\n limit?: number;\n sort?: string;\n search?: string;\n}\n\nexport const DEFAULT_LIST_AFFILIATE_LEADS_PARAMS: ListAffiliateLeadsParams = {\n page: 1,\n limit: 50,\n sort: 'id:DESC',\n};\n\n/** Regras de saque do backend: mínimo, teto mensal de CPF, nota fiscal de CNPJ e bloqueios. */\nexport const WithdrawalLimitsSchema = z.object({\n personType: z.enum(['cpf', 'cnpj']),\n financialDocumentType: z.number(),\n requiresInvoice: z.boolean(),\n minValue: z.number(),\n maxValuePerMonth: z.number().nullable(),\n monthlyUsed: z.number().nullable(),\n monthlyRemaining: z.number().nullable(),\n balance: z.number(),\n availableToWithdraw: z.number(),\n canWithdraw: z.boolean(),\n blockReason: z.enum(['PIX_DOCUMENT_MISMATCH']).nullable(),\n});\n\nexport type WithdrawalLimits = z.infer<typeof WithdrawalLimitsSchema>;\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,kBAAkB,EAAE,OAAO;AAAA,EACtC,IAAI,EAAE,OAAO;AAAA,EACb,SAAS,EACN,OAAO,EACP,UAAU,CAAC,QAAQ,QAAQ,CAAC,EAC5B,SAAS,EACT,QAAQ,KAAK;AAAA,EAChB,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EACvE,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EACvE,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EACvE,OAAO,EAAE,OAAO;AAAA,EAChB,YAAY,EAAE,OAAO;AAAA,EACrB,QAAQ,EAAE,QAAQ;AAAA,EAClB,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EAC/D,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACpC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACrC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACvC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACxC,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EAChD,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,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`${base}/a/${coupon.code}`;
|
|
4
|
+
return `${base}/cupom/${coupon.id}`;
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
getAffiliateShareLink
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=get-affiliate-share-link.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/affiliates/utils/get-affiliate-share-link.ts"],"sourcesContent":["import type { AffiliateCoupon } from '../types/affiliate.type';\n\n/** Cupom sem desconto compartilha o link de afiliado; com desconto, o link do cupom. */\nexport function getAffiliateShareLink(baseUrl: string, coupon: Pick<AffiliateCoupon, 'id' | 'code' | 'discount'>): string {\n const base = baseUrl.replace(/\\/$/, '');\n if (coupon.discount === 0) return `${base}/a/${coupon.code}`;\n return `${base}/cupom/${coupon.id}`;\n}\n"],"mappings":"AAGO,SAAS,sBAAsB,SAAiB,QAAmE;AACxH,QAAM,OAAO,QAAQ,QAAQ,OAAO,EAAE;AACtC,MAAI,OAAO,aAAa,EAAG,QAAO,GAAG,IAAI,MAAM,OAAO,IAAI;AAC1D,SAAO,GAAG,IAAI,UAAU,OAAO,EAAE;AACnC;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeMutationAction } from "../../../utils/safeMutationAction";
|
|
3
|
+
import { chargesService } from "../services/charges.service";
|
|
4
|
+
async function getNotaFiscalAction(chargeId) {
|
|
5
|
+
return safeMutationAction(() => chargesService.getNotaFiscal(chargeId));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
getNotaFiscalAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=get-nota-fiscal.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/charges/actions/get-nota-fiscal.action.ts"],"sourcesContent":["'use server';\n\nimport { safeMutationAction } from '../../../utils/safeMutationAction';\nimport { chargesService } from '../services/charges.service';\n\nexport async function getNotaFiscalAction(chargeId: number | string) {\n return safeMutationAction(() => chargesService.getNotaFiscal(chargeId));\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAE/B,eAAsB,oBAAoB,UAA2B;AACnE,SAAO,mBAAmB,MAAM,eAAe,cAAc,QAAQ,CAAC;AACxE;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeMutationAction } from "../../../utils/safeMutationAction";
|
|
3
|
+
import { chargesService } from "../services/charges.service";
|
|
4
|
+
async function refreshChargePixAction(chargeId) {
|
|
5
|
+
return safeMutationAction(() => chargesService.refreshPix(chargeId));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
refreshChargePixAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=refresh-pix.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/charges/actions/refresh-pix.action.ts"],"sourcesContent":["'use server';\n\nimport { safeMutationAction } from '../../../utils/safeMutationAction';\nimport { chargesService } from '../services/charges.service';\n\nexport async function refreshChargePixAction(chargeId: string) {\n return safeMutationAction(() => chargesService.refreshPix(chargeId));\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAE/B,eAAsB,uBAAuB,UAAkB;AAC7D,SAAO,mBAAmB,MAAM,eAAe,WAAW,QAAQ,CAAC;AACrE;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
|
+
import { getNotaFiscalAction } from "../actions/get-nota-fiscal.action";
|
|
5
|
+
function useNotaFiscal() {
|
|
6
|
+
return useMutation({
|
|
7
|
+
mutationFn: (chargeId) => withAction(getNotaFiscalAction)(chargeId)
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
useNotaFiscal
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=nota-fiscal.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/charges/hooks/nota-fiscal.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { getNotaFiscalAction } from '../actions/get-nota-fiscal.action';\nimport type { NotaFiscalResult } from '../types/nota-fiscal.type';\n\n/** Busca sob demanda a nota fiscal de uma cobrança: `{ emitida, notas[] }` com os links. */\nexport function useNotaFiscal() {\n return useMutation<NotaFiscalResult, Error, number | string>({\n mutationFn: (chargeId) => withAction(getNotaFiscalAction)(chargeId),\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AAI7B,SAAS,gBAAgB;AAC9B,SAAO,YAAsD;AAAA,IAC3D,YAAY,CAAC,aAAa,WAAW,mBAAmB,EAAE,QAAQ;AAAA,EACpE,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
|
+
import { refreshChargePixAction } from "../actions/refresh-pix.action";
|
|
5
|
+
function useRefreshChargePix() {
|
|
6
|
+
return useMutation({
|
|
7
|
+
mutationFn: (chargeId) => withAction(refreshChargePixAction)(chargeId)
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
useRefreshChargePix
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=refresh-pix.hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/charges/hooks/refresh-pix.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { refreshChargePixAction } from '../actions/refresh-pix.action';\nimport type { PixRefreshResult } from '../types/refresh-pix.type';\n\n/** Regenera o PIX de uma fatura aberta (\"Ver código PIX\"). */\nexport function useRefreshChargePix() {\n return useMutation<PixRefreshResult, Error, string>({\n mutationFn: (chargeId) => withAction(refreshChargePixAction)(chargeId),\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,8BAA8B;AAIhC,SAAS,sBAAsB;AACpC,SAAO,YAA6C;AAAA,IAClD,YAAY,CAAC,aAAa,WAAW,sBAAsB,EAAE,QAAQ;AAAA,EACvE,CAAC;AACH;","names":[]}
|
|
@@ -3,6 +3,28 @@ import { api } from "../../../infra/api/client";
|
|
|
3
3
|
import { ApiError } from "../../../infra/api/types";
|
|
4
4
|
import { buildQueryParams } from "../../../infra/utils/params";
|
|
5
5
|
import { getUserContext } from "../../auth/utils/get-user-context";
|
|
6
|
+
const asString = (value) => typeof value === "string" && value.length > 0 ? value : null;
|
|
7
|
+
function extractNotaLinks(invoice) {
|
|
8
|
+
if (!invoice) return [];
|
|
9
|
+
const candidates = [];
|
|
10
|
+
if (Array.isArray(invoice.ListaNFes)) {
|
|
11
|
+
candidates.push(...invoice.ListaNFes);
|
|
12
|
+
}
|
|
13
|
+
if (invoice.nfe && typeof invoice.nfe === "object") {
|
|
14
|
+
candidates.push(invoice.nfe);
|
|
15
|
+
}
|
|
16
|
+
if (candidates.length === 0) {
|
|
17
|
+
candidates.push(invoice);
|
|
18
|
+
}
|
|
19
|
+
return candidates.map((item) => {
|
|
20
|
+
const prefeitura = item.prefeitura && typeof item.prefeitura === "object" ? item.prefeitura : {};
|
|
21
|
+
return {
|
|
22
|
+
situacao: asString(item.situacao),
|
|
23
|
+
linkPdf: asString(item.linkDownloadPDF) ?? asString(item.linkDownload) ?? asString(item.linkVisualizacao) ?? asString(prefeitura.linkImpressao),
|
|
24
|
+
linkXml: asString(item.linkDownloadXML) ?? asString(item.linkXml) ?? asString(prefeitura.linkXml)
|
|
25
|
+
};
|
|
26
|
+
}).filter((nota) => nota.linkPdf || nota.linkXml);
|
|
27
|
+
}
|
|
6
28
|
class ChargesService {
|
|
7
29
|
async listCharges(params) {
|
|
8
30
|
const { id_account } = await getUserContext();
|
|
@@ -44,6 +66,51 @@ class ChargesService {
|
|
|
44
66
|
}
|
|
45
67
|
return { data: response.data[0], success: true };
|
|
46
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Nota fiscal (eNotas) emitida para a cobrança. Vale para Stripe (id `in_xxx`) e Vindi (id
|
|
71
|
+
* numérico) — o backend resolve a venda pelo metadata da invoice ou pela coluna da charge.
|
|
72
|
+
*/
|
|
73
|
+
async getNotaFiscal(chargeId) {
|
|
74
|
+
const { id_account } = await getUserContext();
|
|
75
|
+
const response = await api.apps.get(
|
|
76
|
+
`/charges/${chargeId}/action/nota-fiscal?${buildQueryParams({ id_account })}`
|
|
77
|
+
);
|
|
78
|
+
if (response.status === 0) {
|
|
79
|
+
throw new ApiError(
|
|
80
|
+
response.message || "N\xE3o foi poss\xEDvel consultar a nota fiscal",
|
|
81
|
+
"GET_NOTA_FISCAL_FAILED",
|
|
82
|
+
400
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
const notas = extractNotaLinks(response.data?.[0]?.invoice ?? null);
|
|
86
|
+
return { emitida: notas.length > 0, notas };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Recarrega o PIX de uma fatura aberta ("Ver código PIX"). Devolve o mesmo QR se ainda válido,
|
|
90
|
+
* ou gera outro se expirou. Cobrança automática (mandato) volta `recurring: true`, sem QR manual.
|
|
91
|
+
*/
|
|
92
|
+
async refreshPix(chargeId) {
|
|
93
|
+
const response = await api.apps.post(
|
|
94
|
+
`/charges/${chargeId}/action/pix-refresh`,
|
|
95
|
+
{}
|
|
96
|
+
);
|
|
97
|
+
if (response.status === 0) {
|
|
98
|
+
throw new ApiError(response.message || "N\xE3o foi poss\xEDvel gerar o PIX", "REFRESH_PIX_FAILED", 400);
|
|
99
|
+
}
|
|
100
|
+
const row = response.data?.[0] ?? null;
|
|
101
|
+
const pix = row?.pix ?? null;
|
|
102
|
+
return {
|
|
103
|
+
recurring: Boolean(row?.recurring),
|
|
104
|
+
pix: pix ? {
|
|
105
|
+
qr_code: pix.qr_code ?? null,
|
|
106
|
+
qr_code_image: pix.qr_code_image ?? null,
|
|
107
|
+
payment_link: pix.payment_link ?? null,
|
|
108
|
+
expires_at: pix.expires_at ?? null,
|
|
109
|
+
correlation_id: pix.correlation_id ?? null
|
|
110
|
+
} : null,
|
|
111
|
+
message: response.message ?? null
|
|
112
|
+
};
|
|
113
|
+
}
|
|
47
114
|
}
|
|
48
115
|
const chargesService = new ChargesService();
|
|
49
116
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/charges/services/charges.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { ApiError, ApiActionResult, ApiPaginatedActionResult, PaginatedSuccessResult, SuccessResult } from '../../../infra/api/types';\nimport { buildQueryParams } from '../../../infra/utils/params';\nimport { getUserContext } from '../../auth/utils/get-user-context';\nimport { Charge, FindChargesParams, PayChargeInput } from '../types/charge.type';\n\nclass ChargesService {\n async listCharges(params?: Partial<FindChargesParams>): Promise<PaginatedSuccessResult<Charge>> {\n const { id_account } = await getUserContext();\n\n const query = buildQueryParams({ ...params, id_account });\n\n const response = await api.apps.get<ApiPaginatedActionResult<Charge>>(`/charges?${query}`);\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao listar cobranças',\n 'LIST_CHARGES_FAILED',\n 400\n );\n }\n\n return { data: response.data, total: response.total, success: true };\n }\n\n async chargeAction(data: PayChargeInput): Promise<SuccessResult<void>> {\n const response = await api.apps.put<ApiActionResult<void>>(\n `/charges/${data.chargeId}/action/charge`,\n {\n payment_method: data.paymentMethod,\n payment_method_id: data.paymentMethodId,\n }\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao processar cobrança',\n 'CHARGE_ACTION_FAILED',\n 400\n );\n }\n\n return { success: true, data: undefined };\n }\n\n async findChargeById(chargeId: string | number): Promise<SuccessResult<Charge>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.get<ApiPaginatedActionResult<Charge>>(\n `/charges/${chargeId}?id_account=${id_account}`\n );\n\n if (response.status === 0) {\n throw new ApiError(response.message || 'Erro ao buscar cobrança', 'FIND_CHARGE_FAILED', 400);\n }\n\n return { data: response.data[0], success: true };\n }\n}\n\nexport const chargesService = new ChargesService();\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAAkG;AAC3G,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/charges/services/charges.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { ApiError, ApiActionResult, ApiPaginatedActionResult, PaginatedSuccessResult, SuccessResult } from '../../../infra/api/types';\nimport { buildQueryParams } from '../../../infra/utils/params';\nimport { getUserContext } from '../../auth/utils/get-user-context';\nimport { Charge, FindChargesParams, PayChargeInput } from '../types/charge.type';\nimport type { NotaFiscalLink, NotaFiscalResult } from '../types/nota-fiscal.type';\nimport type { PixRefreshResult } from '../types/refresh-pix.type';\n\ntype NotaFiscalApiResponse = {\n status: number;\n message?: string;\n data?: Array<{ invoice?: Record<string, unknown> | null }>;\n};\n\ntype PixRefreshApiResponse = {\n status: number;\n message?: string;\n data?: Array<{\n recurring?: boolean;\n pix?: {\n qr_code?: string | null;\n qr_code_image?: string | null;\n payment_link?: string | null;\n expires_at?: string | null;\n correlation_id?: string | null;\n } | null;\n }>;\n};\n\nconst asString = (value: unknown): string | null =>\n typeof value === 'string' && value.length > 0 ? value : null;\n\n/**\n * Normaliza a venda do eNotas (shape variável) numa lista de links: a venda pode trazer\n * `ListaNFes` (array), `nfe` (objeto) ou os campos no topo. Os links só vêm preenchidos depois\n * que a nota é autorizada — ficam nulos enquanto a emissão está na fila.\n */\nfunction extractNotaLinks(invoice: Record<string, unknown> | null | undefined): NotaFiscalLink[] {\n if (!invoice) return [];\n\n const candidates: Record<string, unknown>[] = [];\n if (Array.isArray(invoice.ListaNFes)) {\n candidates.push(...(invoice.ListaNFes as Record<string, unknown>[]));\n }\n if (invoice.nfe && typeof invoice.nfe === 'object') {\n candidates.push(invoice.nfe as Record<string, unknown>);\n }\n if (candidates.length === 0) {\n candidates.push(invoice);\n }\n\n return candidates\n .map((item) => {\n const prefeitura =\n item.prefeitura && typeof item.prefeitura === 'object'\n ? (item.prefeitura as Record<string, unknown>)\n : {};\n\n return {\n situacao: asString(item.situacao),\n linkPdf:\n asString(item.linkDownloadPDF) ??\n asString(item.linkDownload) ??\n asString(item.linkVisualizacao) ??\n asString(prefeitura.linkImpressao),\n linkXml:\n asString(item.linkDownloadXML) ?? asString(item.linkXml) ?? asString(prefeitura.linkXml),\n };\n })\n .filter((nota) => nota.linkPdf || nota.linkXml);\n}\n\nclass ChargesService {\n async listCharges(params?: Partial<FindChargesParams>): Promise<PaginatedSuccessResult<Charge>> {\n const { id_account } = await getUserContext();\n\n const query = buildQueryParams({ ...params, id_account });\n\n const response = await api.apps.get<ApiPaginatedActionResult<Charge>>(`/charges?${query}`);\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao listar cobranças',\n 'LIST_CHARGES_FAILED',\n 400\n );\n }\n\n return { data: response.data, total: response.total, success: true };\n }\n\n async chargeAction(data: PayChargeInput): Promise<SuccessResult<void>> {\n const response = await api.apps.put<ApiActionResult<void>>(\n `/charges/${data.chargeId}/action/charge`,\n {\n payment_method: data.paymentMethod,\n payment_method_id: data.paymentMethodId,\n }\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao processar cobrança',\n 'CHARGE_ACTION_FAILED',\n 400\n );\n }\n\n return { success: true, data: undefined };\n }\n\n async findChargeById(chargeId: string | number): Promise<SuccessResult<Charge>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.get<ApiPaginatedActionResult<Charge>>(\n `/charges/${chargeId}?id_account=${id_account}`\n );\n\n if (response.status === 0) {\n throw new ApiError(response.message || 'Erro ao buscar cobrança', 'FIND_CHARGE_FAILED', 400);\n }\n\n return { data: response.data[0], success: true };\n }\n\n /**\n * Nota fiscal (eNotas) emitida para a cobrança. Vale para Stripe (id `in_xxx`) e Vindi (id\n * numérico) — o backend resolve a venda pelo metadata da invoice ou pela coluna da charge.\n */\n async getNotaFiscal(chargeId: number | string): Promise<NotaFiscalResult> {\n const { id_account } = await getUserContext();\n const response = await api.apps.get<NotaFiscalApiResponse>(\n `/charges/${chargeId}/action/nota-fiscal?${buildQueryParams({ id_account })}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Não foi possível consultar a nota fiscal',\n 'GET_NOTA_FISCAL_FAILED',\n 400\n );\n }\n\n const notas = extractNotaLinks(response.data?.[0]?.invoice ?? null);\n\n return { emitida: notas.length > 0, notas };\n }\n\n /**\n * Recarrega o PIX de uma fatura aberta (\"Ver código PIX\"). Devolve o mesmo QR se ainda válido,\n * ou gera outro se expirou. Cobrança automática (mandato) volta `recurring: true`, sem QR manual.\n */\n async refreshPix(chargeId: string): Promise<PixRefreshResult> {\n const response = await api.apps.post<PixRefreshApiResponse>(\n `/charges/${chargeId}/action/pix-refresh`,\n {}\n );\n\n if (response.status === 0) {\n throw new ApiError(response.message || 'Não foi possível gerar o PIX', 'REFRESH_PIX_FAILED', 400);\n }\n\n const row = response.data?.[0] ?? null;\n const pix = row?.pix ?? null;\n\n return {\n recurring: Boolean(row?.recurring),\n pix: pix\n ? {\n qr_code: pix.qr_code ?? null,\n qr_code_image: pix.qr_code_image ?? null,\n payment_link: pix.payment_link ?? null,\n expires_at: pix.expires_at ?? null,\n correlation_id: pix.correlation_id ?? null,\n }\n : null,\n message: response.message ?? null,\n };\n }\n}\n\nexport const chargesService = new ChargesService();\n"],"mappings":"AAAA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,SAAS,MAAM,SAAS,GAAG,MAAM;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAAW,UAA6C;AAC5D,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,YAAY,QAAQ;AAAA,MACpB,CAAC;AAAA,IACH;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI,SAAS,SAAS,WAAW,sCAAgC,sBAAsB,GAAG;AAAA,IAClG;AAEA,UAAM,MAAM,SAAS,OAAO,CAAC,KAAK;AAClC,UAAM,MAAM,KAAK,OAAO;AAExB,WAAO;AAAA,MACL,WAAW,QAAQ,KAAK,SAAS;AAAA,MACjC,KAAK,MACD;AAAA,QACE,SAAS,IAAI,WAAW;AAAA,QACxB,eAAe,IAAI,iBAAiB;AAAA,QACpC,cAAc,IAAI,gBAAgB;AAAA,QAClC,YAAY,IAAI,cAAc;AAAA,QAC9B,gBAAgB,IAAI,kBAAkB;AAAA,MACxC,IACA;AAAA,MACJ,SAAS,SAAS,WAAW;AAAA,IAC/B;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,IAAI,eAAe;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=nota-fiscal.type.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=refresh-pix.type.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/charges/utils/get-charge-download-url.ts"],"sourcesContent":["import type { Charge } from '../types/charge.type';\n\n/**\n * URL pra baixar o recibo/boleto de uma charge, ou null quando nenhuma URL está disponível\n * (caso comum em charges antigas Vindi/enotas que não expõem invoice_url/invoice_pdf/gateway_billet).\n */\nexport function getChargeDownloadUrl(charge: Charge | null | undefined): string | null {\n if (!charge) return null;\n return charge.invoice_pdf || charge.invoice_url || charge.gateway_billet || null;\n}\n"],"mappings":"AAMO,SAAS,qBAAqB,QAAkD;AACrF,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,OAAO,eAAe,OAAO,eAAe,OAAO,kBAAkB;AAC9E;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/coupons/constants/query-keys.constants.ts"],"sourcesContent":["export const COUPON_QUERY_KEY = ['coupon'] as const;\n"],"mappings":"AAAO,MAAM,mBAAmB,CAAC,QAAQ;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { ApiError } from "../../../infra/api/types";
|
|
3
|
+
import { safeRouteHandler } from "../../../infra/route/safe-route-handler";
|
|
4
|
+
import { couponsService } from "../services/coupons.service";
|
|
5
|
+
function createFindCouponByCodeHandler() {
|
|
6
|
+
return async function GET(req) {
|
|
7
|
+
return safeRouteHandler(() => {
|
|
8
|
+
const code = req.nextUrl.searchParams.get("code");
|
|
9
|
+
if (!code) throw new ApiError("Informe o c\xF3digo do cupom", "COUPON_CODE_REQUIRED", 400);
|
|
10
|
+
return couponsService.getCouponByCode(code);
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
createFindCouponByCodeHandler
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=find-coupon-by-code.handler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/coupons/handlers/find-coupon-by-code.handler.ts"],"sourcesContent":["import 'server-only';\n\nimport type { NextRequest } from 'next/server';\nimport { ApiError } from '../../../infra/api/types';\nimport { safeRouteHandler } from '../../../infra/route/safe-route-handler';\nimport { couponsService } from '../services/coupons.service';\n\nexport function createFindCouponByCodeHandler() {\n return async function GET(req: NextRequest) {\n return safeRouteHandler(() => {\n const code = req.nextUrl.searchParams.get('code');\n if (!code) throw new ApiError('Informe o código do cupom', 'COUPON_CODE_REQUIRED', 400);\n return couponsService.getCouponByCode(code);\n });\n };\n}\n"],"mappings":"AAAA,OAAO;AAGP,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAExB,SAAS,gCAAgC;AAC9C,SAAO,eAAe,IAAI,KAAkB;AAC1C,WAAO,iBAAiB,MAAM;AAC5B,YAAM,OAAO,IAAI,QAAQ,aAAa,IAAI,MAAM;AAChD,UAAI,CAAC,KAAM,OAAM,IAAI,SAAS,gCAA6B,wBAAwB,GAAG;AACtF,aAAO,eAAe,gBAAgB,IAAI;AAAA,IAC5C,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { parseId } from "../../../infra/route/parse-id";
|
|
3
|
+
import { safeRouteHandler } from "../../../infra/route/safe-route-handler";
|
|
4
|
+
import { couponsService } from "../services/coupons.service";
|
|
5
|
+
function createFindCouponByIdHandler() {
|
|
6
|
+
return async function GET(_req, { params }) {
|
|
7
|
+
return safeRouteHandler(async () => {
|
|
8
|
+
const { id } = await params;
|
|
9
|
+
return couponsService.getCouponById(parseId(id));
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
createFindCouponByIdHandler
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=find-coupon-by-id.handler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/coupons/handlers/find-coupon-by-id.handler.ts"],"sourcesContent":["import 'server-only';\n\nimport type { NextRequest } from 'next/server';\nimport { parseId } from '../../../infra/route/parse-id';\nimport { safeRouteHandler } from '../../../infra/route/safe-route-handler';\nimport { couponsService } from '../services/coupons.service';\n\nexport function createFindCouponByIdHandler() {\n return async function GET(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {\n return safeRouteHandler(async () => {\n const { id } = await params;\n return couponsService.getCouponById(parseId(id));\n });\n };\n}\n"],"mappings":"AAAA,OAAO;AAGP,SAAS,eAAe;AACxB,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAExB,SAAS,8BAA8B;AAC5C,SAAO,eAAe,IAAI,MAAmB,EAAE,OAAO,GAAwC;AAC5F,WAAO,iBAAiB,YAAY;AAClC,YAAM,EAAE,GAAG,IAAI,MAAM;AACrB,aAAO,eAAe,cAAc,QAAQ,EAAE,CAAC;AAAA,IACjD,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { apiFetch } from "../../../infra/http/api-fetch";
|
|
4
|
+
function useCouponByCode() {
|
|
5
|
+
return useMutation({
|
|
6
|
+
mutationFn: async (code) => {
|
|
7
|
+
const result = await apiFetch("/api/coupons", { params: { code } });
|
|
8
|
+
return result.data;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useCouponByCode
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=use-coupon-by-code.hook.mjs.map
|