@greatapps/common 1.1.790 → 1.1.792

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.
Files changed (791) hide show
  1. package/dist/components/account/AccountHubLinkHandler.mjs +36 -0
  2. package/dist/components/account/AccountHubLinkHandler.mjs.map +1 -0
  3. package/dist/components/account/AccountModalLayout.mjs +137 -0
  4. package/dist/components/account/AccountModalLayout.mjs.map +1 -0
  5. package/dist/components/account/AccountModals.mjs +10 -3
  6. package/dist/components/account/AccountModals.mjs.map +1 -1
  7. package/dist/components/account/AccountUnsavedChangesDialog.mjs +34 -0
  8. package/dist/components/account/AccountUnsavedChangesDialog.mjs.map +1 -0
  9. package/dist/components/account/DeleteAccountModal.mjs +1 -1
  10. package/dist/components/account/DeleteAccountModal.mjs.map +1 -1
  11. package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +8 -1
  12. package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -1
  13. package/dist/components/account/MyAccountModal.mjs +173 -0
  14. package/dist/components/account/MyAccountModal.mjs.map +1 -0
  15. package/dist/components/account/TwoFactorAuthModal.mjs +1 -1
  16. package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -1
  17. package/dist/components/account/hooks/useAccountHubActions.mjs +85 -0
  18. package/dist/components/account/hooks/useAccountHubActions.mjs.map +1 -0
  19. package/dist/components/account/hooks/useAddCardWithPaymentSwitch.mjs +44 -0
  20. package/dist/components/account/hooks/useAddCardWithPaymentSwitch.mjs.map +1 -0
  21. package/dist/components/account/hooks/useAffiliatesActions.mjs +69 -0
  22. package/dist/components/account/hooks/useAffiliatesActions.mjs.map +1 -0
  23. package/dist/components/account/hooks/useMyAccountModal.mjs +27 -0
  24. package/dist/components/account/hooks/useMyAccountModal.mjs.map +1 -0
  25. package/dist/components/account/hooks/useProjectsActions.mjs +40 -0
  26. package/dist/components/account/hooks/useProjectsActions.mjs.map +1 -0
  27. package/dist/components/account/hooks/useSubscriptionActions.mjs +87 -0
  28. package/dist/components/account/hooks/useSubscriptionActions.mjs.map +1 -0
  29. package/dist/components/account/hooks/useTeamActions.mjs +31 -0
  30. package/dist/components/account/hooks/useTeamActions.mjs.map +1 -0
  31. package/dist/components/account/sections/AffiliatesSection.mjs +313 -0
  32. package/dist/components/account/sections/AffiliatesSection.mjs.map +1 -0
  33. package/dist/components/account/sections/ChangePasswordSection.mjs +5 -5
  34. package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -1
  35. package/dist/components/account/sections/MyProfileSection.mjs +212 -164
  36. package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
  37. package/dist/components/account/sections/PreferencesSection.mjs +74 -68
  38. package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
  39. package/dist/components/account/sections/ProjectsSection.mjs +77 -0
  40. package/dist/components/account/sections/ProjectsSection.mjs.map +1 -0
  41. package/dist/components/account/sections/SecuritySection.mjs +55 -36
  42. package/dist/components/account/sections/SecuritySection.mjs.map +1 -1
  43. package/dist/components/account/sections/SubscriptionSection.mjs +29 -0
  44. package/dist/components/account/sections/SubscriptionSection.mjs.map +1 -0
  45. package/dist/components/account/sections/TeamSection.mjs +119 -0
  46. package/dist/components/account/sections/TeamSection.mjs.map +1 -0
  47. package/dist/components/account/sections/TokenSection.mjs +41 -43
  48. package/dist/components/account/sections/TokenSection.mjs.map +1 -1
  49. package/dist/components/account/sections/affiliates/AffiliateCommissionCard.mjs +73 -0
  50. package/dist/components/account/sections/affiliates/AffiliateCommissionCard.mjs.map +1 -0
  51. package/dist/components/account/sections/affiliates/AffiliateFlows.mjs +20 -0
  52. package/dist/components/account/sections/affiliates/AffiliateFlows.mjs.map +1 -0
  53. package/dist/components/account/sections/affiliates/AffiliateLeadsSheet.mjs +99 -0
  54. package/dist/components/account/sections/affiliates/AffiliateLeadsSheet.mjs.map +1 -0
  55. package/dist/components/account/sections/affiliates/AffiliateStatsCard.mjs +31 -0
  56. package/dist/components/account/sections/affiliates/AffiliateStatsCard.mjs.map +1 -0
  57. package/dist/components/account/sections/affiliates/AffiliateStepCard.mjs +15 -0
  58. package/dist/components/account/sections/affiliates/AffiliateStepCard.mjs.map +1 -0
  59. package/dist/components/account/sections/affiliates/AffiliateTransactionsList.mjs +108 -0
  60. package/dist/components/account/sections/affiliates/AffiliateTransactionsList.mjs.map +1 -0
  61. package/dist/components/account/sections/affiliates/NoReceivingAccountModal.mjs +49 -0
  62. package/dist/components/account/sections/affiliates/NoReceivingAccountModal.mjs.map +1 -0
  63. package/dist/components/account/sections/affiliates/ReceivingAccountModal.mjs +182 -0
  64. package/dist/components/account/sections/affiliates/ReceivingAccountModal.mjs.map +1 -0
  65. package/dist/components/account/sections/affiliates/RequestWithdrawalSheet.mjs +476 -0
  66. package/dist/components/account/sections/affiliates/RequestWithdrawalSheet.mjs.map +1 -0
  67. package/dist/components/account/sections/affiliates/ViewAttachmentModal.mjs +34 -0
  68. package/dist/components/account/sections/affiliates/ViewAttachmentModal.mjs.map +1 -0
  69. package/dist/components/account/sections/affiliates/reports/AffiliatesIndicatorsChart.mjs +27 -0
  70. package/dist/components/account/sections/affiliates/reports/AffiliatesIndicatorsChart.mjs.map +1 -0
  71. package/dist/components/account/sections/affiliates/reports/AffiliatesReportsTab.mjs +30 -0
  72. package/dist/components/account/sections/affiliates/reports/AffiliatesReportsTab.mjs.map +1 -0
  73. package/dist/components/account/sections/affiliates/reports/useAffiliatesIndicatorsChart.mjs +120 -0
  74. package/dist/components/account/sections/affiliates/reports/useAffiliatesIndicatorsChart.mjs.map +1 -0
  75. package/dist/components/account/sections/projects/DeleteProjectModal.mjs +205 -0
  76. package/dist/components/account/sections/projects/DeleteProjectModal.mjs.map +1 -0
  77. package/dist/components/account/sections/projects/ProjectFlows.mjs +16 -0
  78. package/dist/components/account/sections/projects/ProjectFlows.mjs.map +1 -0
  79. package/dist/components/account/sections/projects/ProjectMembersStack.mjs +53 -0
  80. package/dist/components/account/sections/projects/ProjectMembersStack.mjs.map +1 -0
  81. package/dist/components/account/sections/projects/ProjectRow.mjs +85 -0
  82. package/dist/components/account/sections/projects/ProjectRow.mjs.map +1 -0
  83. package/dist/components/account/sections/projects/ProjectSheet.mjs +499 -0
  84. package/dist/components/account/sections/projects/ProjectSheet.mjs.map +1 -0
  85. package/dist/components/account/sections/projects/ProjectsDisabledModal.mjs +55 -0
  86. package/dist/components/account/sections/projects/ProjectsDisabledModal.mjs.map +1 -0
  87. package/dist/components/account/sections/projects/project-form.schema.mjs +28 -0
  88. package/dist/components/account/sections/projects/project-form.schema.mjs.map +1 -0
  89. package/dist/components/account/sections/shared/ConnectListRow.mjs +45 -0
  90. package/dist/components/account/sections/shared/ConnectListRow.mjs.map +1 -0
  91. package/dist/components/account/sections/shared/DateFilterPopover.mjs +51 -0
  92. package/dist/components/account/sections/shared/DateFilterPopover.mjs.map +1 -0
  93. package/dist/components/account/sections/shared/EntityAvatar.mjs +41 -0
  94. package/dist/components/account/sections/shared/EntityAvatar.mjs.map +1 -0
  95. package/dist/components/account/sections/shared/FilterPopover.mjs +62 -0
  96. package/dist/components/account/sections/shared/FilterPopover.mjs.map +1 -0
  97. package/dist/components/account/sections/shared/FormSection.mjs +14 -0
  98. package/dist/components/account/sections/shared/FormSection.mjs.map +1 -0
  99. package/dist/components/account/sections/shared/IconBox.mjs +18 -0
  100. package/dist/components/account/sections/shared/IconBox.mjs.map +1 -0
  101. package/dist/components/account/sections/shared/InfiniteScrollList.mjs +36 -0
  102. package/dist/components/account/sections/shared/InfiniteScrollList.mjs.map +1 -0
  103. package/dist/components/account/sections/shared/ListPagination.mjs +69 -0
  104. package/dist/components/account/sections/shared/ListPagination.mjs.map +1 -0
  105. package/dist/components/account/sections/shared/RowActionsMenu.mjs +52 -0
  106. package/dist/components/account/sections/shared/RowActionsMenu.mjs.map +1 -0
  107. package/dist/components/account/sections/shared/SectionLoadError.mjs +20 -0
  108. package/dist/components/account/sections/shared/SectionLoadError.mjs.map +1 -0
  109. package/dist/components/account/sections/shared/StatusBadge.mjs +26 -0
  110. package/dist/components/account/sections/shared/StatusBadge.mjs.map +1 -0
  111. package/dist/components/account/sections/shared/WorkspaceSection.mjs +10 -0
  112. package/dist/components/account/sections/shared/WorkspaceSection.mjs.map +1 -0
  113. package/dist/components/account/sections/subscription/AiCreditsUsage.mjs +106 -0
  114. package/dist/components/account/sections/subscription/AiCreditsUsage.mjs.map +1 -0
  115. package/dist/components/account/sections/subscription/BillingAddressSheet.mjs +407 -0
  116. package/dist/components/account/sections/subscription/BillingAddressSheet.mjs.map +1 -0
  117. package/dist/components/account/sections/subscription/BoletoDetailsDialog.mjs +73 -0
  118. package/dist/components/account/sections/subscription/BoletoDetailsDialog.mjs.map +1 -0
  119. package/dist/components/account/sections/subscription/BoletoGeneratedDialog.mjs +22 -0
  120. package/dist/components/account/sections/subscription/BoletoGeneratedDialog.mjs.map +1 -0
  121. package/dist/components/account/sections/subscription/CancelPlanDialog.mjs +161 -0
  122. package/dist/components/account/sections/subscription/CancelPlanDialog.mjs.map +1 -0
  123. package/dist/components/account/sections/subscription/ChargeRow.mjs +127 -0
  124. package/dist/components/account/sections/subscription/ChargeRow.mjs.map +1 -0
  125. package/dist/components/account/sections/subscription/ChargeStatusBadge.mjs +27 -0
  126. package/dist/components/account/sections/subscription/ChargeStatusBadge.mjs.map +1 -0
  127. package/dist/components/account/sections/subscription/ChargesList.mjs +88 -0
  128. package/dist/components/account/sections/subscription/ChargesList.mjs.map +1 -0
  129. package/dist/components/account/sections/subscription/ManageCardsSheet.mjs +49 -0
  130. package/dist/components/account/sections/subscription/ManageCardsSheet.mjs.map +1 -0
  131. package/dist/components/account/sections/subscription/OverdueReceiptOpener.mjs +26 -0
  132. package/dist/components/account/sections/subscription/OverdueReceiptOpener.mjs.map +1 -0
  133. package/dist/components/account/sections/subscription/PayChargeDialog.mjs +222 -0
  134. package/dist/components/account/sections/subscription/PayChargeDialog.mjs.map +1 -0
  135. package/dist/components/account/sections/subscription/PaymentConfirmationDialog.mjs +61 -0
  136. package/dist/components/account/sections/subscription/PaymentConfirmationDialog.mjs.map +1 -0
  137. package/dist/components/account/sections/subscription/PaymentMethodsCard.mjs +72 -0
  138. package/dist/components/account/sections/subscription/PaymentMethodsCard.mjs.map +1 -0
  139. package/dist/components/account/sections/subscription/PendingChangeDialog.mjs +117 -0
  140. package/dist/components/account/sections/subscription/PendingChangeDialog.mjs.map +1 -0
  141. package/dist/components/account/sections/subscription/PixDetailsDialog.mjs +165 -0
  142. package/dist/components/account/sections/subscription/PixDetailsDialog.mjs.map +1 -0
  143. package/dist/components/account/sections/subscription/PixPaymentDialog.mjs +155 -0
  144. package/dist/components/account/sections/subscription/PixPaymentDialog.mjs.map +1 -0
  145. package/dist/components/account/sections/subscription/PlanDetailsSheet.mjs +253 -0
  146. package/dist/components/account/sections/subscription/PlanDetailsSheet.mjs.map +1 -0
  147. package/dist/components/account/sections/subscription/ReceiptDetailsSheet.mjs +237 -0
  148. package/dist/components/account/sections/subscription/ReceiptDetailsSheet.mjs.map +1 -0
  149. package/dist/components/account/sections/subscription/SubscriptionFlows.mjs +40 -0
  150. package/dist/components/account/sections/subscription/SubscriptionFlows.mjs.map +1 -0
  151. package/dist/components/account/sections/subscription/SubscriptionPlanCard.mjs +303 -0
  152. package/dist/components/account/sections/subscription/SubscriptionPlanCard.mjs.map +1 -0
  153. package/dist/components/account/sections/subscription/UsageReportSheet.mjs +163 -0
  154. package/dist/components/account/sections/subscription/UsageReportSheet.mjs.map +1 -0
  155. package/dist/components/account/sections/subscription/change-plan/ChangePlanSheet.mjs +75 -0
  156. package/dist/components/account/sections/subscription/change-plan/ChangePlanSheet.mjs.map +1 -0
  157. package/dist/components/account/sections/subscription/change-plan/components/AbTestDetailsDialog.mjs +55 -0
  158. package/dist/components/account/sections/subscription/change-plan/components/AbTestDetailsDialog.mjs.map +1 -0
  159. package/dist/components/account/sections/subscription/change-plan/components/AddonsBlock.mjs +188 -0
  160. package/dist/components/account/sections/subscription/change-plan/components/AddonsBlock.mjs.map +1 -0
  161. package/dist/components/account/sections/subscription/change-plan/components/AlternativeBucketsSection.mjs +66 -0
  162. package/dist/components/account/sections/subscription/change-plan/components/AlternativeBucketsSection.mjs.map +1 -0
  163. package/dist/components/account/sections/subscription/change-plan/components/CouponBlock.mjs +42 -0
  164. package/dist/components/account/sections/subscription/change-plan/components/CouponBlock.mjs.map +1 -0
  165. package/dist/components/account/sections/subscription/change-plan/components/CouponDialog.mjs +119 -0
  166. package/dist/components/account/sections/subscription/change-plan/components/CouponDialog.mjs.map +1 -0
  167. package/dist/components/account/sections/subscription/change-plan/components/PricePreview.mjs +17 -0
  168. package/dist/components/account/sections/subscription/change-plan/components/PricePreview.mjs.map +1 -0
  169. package/dist/components/account/sections/subscription/change-plan/components/SummaryBlock.mjs +130 -0
  170. package/dist/components/account/sections/subscription/change-plan/components/SummaryBlock.mjs.map +1 -0
  171. package/dist/components/account/sections/subscription/change-plan/plan-comparison.mjs +38 -0
  172. package/dist/components/account/sections/subscription/change-plan/plan-comparison.mjs.map +1 -0
  173. package/dist/components/account/sections/subscription/change-plan/steps/PaymentSummaryStep.mjs +127 -0
  174. package/dist/components/account/sections/subscription/change-plan/steps/PaymentSummaryStep.mjs.map +1 -0
  175. package/dist/components/account/sections/subscription/change-plan/steps/PlanComparisonStep.mjs +111 -0
  176. package/dist/components/account/sections/subscription/change-plan/steps/PlanComparisonStep.mjs.map +1 -0
  177. package/dist/components/account/sections/subscription/change-plan/steps/PlanViewStep.mjs +69 -0
  178. package/dist/components/account/sections/subscription/change-plan/steps/PlanViewStep.mjs.map +1 -0
  179. package/dist/components/account/sections/subscription/change-plan/steps/ReactivationConfigStep.mjs +88 -0
  180. package/dist/components/account/sections/subscription/change-plan/steps/ReactivationConfigStep.mjs.map +1 -0
  181. package/dist/components/account/sections/subscription/change-plan/steps/ReactivationPaymentStep.mjs +115 -0
  182. package/dist/components/account/sections/subscription/change-plan/steps/ReactivationPaymentStep.mjs.map +1 -0
  183. package/dist/components/account/sections/subscription/change-plan/useChangePlanState.mjs +918 -0
  184. package/dist/components/account/sections/subscription/change-plan/useChangePlanState.mjs.map +1 -0
  185. package/dist/components/account/sections/subscription/downgrade/CannotDowngradeDialog.mjs +216 -0
  186. package/dist/components/account/sections/subscription/downgrade/CannotDowngradeDialog.mjs.map +1 -0
  187. package/dist/components/account/sections/subscription/downgrade/DowngradeReasonDialog.mjs +128 -0
  188. package/dist/components/account/sections/subscription/downgrade/DowngradeReasonDialog.mjs.map +1 -0
  189. package/dist/components/account/sections/subscription/plans/PlanCard.mjs +281 -0
  190. package/dist/components/account/sections/subscription/plans/PlanCard.mjs.map +1 -0
  191. package/dist/components/account/sections/subscription/plans/PlanCardSkeleton.mjs +53 -0
  192. package/dist/components/account/sections/subscription/plans/PlanCardSkeleton.mjs.map +1 -0
  193. package/dist/components/account/sections/subscription/plans/PlansCatalogDialog.mjs +119 -0
  194. package/dist/components/account/sections/subscription/plans/PlansCatalogDialog.mjs.map +1 -0
  195. package/dist/components/account/sections/team/DeleteUserModal.mjs +116 -0
  196. package/dist/components/account/sections/team/DeleteUserModal.mjs.map +1 -0
  197. package/dist/components/account/sections/team/TeamFlows.mjs +14 -0
  198. package/dist/components/account/sections/team/TeamFlows.mjs.map +1 -0
  199. package/dist/components/account/sections/team/TeamMemberRow.mjs +99 -0
  200. package/dist/components/account/sections/team/TeamMemberRow.mjs.map +1 -0
  201. package/dist/components/account/sections/team/UserSheet.mjs +570 -0
  202. package/dist/components/account/sections/team/UserSheet.mjs.map +1 -0
  203. package/dist/components/account/sections/team/steps/NotificationsStep.mjs +80 -0
  204. package/dist/components/account/sections/team/steps/NotificationsStep.mjs.map +1 -0
  205. package/dist/components/account/sections/team/steps/ProjectSelectionStep.mjs +180 -0
  206. package/dist/components/account/sections/team/steps/ProjectSelectionStep.mjs.map +1 -0
  207. package/dist/components/account/sections/team/steps/UserInformationStep.mjs +371 -0
  208. package/dist/components/account/sections/team/steps/UserInformationStep.mjs.map +1 -0
  209. package/dist/components/account/sections/team/user-form.schema.mjs +37 -0
  210. package/dist/components/account/sections/team/user-form.schema.mjs.map +1 -0
  211. package/dist/components/account/types/workspace-actions.type.mjs +1 -0
  212. package/dist/components/account/types/workspace-actions.type.mjs.map +1 -0
  213. package/dist/components/layouts/ProfilePopover.mjs +10 -12
  214. package/dist/components/layouts/ProfilePopover.mjs.map +1 -1
  215. package/dist/components/layouts/UsersSelectorPopover.mjs +7 -4
  216. package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -1
  217. package/dist/components/modals/AccountDeletionWarningModal.mjs +4 -5
  218. package/dist/components/modals/AccountDeletionWarningModal.mjs.map +1 -1
  219. package/dist/components/modals/AccountFrozenModal.mjs +6 -3
  220. package/dist/components/modals/AccountFrozenModal.mjs.map +1 -1
  221. package/dist/components/modals/Modals.mjs +3 -3
  222. package/dist/components/modals/Modals.mjs.map +1 -1
  223. package/dist/components/modals/PaidPlanRequiredModal.mjs +4 -5
  224. package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -1
  225. package/dist/components/modals/cards/AddFirstCardWarningModal.mjs +63 -0
  226. package/dist/components/modals/cards/AddFirstCardWarningModal.mjs.map +1 -0
  227. package/dist/components/modals/cards/SwitchPaymentToCardModal.mjs +187 -0
  228. package/dist/components/modals/cards/SwitchPaymentToCardModal.mjs.map +1 -0
  229. package/dist/components/modals/promo/AiCreditsOfferModal/AiCreditsOfferModal.mjs +5 -4
  230. package/dist/components/modals/promo/AiCreditsOfferModal/AiCreditsOfferModal.mjs.map +1 -1
  231. package/dist/components/ui/data-display/CardItem.mjs +9 -1
  232. package/dist/components/ui/data-display/CardItem.mjs.map +1 -1
  233. package/dist/components/ui/data-display/PaymentMethodIcons.mjs +50 -0
  234. package/dist/components/ui/data-display/PaymentMethodIcons.mjs.map +1 -0
  235. package/dist/components/ui/form/BillingPeriodSelector.mjs +108 -0
  236. package/dist/components/ui/form/BillingPeriodSelector.mjs.map +1 -0
  237. package/dist/components/ui/form/PaymentMethodToggle.mjs +82 -0
  238. package/dist/components/ui/form/PaymentMethodToggle.mjs.map +1 -0
  239. package/dist/components/ui/form/RadioOptionFieldIcon.mjs +57 -0
  240. package/dist/components/ui/form/RadioOptionFieldIcon.mjs.map +1 -0
  241. package/dist/components/ui/form/SegmentedControl.mjs +56 -0
  242. package/dist/components/ui/form/SegmentedControl.mjs.map +1 -0
  243. package/dist/components/ui/overlay/Dialog.mjs +21 -4
  244. package/dist/components/ui/overlay/Dialog.mjs.map +1 -1
  245. package/dist/components/ui/overlay/Sheet.mjs +26 -8
  246. package/dist/components/ui/overlay/Sheet.mjs.map +1 -1
  247. package/dist/components/ui/overlay/layers.mjs +52 -5
  248. package/dist/components/ui/overlay/layers.mjs.map +1 -1
  249. package/dist/enums/AccountHubFlow.mjs +13 -0
  250. package/dist/enums/AccountHubFlow.mjs.map +1 -0
  251. package/dist/enums/DateFilterPeriod.mjs +22 -0
  252. package/dist/enums/DateFilterPeriod.mjs.map +1 -0
  253. package/dist/enums/WorkspaceSectionType.mjs +11 -0
  254. package/dist/enums/WorkspaceSectionType.mjs.map +1 -0
  255. package/dist/handlers.mjs +24 -0
  256. package/dist/handlers.mjs.map +1 -1
  257. package/dist/hooks/useDebounce.mjs +5 -3
  258. package/dist/hooks/useDebounce.mjs.map +1 -1
  259. package/dist/hooks/useUploadProgress.mjs +33 -0
  260. package/dist/hooks/useUploadProgress.mjs.map +1 -0
  261. package/dist/i18n/messages/en-us.mjs +868 -3
  262. package/dist/i18n/messages/en-us.mjs.map +1 -1
  263. package/dist/i18n/messages/es-es.mjs +868 -3
  264. package/dist/i18n/messages/es-es.mjs.map +1 -1
  265. package/dist/i18n/messages/pt-br.mjs +868 -3
  266. package/dist/i18n/messages/pt-br.mjs.map +1 -1
  267. package/dist/index.mjs +87 -7
  268. package/dist/index.mjs.map +1 -1
  269. package/dist/infra/http/paged.mjs +20 -0
  270. package/dist/infra/http/paged.mjs.map +1 -0
  271. package/dist/middleware.mjs +2 -0
  272. package/dist/middleware.mjs.map +1 -1
  273. package/dist/middlewares/create-auth-middleware.mjs +2 -4
  274. package/dist/middlewares/create-auth-middleware.mjs.map +1 -1
  275. package/dist/middlewares/create-legacy-account-routes-middleware.mjs +44 -0
  276. package/dist/middlewares/create-legacy-account-routes-middleware.mjs.map +1 -0
  277. package/dist/middlewares/is-route-equals.mjs +7 -0
  278. package/dist/middlewares/is-route-equals.mjs.map +1 -0
  279. package/dist/modules/accounts/actions/account-management.action.mjs +20 -1
  280. package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -1
  281. package/dist/modules/accounts/constants/account-hub-link.constants.mjs +9 -0
  282. package/dist/modules/accounts/constants/account-hub-link.constants.mjs.map +1 -0
  283. package/dist/modules/accounts/constants/legacy-account-routes.constants.mjs +5 -0
  284. package/dist/modules/accounts/constants/legacy-account-routes.constants.mjs.map +1 -0
  285. package/dist/modules/accounts/handlers/list-account-members.handler.mjs +22 -0
  286. package/dist/modules/accounts/handlers/list-account-members.handler.mjs.map +1 -0
  287. package/dist/modules/accounts/hooks/add-user-projects.hook.mjs +51 -0
  288. package/dist/modules/accounts/hooks/add-user-projects.hook.mjs.map +1 -0
  289. package/dist/modules/accounts/hooks/create-account-user.hook.mjs +20 -0
  290. package/dist/modules/accounts/hooks/create-account-user.hook.mjs.map +1 -0
  291. package/dist/modules/accounts/hooks/remove-user-projects.hook.mjs +47 -0
  292. package/dist/modules/accounts/hooks/remove-user-projects.hook.mjs.map +1 -0
  293. package/dist/modules/accounts/hooks/use-account-members.hook.mjs +20 -0
  294. package/dist/modules/accounts/hooks/use-account-members.hook.mjs.map +1 -0
  295. package/dist/modules/accounts/services/account.service.mjs +59 -0
  296. package/dist/modules/accounts/services/account.service.mjs.map +1 -1
  297. package/dist/modules/accounts/types/account-hub-link.type.mjs +1 -0
  298. package/dist/modules/accounts/types/account-hub-link.type.mjs.map +1 -0
  299. package/dist/modules/accounts/utils/build-account-hub-url.mjs +16 -0
  300. package/dist/modules/accounts/utils/build-account-hub-url.mjs.map +1 -0
  301. package/dist/modules/accounts/utils/is-account-hub-flow.mjs +9 -0
  302. package/dist/modules/accounts/utils/is-account-hub-flow.mjs.map +1 -0
  303. package/dist/modules/accounts/utils/is-account-section.mjs +9 -0
  304. package/dist/modules/accounts/utils/is-account-section.mjs.map +1 -0
  305. package/dist/modules/accounts/utils/is-my-account-section.mjs +13 -0
  306. package/dist/modules/accounts/utils/is-my-account-section.mjs.map +1 -0
  307. package/dist/modules/accounts/utils/map-legacy-account-route.mjs +93 -0
  308. package/dist/modules/accounts/utils/map-legacy-account-route.mjs.map +1 -0
  309. package/dist/modules/accounts/utils/parse-account-hub-link.mjs +20 -0
  310. package/dist/modules/accounts/utils/parse-account-hub-link.mjs.map +1 -0
  311. package/dist/modules/affiliates/actions/ensure-affiliate.action.mjs +10 -0
  312. package/dist/modules/affiliates/actions/ensure-affiliate.action.mjs.map +1 -0
  313. package/dist/modules/affiliates/actions/request-deposit.action.mjs +10 -0
  314. package/dist/modules/affiliates/actions/request-deposit.action.mjs.map +1 -0
  315. package/dist/modules/affiliates/actions/update-affiliate.action.mjs +10 -0
  316. package/dist/modules/affiliates/actions/update-affiliate.action.mjs.map +1 -0
  317. package/dist/modules/affiliates/constants/affiliate.constants.mjs +11 -0
  318. package/dist/modules/affiliates/constants/affiliate.constants.mjs.map +1 -0
  319. package/dist/modules/affiliates/constants/query-keys.constants.mjs +15 -0
  320. package/dist/modules/affiliates/constants/query-keys.constants.mjs.map +1 -0
  321. package/dist/modules/affiliates/handlers/affiliate-report-analytics.handler.mjs +16 -0
  322. package/dist/modules/affiliates/handlers/affiliate-report-analytics.handler.mjs.map +1 -0
  323. package/dist/modules/affiliates/handlers/affiliate-withdrawal-limits.handler.mjs +12 -0
  324. package/dist/modules/affiliates/handlers/affiliate-withdrawal-limits.handler.mjs.map +1 -0
  325. package/dist/modules/affiliates/handlers/current-affiliate.handler.mjs +12 -0
  326. package/dist/modules/affiliates/handlers/current-affiliate.handler.mjs.map +1 -0
  327. package/dist/modules/affiliates/handlers/list-affiliate-coupons.handler.mjs +12 -0
  328. package/dist/modules/affiliates/handlers/list-affiliate-coupons.handler.mjs.map +1 -0
  329. package/dist/modules/affiliates/handlers/list-affiliate-leads.handler.mjs +22 -0
  330. package/dist/modules/affiliates/handlers/list-affiliate-leads.handler.mjs.map +1 -0
  331. package/dist/modules/affiliates/handlers/list-affiliate-transactions.handler.mjs +22 -0
  332. package/dist/modules/affiliates/handlers/list-affiliate-transactions.handler.mjs.map +1 -0
  333. package/dist/modules/affiliates/hooks/use-affiliate-coupons.hook.mjs +17 -0
  334. package/dist/modules/affiliates/hooks/use-affiliate-coupons.hook.mjs.map +1 -0
  335. package/dist/modules/affiliates/hooks/use-affiliate-leads.hook.mjs +22 -0
  336. package/dist/modules/affiliates/hooks/use-affiliate-leads.hook.mjs.map +1 -0
  337. package/dist/modules/affiliates/hooks/use-affiliate-report-analytics.hook.mjs +17 -0
  338. package/dist/modules/affiliates/hooks/use-affiliate-report-analytics.hook.mjs.map +1 -0
  339. package/dist/modules/affiliates/hooks/use-affiliate-transactions.hook.mjs +20 -0
  340. package/dist/modules/affiliates/hooks/use-affiliate-transactions.hook.mjs.map +1 -0
  341. package/dist/modules/affiliates/hooks/use-current-affiliate.hook.mjs +17 -0
  342. package/dist/modules/affiliates/hooks/use-current-affiliate.hook.mjs.map +1 -0
  343. package/dist/modules/affiliates/hooks/use-ensure-affiliate.hook.mjs +23 -0
  344. package/dist/modules/affiliates/hooks/use-ensure-affiliate.hook.mjs.map +1 -0
  345. package/dist/modules/affiliates/hooks/use-request-deposit.hook.mjs +28 -0
  346. package/dist/modules/affiliates/hooks/use-request-deposit.hook.mjs.map +1 -0
  347. package/dist/modules/affiliates/hooks/use-update-affiliate.hook.mjs +22 -0
  348. package/dist/modules/affiliates/hooks/use-update-affiliate.hook.mjs.map +1 -0
  349. package/dist/modules/affiliates/hooks/use-withdrawal-limits.hook.mjs +17 -0
  350. package/dist/modules/affiliates/hooks/use-withdrawal-limits.hook.mjs.map +1 -0
  351. package/dist/modules/affiliates/services/affiliates.service.mjs +183 -0
  352. package/dist/modules/affiliates/services/affiliates.service.mjs.map +1 -0
  353. package/dist/modules/affiliates/types/affiliate.type.mjs +100 -0
  354. package/dist/modules/affiliates/types/affiliate.type.mjs.map +1 -0
  355. package/dist/modules/affiliates/utils/get-affiliate-share-link.mjs +9 -0
  356. package/dist/modules/affiliates/utils/get-affiliate-share-link.mjs.map +1 -0
  357. package/dist/modules/charges/actions/get-nota-fiscal.action.mjs +10 -0
  358. package/dist/modules/charges/actions/get-nota-fiscal.action.mjs.map +1 -0
  359. package/dist/modules/charges/actions/refresh-pix.action.mjs +10 -0
  360. package/dist/modules/charges/actions/refresh-pix.action.mjs.map +1 -0
  361. package/dist/modules/charges/hooks/nota-fiscal.hook.mjs +13 -0
  362. package/dist/modules/charges/hooks/nota-fiscal.hook.mjs.map +1 -0
  363. package/dist/modules/charges/hooks/refresh-pix.hook.mjs +13 -0
  364. package/dist/modules/charges/hooks/refresh-pix.hook.mjs.map +1 -0
  365. package/dist/modules/charges/services/charges.service.mjs +67 -0
  366. package/dist/modules/charges/services/charges.service.mjs.map +1 -1
  367. package/dist/modules/charges/types/nota-fiscal.type.mjs +1 -0
  368. package/dist/modules/charges/types/nota-fiscal.type.mjs.map +1 -0
  369. package/dist/modules/charges/types/refresh-pix.type.mjs +1 -0
  370. package/dist/modules/charges/types/refresh-pix.type.mjs.map +1 -0
  371. package/dist/modules/charges/utils/get-charge-download-url.mjs +8 -0
  372. package/dist/modules/charges/utils/get-charge-download-url.mjs.map +1 -0
  373. package/dist/modules/coupons/constants/query-keys.constants.mjs +5 -0
  374. package/dist/modules/coupons/constants/query-keys.constants.mjs.map +1 -0
  375. package/dist/modules/coupons/handlers/find-coupon-by-code.handler.mjs +17 -0
  376. package/dist/modules/coupons/handlers/find-coupon-by-code.handler.mjs.map +1 -0
  377. package/dist/modules/coupons/handlers/find-coupon-by-id.handler.mjs +16 -0
  378. package/dist/modules/coupons/handlers/find-coupon-by-id.handler.mjs.map +1 -0
  379. package/dist/modules/coupons/hooks/use-coupon-by-code.hook.mjs +15 -0
  380. package/dist/modules/coupons/hooks/use-coupon-by-code.hook.mjs.map +1 -0
  381. package/dist/modules/coupons/hooks/use-coupon-by-id.hook.mjs +18 -0
  382. package/dist/modules/coupons/hooks/use-coupon-by-id.hook.mjs.map +1 -0
  383. package/dist/modules/coupons/services/coupons.service.mjs +44 -0
  384. package/dist/modules/coupons/services/coupons.service.mjs.map +1 -0
  385. package/dist/modules/coupons/types/coupon.type.mjs +61 -0
  386. package/dist/modules/coupons/types/coupon.type.mjs.map +1 -0
  387. package/dist/modules/coupons/utils/coupon-restrictions.mjs +60 -0
  388. package/dist/modules/coupons/utils/coupon-restrictions.mjs.map +1 -0
  389. package/dist/modules/domains/handlers/count-domains.handler.mjs +12 -0
  390. package/dist/modules/domains/handlers/count-domains.handler.mjs.map +1 -0
  391. package/dist/modules/domains/hooks/count-domains.hook.mjs +17 -0
  392. package/dist/modules/domains/hooks/count-domains.hook.mjs.map +1 -0
  393. package/dist/modules/domains/services/domains.service.mjs +18 -0
  394. package/dist/modules/domains/services/domains.service.mjs.map +1 -0
  395. package/dist/modules/ia-credits/handlers/list-ia-credit-operations.handler.mjs +15 -0
  396. package/dist/modules/ia-credits/handlers/list-ia-credit-operations.handler.mjs.map +1 -0
  397. package/dist/modules/ia-credits/hooks/ia-credit-operations.hook.mjs +28 -0
  398. package/dist/modules/ia-credits/hooks/ia-credit-operations.hook.mjs.map +1 -0
  399. package/dist/modules/ia-credits/services/ia-credits.service.mjs +23 -2
  400. package/dist/modules/ia-credits/services/ia-credits.service.mjs.map +1 -1
  401. package/dist/modules/pages/handlers/count-pages.handler.mjs +4 -2
  402. package/dist/modules/pages/handlers/count-pages.handler.mjs.map +1 -1
  403. package/dist/modules/pages/hooks/count-published-pages.hook.mjs +26 -0
  404. package/dist/modules/pages/hooks/count-published-pages.hook.mjs.map +1 -0
  405. package/dist/modules/pages/services/pages.service.mjs +3 -2
  406. package/dist/modules/pages/services/pages.service.mjs.map +1 -1
  407. package/dist/modules/plans/constants/plan-tooltips.constants.mjs +14 -0
  408. package/dist/modules/plans/constants/plan-tooltips.constants.mjs.map +1 -0
  409. package/dist/modules/plans/hooks/use-enriched-plans.hook.mjs +28 -0
  410. package/dist/modules/plans/hooks/use-enriched-plans.hook.mjs.map +1 -0
  411. package/dist/modules/plans/hooks/use-ui-plans.hook.mjs +20 -0
  412. package/dist/modules/plans/hooks/use-ui-plans.hook.mjs.map +1 -0
  413. package/dist/modules/projects/hooks/add-project-users.hook.mjs +25 -0
  414. package/dist/modules/projects/hooks/add-project-users.hook.mjs.map +1 -0
  415. package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +3 -6
  416. package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -1
  417. package/dist/modules/projects/hooks/list-available-users.hook.mjs +3 -6
  418. package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -1
  419. package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs +3 -6
  420. package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs.map +1 -1
  421. package/dist/modules/projects/hooks/list-project-users.hook.mjs +3 -6
  422. package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -1
  423. package/dist/modules/projects/hooks/remove-project-users.hook.mjs +25 -0
  424. package/dist/modules/projects/hooks/remove-project-users.hook.mjs.map +1 -0
  425. package/dist/modules/projects/services/project-users.service.mjs +5 -0
  426. package/dist/modules/projects/services/project-users.service.mjs.map +1 -1
  427. package/dist/modules/projects/types.mjs +3 -2
  428. package/dist/modules/projects/types.mjs.map +1 -1
  429. package/dist/modules/subscriptions/actions/cancel-subscription.action.mjs +10 -0
  430. package/dist/modules/subscriptions/actions/cancel-subscription.action.mjs.map +1 -0
  431. package/dist/modules/subscriptions/actions/create-subscription.action.mjs +10 -0
  432. package/dist/modules/subscriptions/actions/create-subscription.action.mjs.map +1 -0
  433. package/dist/modules/subscriptions/actions/find-pending-pix-status.action.mjs +10 -0
  434. package/dist/modules/subscriptions/actions/find-pending-pix-status.action.mjs.map +1 -0
  435. package/dist/modules/subscriptions/actions/find-subscription-by-id.action.mjs +10 -0
  436. package/dist/modules/subscriptions/actions/find-subscription-by-id.action.mjs.map +1 -0
  437. package/dist/modules/subscriptions/constants/addons.constants.mjs +35 -0
  438. package/dist/modules/subscriptions/constants/addons.constants.mjs.map +1 -1
  439. package/dist/modules/subscriptions/constants/downgrade.constants.mjs +25 -0
  440. package/dist/modules/subscriptions/constants/downgrade.constants.mjs.map +1 -0
  441. package/dist/modules/subscriptions/constants/subscription.constants.mjs +2 -0
  442. package/dist/modules/subscriptions/constants/subscription.constants.mjs.map +1 -1
  443. package/dist/modules/subscriptions/handlers/pending-pix-status.handler.mjs +15 -0
  444. package/dist/modules/subscriptions/handlers/pending-pix-status.handler.mjs.map +1 -0
  445. package/dist/modules/subscriptions/hooks/cancel-subscription.hook.mjs +25 -0
  446. package/dist/modules/subscriptions/hooks/cancel-subscription.hook.mjs.map +1 -0
  447. package/dist/modules/subscriptions/hooks/create-subscription.hook.mjs +33 -0
  448. package/dist/modules/subscriptions/hooks/create-subscription.hook.mjs.map +1 -0
  449. package/dist/modules/subscriptions/hooks/find-subscription-by-id.hook.mjs +18 -0
  450. package/dist/modules/subscriptions/hooks/find-subscription-by-id.hook.mjs.map +1 -0
  451. package/dist/modules/subscriptions/hooks/pending-pix-status.hook.mjs +25 -0
  452. package/dist/modules/subscriptions/hooks/pending-pix-status.hook.mjs.map +1 -0
  453. package/dist/modules/subscriptions/services/subscriptions.service.mjs +71 -0
  454. package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -1
  455. package/dist/modules/subscriptions/types/cancel-subscription.type.mjs +9 -0
  456. package/dist/modules/subscriptions/types/cancel-subscription.type.mjs.map +1 -0
  457. package/dist/modules/subscriptions/types/create-subscription.type.mjs +62 -0
  458. package/dist/modules/subscriptions/types/create-subscription.type.mjs.map +1 -0
  459. package/dist/modules/subscriptions/types/pending-pix-status.type.mjs +28 -0
  460. package/dist/modules/subscriptions/types/pending-pix-status.type.mjs.map +1 -0
  461. package/dist/modules/subscriptions/types/subscription.type.mjs +9 -1
  462. package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -1
  463. package/dist/modules/subscriptions/utils/addon-buckets.mjs +69 -0
  464. package/dist/modules/subscriptions/utils/addon-buckets.mjs.map +1 -0
  465. package/dist/modules/subscriptions/utils/confirm-payment-if-required.mjs +8 -2
  466. package/dist/modules/subscriptions/utils/confirm-payment-if-required.mjs.map +1 -1
  467. package/dist/modules/subscriptions/utils/first-period-pricing.mjs +25 -0
  468. package/dist/modules/subscriptions/utils/first-period-pricing.mjs.map +1 -0
  469. package/dist/modules/subscriptions/utils/is-api-subscription.mjs +8 -0
  470. package/dist/modules/subscriptions/utils/is-api-subscription.mjs.map +1 -0
  471. package/dist/modules/subscriptions/utils/is-boleto-payer.mjs +17 -0
  472. package/dist/modules/subscriptions/utils/is-boleto-payer.mjs.map +1 -0
  473. package/dist/modules/subscriptions/utils/is-free-subscription.mjs +8 -0
  474. package/dist/modules/subscriptions/utils/is-free-subscription.mjs.map +1 -0
  475. package/dist/modules/subscriptions/utils/periodicity.mjs +55 -1
  476. package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -1
  477. package/dist/modules/subscriptions/utils/resolve-subscription-plan-name.mjs +27 -0
  478. package/dist/modules/subscriptions/utils/resolve-subscription-plan-name.mjs.map +1 -0
  479. package/dist/modules/users/hooks/messages.hook.mjs +3 -5
  480. package/dist/modules/users/hooks/messages.hook.mjs.map +1 -1
  481. package/dist/server.mjs +6 -0
  482. package/dist/server.mjs.map +1 -1
  483. package/dist/store/useAccountModals.mjs +9 -2
  484. package/dist/store/useAccountModals.mjs.map +1 -1
  485. package/dist/store/useAccountUnsavedChanges.mjs +31 -0
  486. package/dist/store/useAccountUnsavedChanges.mjs.map +1 -0
  487. package/dist/store/useAffiliateFlows.mjs +23 -0
  488. package/dist/store/useAffiliateFlows.mjs.map +1 -0
  489. package/dist/store/useProjectFlows.mjs +18 -0
  490. package/dist/store/useProjectFlows.mjs.map +1 -0
  491. package/dist/store/useSubscriptionFlows.mjs +58 -0
  492. package/dist/store/useSubscriptionFlows.mjs.map +1 -0
  493. package/dist/store/useTeamFlows.mjs +15 -0
  494. package/dist/store/useTeamFlows.mjs.map +1 -0
  495. package/dist/testing/factories/coupon.factory.mjs +19 -0
  496. package/dist/testing/factories/coupon.factory.mjs.map +1 -0
  497. package/dist/testing/factories/index.mjs +6 -0
  498. package/dist/testing/factories/index.mjs.map +1 -1
  499. package/dist/testing/factories/project-user.factory.mjs +17 -0
  500. package/dist/testing/factories/project-user.factory.mjs.map +1 -0
  501. package/dist/testing/factories/project.factory.mjs +21 -0
  502. package/dist/testing/factories/project.factory.mjs.map +1 -0
  503. package/dist/testing/react/providers.mjs +1 -1
  504. package/dist/testing/react/providers.mjs.map +1 -1
  505. package/dist/utils/browser/chart-custom-tooltip.mjs +69 -0
  506. package/dist/utils/browser/chart-custom-tooltip.mjs.map +1 -0
  507. package/dist/utils/browser/get-css-variable.mjs +9 -0
  508. package/dist/utils/browser/get-css-variable.mjs.map +1 -0
  509. package/dist/utils/constants/scrollbar.mjs +5 -0
  510. package/dist/utils/constants/scrollbar.mjs.map +1 -0
  511. package/dist/utils/date-filter-period.mjs +34 -0
  512. package/dist/utils/date-filter-period.mjs.map +1 -0
  513. package/dist/utils/file/index.mjs +11 -1
  514. package/dist/utils/file/index.mjs.map +1 -1
  515. package/dist/utils/format/initials.mjs +8 -0
  516. package/dist/utils/format/initials.mjs.map +1 -0
  517. package/dist/utils/format/masks.mjs +32 -1
  518. package/dist/utils/format/masks.mjs.map +1 -1
  519. package/dist/utils/qrcode/to-data-url.mjs +12 -0
  520. package/dist/utils/qrcode/to-data-url.mjs.map +1 -0
  521. package/dist/utils/validators/account.mjs +1 -7
  522. package/dist/utils/validators/account.mjs.map +1 -1
  523. package/package.json +15 -2
  524. package/src/components/account/AccountHubLinkHandler.tsx +39 -0
  525. package/src/components/account/AccountModalLayout.tsx +190 -0
  526. package/src/components/account/AccountModals.tsx +12 -2
  527. package/src/components/account/AccountUnsavedChangesDialog.tsx +49 -0
  528. package/src/components/account/DeleteAccountModal.tsx +1 -1
  529. package/src/components/account/IsntPossibleDeleteAccountModal.tsx +9 -1
  530. package/src/components/account/MyAccountModal.tsx +222 -0
  531. package/src/components/account/TwoFactorAuthModal.tsx +1 -1
  532. package/src/components/account/hooks/useAccountHubActions.ts +95 -0
  533. package/src/components/account/hooks/useAddCardWithPaymentSwitch.ts +70 -0
  534. package/src/components/account/hooks/useAffiliatesActions.tsx +78 -0
  535. package/src/components/account/hooks/useMyAccountModal.ts +40 -0
  536. package/src/components/account/hooks/useProjectsActions.ts +44 -0
  537. package/src/components/account/hooks/useSubscriptionActions.ts +99 -0
  538. package/src/components/account/hooks/useTeamActions.ts +35 -0
  539. package/src/components/account/sections/AffiliatesSection.tsx +342 -0
  540. package/src/components/account/sections/ChangePasswordSection.tsx +6 -10
  541. package/src/components/account/sections/MyProfileSection.tsx +215 -147
  542. package/src/components/account/sections/PreferencesSection.tsx +71 -71
  543. package/src/components/account/sections/ProjectsSection.tsx +110 -0
  544. package/src/components/account/sections/SecuritySection.tsx +72 -62
  545. package/src/components/account/sections/SubscriptionSection.tsx +36 -0
  546. package/src/components/account/sections/TeamSection.tsx +161 -0
  547. package/src/components/account/sections/TokenSection.tsx +4 -8
  548. package/src/components/account/sections/affiliates/AffiliateCommissionCard.tsx +83 -0
  549. package/src/components/account/sections/affiliates/AffiliateFlows.tsx +20 -0
  550. package/src/components/account/sections/affiliates/AffiliateLeadsSheet.tsx +143 -0
  551. package/src/components/account/sections/affiliates/AffiliateStatsCard.tsx +56 -0
  552. package/src/components/account/sections/affiliates/AffiliateStepCard.tsx +20 -0
  553. package/src/components/account/sections/affiliates/AffiliateTransactionsList.tsx +194 -0
  554. package/src/components/account/sections/affiliates/NoReceivingAccountModal.tsx +63 -0
  555. package/src/components/account/sections/affiliates/ReceivingAccountModal.tsx +213 -0
  556. package/src/components/account/sections/affiliates/RequestWithdrawalSheet.tsx +586 -0
  557. package/src/components/account/sections/affiliates/ViewAttachmentModal.tsx +47 -0
  558. package/src/components/account/sections/affiliates/reports/AffiliatesIndicatorsChart.tsx +45 -0
  559. package/src/components/account/sections/affiliates/reports/AffiliatesReportsTab.tsx +44 -0
  560. package/src/components/account/sections/affiliates/reports/useAffiliatesIndicatorsChart.ts +148 -0
  561. package/src/components/account/sections/projects/DeleteProjectModal.tsx +246 -0
  562. package/src/components/account/sections/projects/ProjectFlows.tsx +16 -0
  563. package/src/components/account/sections/projects/ProjectMembersStack.tsx +75 -0
  564. package/src/components/account/sections/projects/ProjectRow.tsx +96 -0
  565. package/src/components/account/sections/projects/ProjectSheet.tsx +603 -0
  566. package/src/components/account/sections/projects/ProjectsDisabledModal.tsx +69 -0
  567. package/src/components/account/sections/projects/project-form.schema.ts +30 -0
  568. package/src/components/account/sections/shared/ConnectListRow.tsx +68 -0
  569. package/src/components/account/sections/shared/DateFilterPopover.tsx +58 -0
  570. package/src/components/account/sections/shared/EntityAvatar.tsx +54 -0
  571. package/src/components/account/sections/shared/FilterPopover.tsx +79 -0
  572. package/src/components/account/sections/shared/FormSection.tsx +23 -0
  573. package/src/components/account/sections/shared/IconBox.tsx +21 -0
  574. package/src/components/account/sections/shared/InfiniteScrollList.tsx +57 -0
  575. package/src/components/account/sections/shared/ListPagination.tsx +84 -0
  576. package/src/components/account/sections/shared/RowActionsMenu.tsx +66 -0
  577. package/src/components/account/sections/shared/SectionLoadError.tsx +27 -0
  578. package/src/components/account/sections/shared/StatusBadge.tsx +33 -0
  579. package/src/components/account/sections/shared/WorkspaceSection.tsx +22 -0
  580. package/src/components/account/sections/subscription/AiCreditsUsage.tsx +152 -0
  581. package/src/components/account/sections/subscription/BillingAddressSheet.tsx +460 -0
  582. package/src/components/account/sections/subscription/BoletoDetailsDialog.tsx +104 -0
  583. package/src/components/account/sections/subscription/BoletoGeneratedDialog.tsx +24 -0
  584. package/src/components/account/sections/subscription/CancelPlanDialog.tsx +221 -0
  585. package/src/components/account/sections/subscription/ChargeRow.tsx +161 -0
  586. package/src/components/account/sections/subscription/ChargeStatusBadge.tsx +29 -0
  587. package/src/components/account/sections/subscription/ChargesList.tsx +125 -0
  588. package/src/components/account/sections/subscription/ManageCardsSheet.tsx +93 -0
  589. package/src/components/account/sections/subscription/OverdueReceiptOpener.tsx +29 -0
  590. package/src/components/account/sections/subscription/PayChargeDialog.tsx +306 -0
  591. package/src/components/account/sections/subscription/PaymentConfirmationDialog.tsx +70 -0
  592. package/src/components/account/sections/subscription/PaymentMethodsCard.tsx +117 -0
  593. package/src/components/account/sections/subscription/PendingChangeDialog.tsx +168 -0
  594. package/src/components/account/sections/subscription/PixDetailsDialog.tsx +246 -0
  595. package/src/components/account/sections/subscription/PixPaymentDialog.tsx +242 -0
  596. package/src/components/account/sections/subscription/PlanDetailsSheet.tsx +380 -0
  597. package/src/components/account/sections/subscription/ReceiptDetailsSheet.tsx +318 -0
  598. package/src/components/account/sections/subscription/SubscriptionFlows.tsx +40 -0
  599. package/src/components/account/sections/subscription/SubscriptionPlanCard.tsx +433 -0
  600. package/src/components/account/sections/subscription/UsageReportSheet.tsx +244 -0
  601. package/src/components/account/sections/subscription/change-plan/ChangePlanSheet.tsx +95 -0
  602. package/src/components/account/sections/subscription/change-plan/components/AbTestDetailsDialog.tsx +57 -0
  603. package/src/components/account/sections/subscription/change-plan/components/AddonsBlock.tsx +214 -0
  604. package/src/components/account/sections/subscription/change-plan/components/AlternativeBucketsSection.tsx +92 -0
  605. package/src/components/account/sections/subscription/change-plan/components/CouponBlock.tsx +42 -0
  606. package/src/components/account/sections/subscription/change-plan/components/CouponDialog.tsx +134 -0
  607. package/src/components/account/sections/subscription/change-plan/components/PricePreview.tsx +28 -0
  608. package/src/components/account/sections/subscription/change-plan/components/SummaryBlock.tsx +194 -0
  609. package/src/components/account/sections/subscription/change-plan/plan-comparison.ts +52 -0
  610. package/src/components/account/sections/subscription/change-plan/steps/PaymentSummaryStep.tsx +161 -0
  611. package/src/components/account/sections/subscription/change-plan/steps/PlanComparisonStep.tsx +165 -0
  612. package/src/components/account/sections/subscription/change-plan/steps/PlanViewStep.tsx +89 -0
  613. package/src/components/account/sections/subscription/change-plan/steps/ReactivationConfigStep.tsx +117 -0
  614. package/src/components/account/sections/subscription/change-plan/steps/ReactivationPaymentStep.tsx +139 -0
  615. package/src/components/account/sections/subscription/change-plan/useChangePlanState.tsx +1158 -0
  616. package/src/components/account/sections/subscription/downgrade/CannotDowngradeDialog.tsx +297 -0
  617. package/src/components/account/sections/subscription/downgrade/DowngradeReasonDialog.tsx +154 -0
  618. package/src/components/account/sections/subscription/plans/PlanCard.tsx +417 -0
  619. package/src/components/account/sections/subscription/plans/PlanCardSkeleton.tsx +70 -0
  620. package/src/components/account/sections/subscription/plans/PlansCatalogDialog.tsx +156 -0
  621. package/src/components/account/sections/team/DeleteUserModal.tsx +134 -0
  622. package/src/components/account/sections/team/TeamFlows.tsx +14 -0
  623. package/src/components/account/sections/team/TeamMemberRow.tsx +151 -0
  624. package/src/components/account/sections/team/UserSheet.tsx +688 -0
  625. package/src/components/account/sections/team/steps/NotificationsStep.tsx +109 -0
  626. package/src/components/account/sections/team/steps/ProjectSelectionStep.tsx +219 -0
  627. package/src/components/account/sections/team/steps/UserInformationStep.tsx +423 -0
  628. package/src/components/account/sections/team/user-form.schema.ts +43 -0
  629. package/src/components/account/types/workspace-actions.type.ts +56 -0
  630. package/src/components/layouts/ProfilePopover.tsx +11 -12
  631. package/src/components/layouts/UsersSelectorPopover.tsx +7 -4
  632. package/src/components/modals/AccountDeletionWarningModal.tsx +4 -5
  633. package/src/components/modals/AccountFrozenModal.tsx +6 -3
  634. package/src/components/modals/Modals.tsx +6 -3
  635. package/src/components/modals/PaidPlanRequiredModal.tsx +4 -5
  636. package/src/components/modals/cards/AddFirstCardWarningModal.tsx +72 -0
  637. package/src/components/modals/cards/SwitchPaymentToCardModal.tsx +232 -0
  638. package/src/components/modals/promo/AiCreditsOfferModal/AiCreditsOfferModal.tsx +5 -4
  639. package/src/components/ui/data-display/CardItem.tsx +9 -5
  640. package/src/components/ui/data-display/PaymentMethodIcons.tsx +43 -0
  641. package/src/components/ui/form/BillingPeriodSelector.tsx +173 -0
  642. package/src/components/ui/form/PaymentMethodToggle.tsx +119 -0
  643. package/src/components/ui/form/RadioOptionFieldIcon.tsx +64 -0
  644. package/src/components/ui/form/SegmentedControl.tsx +77 -0
  645. package/src/components/ui/overlay/Dialog.tsx +21 -2
  646. package/src/components/ui/overlay/Sheet.tsx +26 -5
  647. package/src/components/ui/overlay/layers.tsx +88 -4
  648. package/src/enums/AccountHubFlow.ts +8 -0
  649. package/src/enums/DateFilterPeriod.ts +17 -0
  650. package/src/enums/WorkspaceSectionType.ts +6 -0
  651. package/src/handlers.ts +14 -0
  652. package/src/hooks/useDebounce.ts +5 -3
  653. package/src/hooks/useUploadProgress.ts +42 -0
  654. package/src/i18n/messages/en-us.ts +909 -2
  655. package/src/i18n/messages/es-es.ts +913 -2
  656. package/src/i18n/messages/pt-br.ts +913 -2
  657. package/src/index.ts +56 -1
  658. package/src/infra/http/paged.ts +24 -0
  659. package/src/middleware.ts +1 -0
  660. package/src/middlewares/create-auth-middleware.ts +2 -5
  661. package/src/middlewares/create-legacy-account-routes-middleware.ts +54 -0
  662. package/src/middlewares/is-route-equals.ts +3 -0
  663. package/src/modules/accounts/actions/account-management.action.ts +22 -1
  664. package/src/modules/accounts/constants/account-hub-link.constants.ts +3 -0
  665. package/src/modules/accounts/constants/legacy-account-routes.constants.ts +1 -0
  666. package/src/modules/accounts/handlers/list-account-members.handler.ts +23 -0
  667. package/src/modules/accounts/hooks/add-user-projects.hook.ts +72 -0
  668. package/src/modules/accounts/hooks/create-account-user.hook.ts +21 -0
  669. package/src/modules/accounts/hooks/remove-user-projects.hook.ts +68 -0
  670. package/src/modules/accounts/hooks/use-account-members.hook.ts +31 -0
  671. package/src/modules/accounts/services/account.service.ts +71 -0
  672. package/src/modules/accounts/types/account-hub-link.type.ts +13 -0
  673. package/src/modules/accounts/types.ts +9 -0
  674. package/src/modules/accounts/utils/build-account-hub-url.ts +14 -0
  675. package/src/modules/accounts/utils/is-account-hub-flow.ts +7 -0
  676. package/src/modules/accounts/utils/is-account-section.ts +7 -0
  677. package/src/modules/accounts/utils/is-my-account-section.ts +12 -0
  678. package/src/modules/accounts/utils/map-legacy-account-route.ts +108 -0
  679. package/src/modules/accounts/utils/parse-account-hub-link.ts +21 -0
  680. package/src/modules/affiliates/actions/ensure-affiliate.action.ts +9 -0
  681. package/src/modules/affiliates/actions/request-deposit.action.ts +9 -0
  682. package/src/modules/affiliates/actions/update-affiliate.action.ts +9 -0
  683. package/src/modules/affiliates/constants/affiliate.constants.ts +11 -0
  684. package/src/modules/affiliates/constants/query-keys.constants.ts +7 -0
  685. package/src/modules/affiliates/handlers/affiliate-report-analytics.handler.ts +16 -0
  686. package/src/modules/affiliates/handlers/affiliate-withdrawal-limits.handler.ts +10 -0
  687. package/src/modules/affiliates/handlers/current-affiliate.handler.ts +10 -0
  688. package/src/modules/affiliates/handlers/list-affiliate-coupons.handler.ts +10 -0
  689. package/src/modules/affiliates/handlers/list-affiliate-leads.handler.ts +23 -0
  690. package/src/modules/affiliates/handlers/list-affiliate-transactions.handler.ts +23 -0
  691. package/src/modules/affiliates/hooks/use-affiliate-coupons.hook.ts +19 -0
  692. package/src/modules/affiliates/hooks/use-affiliate-leads.hook.ts +27 -0
  693. package/src/modules/affiliates/hooks/use-affiliate-report-analytics.hook.ts +19 -0
  694. package/src/modules/affiliates/hooks/use-affiliate-transactions.hook.ts +25 -0
  695. package/src/modules/affiliates/hooks/use-current-affiliate.hook.ts +19 -0
  696. package/src/modules/affiliates/hooks/use-ensure-affiliate.hook.ts +24 -0
  697. package/src/modules/affiliates/hooks/use-request-deposit.hook.ts +29 -0
  698. package/src/modules/affiliates/hooks/use-update-affiliate.hook.ts +24 -0
  699. package/src/modules/affiliates/hooks/use-withdrawal-limits.hook.ts +20 -0
  700. package/src/modules/affiliates/services/affiliates.service.ts +240 -0
  701. package/src/modules/affiliates/types/affiliate.type.ts +180 -0
  702. package/src/modules/affiliates/utils/get-affiliate-share-link.ts +8 -0
  703. package/src/modules/charges/actions/get-nota-fiscal.action.ts +8 -0
  704. package/src/modules/charges/actions/refresh-pix.action.ts +8 -0
  705. package/src/modules/charges/hooks/nota-fiscal.hook.ts +13 -0
  706. package/src/modules/charges/hooks/refresh-pix.hook.ts +13 -0
  707. package/src/modules/charges/services/charges.service.ts +121 -0
  708. package/src/modules/charges/types/nota-fiscal.type.ts +20 -0
  709. package/src/modules/charges/types/refresh-pix.type.ts +14 -0
  710. package/src/modules/charges/utils/get-charge-download-url.ts +10 -0
  711. package/src/modules/coupons/constants/query-keys.constants.ts +1 -0
  712. package/src/modules/coupons/handlers/find-coupon-by-code.handler.ts +16 -0
  713. package/src/modules/coupons/handlers/find-coupon-by-id.handler.ts +15 -0
  714. package/src/modules/coupons/hooks/use-coupon-by-code.hook.ts +16 -0
  715. package/src/modules/coupons/hooks/use-coupon-by-id.hook.ts +20 -0
  716. package/src/modules/coupons/services/coupons.service.ts +54 -0
  717. package/src/modules/coupons/types/coupon.type.ts +70 -0
  718. package/src/modules/coupons/utils/coupon-restrictions.ts +112 -0
  719. package/src/modules/domains/handlers/count-domains.handler.ts +10 -0
  720. package/src/modules/domains/hooks/count-domains.hook.ts +17 -0
  721. package/src/modules/domains/services/domains.service.ts +18 -0
  722. package/src/modules/ia-credits/handlers/list-ia-credit-operations.handler.ts +14 -0
  723. package/src/modules/ia-credits/hooks/ia-credit-operations.hook.ts +33 -0
  724. package/src/modules/ia-credits/services/ia-credits.service.ts +32 -1
  725. package/src/modules/pages/handlers/count-pages.handler.ts +5 -2
  726. package/src/modules/pages/hooks/count-published-pages.hook.ts +26 -0
  727. package/src/modules/pages/services/pages.service.ts +3 -2
  728. package/src/modules/plans/constants/plan-tooltips.constants.ts +16 -0
  729. package/src/modules/plans/hooks/use-enriched-plans.hook.ts +31 -0
  730. package/src/modules/plans/hooks/use-ui-plans.hook.ts +22 -0
  731. package/src/modules/projects/hooks/add-project-users.hook.ts +29 -0
  732. package/src/modules/projects/hooks/list-all-account-users.hook.ts +3 -6
  733. package/src/modules/projects/hooks/list-available-users.hook.ts +3 -6
  734. package/src/modules/projects/hooks/list-infinite-projects.hook.ts +3 -6
  735. package/src/modules/projects/hooks/list-project-users.hook.ts +3 -6
  736. package/src/modules/projects/hooks/remove-project-users.hook.ts +29 -0
  737. package/src/modules/projects/services/project-users.service.ts +135 -130
  738. package/src/modules/projects/types.ts +89 -88
  739. package/src/modules/subscriptions/actions/cancel-subscription.action.ts +12 -0
  740. package/src/modules/subscriptions/actions/create-subscription.action.ts +9 -0
  741. package/src/modules/subscriptions/actions/find-pending-pix-status.action.ts +8 -0
  742. package/src/modules/subscriptions/actions/find-subscription-by-id.action.ts +8 -0
  743. package/src/modules/subscriptions/constants/addons.constants.ts +50 -0
  744. package/src/modules/subscriptions/constants/downgrade.constants.ts +30 -0
  745. package/src/modules/subscriptions/constants/subscription.constants.ts +3 -0
  746. package/src/modules/subscriptions/handlers/pending-pix-status.handler.ts +17 -0
  747. package/src/modules/subscriptions/hooks/cancel-subscription.hook.ts +28 -0
  748. package/src/modules/subscriptions/hooks/create-subscription.hook.ts +34 -0
  749. package/src/modules/subscriptions/hooks/find-subscription-by-id.hook.ts +17 -0
  750. package/src/modules/subscriptions/hooks/pending-pix-status.hook.ts +30 -0
  751. package/src/modules/subscriptions/services/subscriptions.service.ts +401 -301
  752. package/src/modules/subscriptions/types/cancel-subscription.type.ts +8 -0
  753. package/src/modules/subscriptions/types/create-subscription.type.ts +79 -0
  754. package/src/modules/subscriptions/types/pending-pix-status.type.ts +33 -0
  755. package/src/modules/subscriptions/types/subscription.type.ts +157 -147
  756. package/src/modules/subscriptions/utils/addon-buckets.ts +129 -0
  757. package/src/modules/subscriptions/utils/confirm-payment-if-required.ts +9 -2
  758. package/src/modules/subscriptions/utils/first-period-pricing.ts +63 -0
  759. package/src/modules/subscriptions/utils/is-api-subscription.ts +6 -0
  760. package/src/modules/subscriptions/utils/is-boleto-payer.ts +21 -0
  761. package/src/modules/subscriptions/utils/is-free-subscription.ts +6 -0
  762. package/src/modules/subscriptions/utils/periodicity.ts +101 -0
  763. package/src/modules/subscriptions/utils/resolve-subscription-plan-name.ts +44 -0
  764. package/src/modules/users/hooks/messages.hook.ts +3 -5
  765. package/src/server.ts +102 -99
  766. package/src/store/useAccountModals.ts +22 -5
  767. package/src/store/useAccountUnsavedChanges.ts +52 -0
  768. package/src/store/useAffiliateFlows.ts +46 -0
  769. package/src/store/useProjectFlows.ts +42 -0
  770. package/src/store/useSubscriptionFlows.ts +176 -0
  771. package/src/store/useTeamFlows.ts +34 -0
  772. package/src/testing/factories/coupon.factory.ts +17 -0
  773. package/src/testing/factories/index.ts +3 -0
  774. package/src/testing/factories/project-user.factory.ts +15 -0
  775. package/src/testing/factories/project.factory.ts +19 -0
  776. package/src/testing/react/providers.tsx +2 -1
  777. package/src/utils/browser/chart-custom-tooltip.ts +85 -0
  778. package/src/utils/browser/get-css-variable.ts +6 -0
  779. package/src/utils/constants/scrollbar.ts +10 -0
  780. package/src/utils/date-filter-period.ts +34 -0
  781. package/src/utils/file/index.ts +13 -0
  782. package/src/utils/format/initials.ts +10 -0
  783. package/src/utils/format/masks.ts +41 -0
  784. package/src/utils/qrcode/to-data-url.ts +23 -0
  785. package/src/utils/validators/account.ts +0 -8
  786. package/dist/components/account/ConfigurationsMyAccountModal.mjs +0 -143
  787. package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +0 -1
  788. package/dist/components/account/hooks/useConfigurationsModal.mjs +0 -34
  789. package/dist/components/account/hooks/useConfigurationsModal.mjs.map +0 -1
  790. package/src/components/account/ConfigurationsMyAccountModal.tsx +0 -179
  791. 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":"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","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":"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","names":[]}
@@ -0,0 +1,9 @@
1
+ function getAffiliateShareLink(baseUrl, coupon) {
2
+ const base = baseUrl.replace(/\/$/, "");
3
+ if (coupon.discount === 0) return `${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;AAG/B,MAAM,eAAe;AAAA,EACnB,MAAM,YAAY,QAA8E;AAC9F,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,QAAQ,iBAAiB,EAAE,GAAG,QAAQ,WAAW,CAAC;AAExD,UAAM,WAAW,MAAM,IAAI,KAAK,IAAsC,YAAY,KAAK,EAAE;AAEzF,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,EAAE,MAAM,SAAS,MAAM,OAAO,SAAS,OAAO,SAAS,KAAK;AAAA,EACrE;AAAA,EAEA,MAAM,aAAa,MAAoD;AACrE,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,YAAY,KAAK,QAAQ;AAAA,MACzB;AAAA,QACE,gBAAgB,KAAK;AAAA,QACrB,mBAAmB,KAAK;AAAA,MAC1B;AAAA,IACF;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,EAAE,SAAS,MAAM,MAAM,OAAU;AAAA,EAC1C;AAAA,EAEA,MAAM,eAAe,UAA2D;AAC9E,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,YAAY,QAAQ,eAAe,UAAU;AAAA,IAC/C;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI,SAAS,SAAS,WAAW,8BAA2B,sBAAsB,GAAG;AAAA,IAC7F;AAEA,WAAO,EAAE,MAAM,SAAS,KAAK,CAAC,GAAG,SAAS,KAAK;AAAA,EACjD;AACF;AAEO,MAAM,iBAAiB,IAAI,eAAe;","names":[]}
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":"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","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,8 @@
1
+ function getChargeDownloadUrl(charge) {
2
+ if (!charge) return null;
3
+ return charge.invoice_pdf || charge.invoice_url || charge.gateway_billet || null;
4
+ }
5
+ export {
6
+ getChargeDownloadUrl
7
+ };
8
+ //# sourceMappingURL=get-charge-download-url.mjs.map
@@ -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,5 @@
1
+ const COUPON_QUERY_KEY = ["coupon"];
2
+ export {
3
+ COUPON_QUERY_KEY
4
+ };
5
+ //# sourceMappingURL=query-keys.constants.mjs.map
@@ -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