@greatapps/common 1.1.676 → 1.1.678

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 (243) hide show
  1. package/dist/components/account/ConfigurationsMyAccountModal.mjs +8 -6
  2. package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
  3. package/dist/components/account/ConfirmDeleteAccountModal.mjs +20 -19
  4. package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -1
  5. package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +10 -11
  6. package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -1
  7. package/dist/components/account/DeleteAccountModal.mjs +34 -28
  8. package/dist/components/account/DeleteAccountModal.mjs.map +1 -1
  9. package/dist/components/account/DisableTwoFactorAuthModal.mjs +7 -5
  10. package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -1
  11. package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +8 -9
  12. package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -1
  13. package/dist/components/account/TwoFactorAuthModal.mjs +22 -23
  14. package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -1
  15. package/dist/components/account/constants.mjs +4 -4
  16. package/dist/components/account/constants.mjs.map +1 -1
  17. package/dist/components/account/hooks/useChangeEmailForm.mjs +5 -3
  18. package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -1
  19. package/dist/components/account/hooks/useChangePasswordForm.mjs +26 -3
  20. package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -1
  21. package/dist/components/account/hooks/useChangePhoneForm.mjs +18 -9
  22. package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -1
  23. package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +26 -3
  24. package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -1
  25. package/dist/components/account/hooks/useOtpVerification.mjs +19 -3
  26. package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -1
  27. package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +27 -4
  28. package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -1
  29. package/dist/components/account/sections/ChangeEmailModal.mjs +25 -28
  30. package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -1
  31. package/dist/components/account/sections/ChangePasswordSection.mjs +8 -6
  32. package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -1
  33. package/dist/components/account/sections/ChangePhoneModal.mjs +24 -27
  34. package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -1
  35. package/dist/components/account/sections/MyProfileSection.mjs +37 -22
  36. package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
  37. package/dist/components/account/sections/PreferencesSection.mjs +48 -24
  38. package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
  39. package/dist/components/account/sections/SecuritySection.mjs +11 -9
  40. package/dist/components/account/sections/SecuritySection.mjs.map +1 -1
  41. package/dist/components/account/sections/TokenSection.mjs +24 -8
  42. package/dist/components/account/sections/TokenSection.mjs.map +1 -1
  43. package/dist/components/layouts/NavBar.mjs +5 -3
  44. package/dist/components/layouts/NavBar.mjs.map +1 -1
  45. package/dist/components/layouts/NotificationsPopover.mjs +5 -3
  46. package/dist/components/layouts/NotificationsPopover.mjs.map +1 -1
  47. package/dist/components/layouts/ProfilePopover.mjs +6 -4
  48. package/dist/components/layouts/ProfilePopover.mjs.map +1 -1
  49. package/dist/components/layouts/UsersSelectorPopover.mjs +9 -7
  50. package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -1
  51. package/dist/components/modals/BuyCreditsModal.mjs +17 -18
  52. package/dist/components/modals/BuyCreditsModal.mjs.map +1 -1
  53. package/dist/components/modals/CreditsDisabledModal.mjs +6 -4
  54. package/dist/components/modals/CreditsDisabledModal.mjs.map +1 -1
  55. package/dist/components/modals/PaidPlanRequiredModal.mjs +5 -3
  56. package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -1
  57. package/dist/components/modals/cards/AddCardModal.mjs +64 -46
  58. package/dist/components/modals/cards/AddCardModal.mjs.map +1 -1
  59. package/dist/components/modals/cards/CannotDeleteCardModal.mjs +9 -7
  60. package/dist/components/modals/cards/CannotDeleteCardModal.mjs.map +1 -1
  61. package/dist/components/modals/cards/CardFormFields.mjs +65 -51
  62. package/dist/components/modals/cards/CardFormFields.mjs.map +1 -1
  63. package/dist/components/modals/cards/DeleteCardModal.mjs +10 -8
  64. package/dist/components/modals/cards/DeleteCardModal.mjs.map +1 -1
  65. package/dist/components/navigation/CancelledSubscriptionBanner.mjs +4 -2
  66. package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -1
  67. package/dist/components/navigation/OverdueInvoiceBanner.mjs +4 -2
  68. package/dist/components/navigation/OverdueInvoiceBanner.mjs.map +1 -1
  69. package/dist/components/navigation/PendingCancellationBanner.mjs +4 -6
  70. package/dist/components/navigation/PendingCancellationBanner.mjs.map +1 -1
  71. package/dist/components/navigation/ProjectSelectorPopover.mjs +8 -6
  72. package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -1
  73. package/dist/components/navigation/UpcomingInvoiceBanner.mjs +4 -6
  74. package/dist/components/navigation/UpcomingInvoiceBanner.mjs.map +1 -1
  75. package/dist/components/navigation/subcomponents/BottomLinks.mjs +5 -3
  76. package/dist/components/navigation/subcomponents/BottomLinks.mjs.map +1 -1
  77. package/dist/components/navigation/subcomponents/CreditsCard.mjs +3 -1
  78. package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -1
  79. package/dist/components/navigation/subcomponents/PlanCard.mjs +3 -1
  80. package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -1
  81. package/dist/components/navigation/subcomponents/ProjectSelector.mjs +5 -3
  82. package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -1
  83. package/dist/components/pages/NotFoundPage.mjs +5 -3
  84. package/dist/components/pages/NotFoundPage.mjs.map +1 -1
  85. package/dist/components/pages/notifications/Notifications.mjs +13 -10
  86. package/dist/components/pages/notifications/Notifications.mjs.map +1 -1
  87. package/dist/components/ui/buttons/CopyButton.mjs +9 -5
  88. package/dist/components/ui/buttons/CopyButton.mjs.map +1 -1
  89. package/dist/components/ui/data-display/CardItem.mjs +7 -5
  90. package/dist/components/ui/data-display/CardItem.mjs.map +1 -1
  91. package/dist/components/ui/data-display/PaymentInfoCard.mjs +10 -8
  92. package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -1
  93. package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -1
  94. package/dist/components/ui/feedback/DefaultCircularProgress.mjs +3 -1
  95. package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -1
  96. package/dist/components/ui/form/ComboboxField.mjs +11 -6
  97. package/dist/components/ui/form/ComboboxField.mjs.map +1 -1
  98. package/dist/components/ui/form/DatePicker.mjs +5 -2
  99. package/dist/components/ui/form/DatePicker.mjs.map +1 -1
  100. package/dist/components/ui/form/DateRangePicker.mjs +5 -2
  101. package/dist/components/ui/form/DateRangePicker.mjs.map +1 -1
  102. package/dist/components/ui/form/PhoneInput.mjs +5 -3
  103. package/dist/components/ui/form/PhoneInput.mjs.map +1 -1
  104. package/dist/components/ui/form/SelectField.mjs +6 -3
  105. package/dist/components/ui/form/SelectField.mjs.map +1 -1
  106. package/dist/components/widgets/ImageUpload/ImageCropModal.mjs +11 -18
  107. package/dist/components/widgets/ImageUpload/ImageCropModal.mjs.map +1 -1
  108. package/dist/components/widgets/ImageUpload/ImageTooSmallModal.mjs +6 -15
  109. package/dist/components/widgets/ImageUpload/ImageTooSmallModal.mjs.map +1 -1
  110. package/dist/i18n/config.mjs +13 -0
  111. package/dist/i18n/config.mjs.map +1 -0
  112. package/dist/i18n/country-language.mjs +74 -0
  113. package/dist/i18n/country-language.mjs.map +1 -0
  114. package/dist/i18n/messages/en-us.mjs +495 -0
  115. package/dist/i18n/messages/en-us.mjs.map +1 -0
  116. package/dist/i18n/messages/es-es.mjs +495 -0
  117. package/dist/i18n/messages/es-es.mjs.map +1 -0
  118. package/dist/i18n/messages/index.mjs +16 -0
  119. package/dist/i18n/messages/index.mjs.map +1 -0
  120. package/dist/i18n/messages/pt-br.mjs +508 -0
  121. package/dist/i18n/messages/pt-br.mjs.map +1 -0
  122. package/dist/i18n/normalize.mjs +12 -0
  123. package/dist/i18n/normalize.mjs.map +1 -0
  124. package/dist/i18n/resolve-locale.mjs +42 -0
  125. package/dist/i18n/resolve-locale.mjs.map +1 -0
  126. package/dist/i18n.mjs +14 -0
  127. package/dist/i18n.mjs.map +1 -0
  128. package/dist/index.mjs +19 -3
  129. package/dist/index.mjs.map +1 -1
  130. package/dist/modules/accounts/hooks/use-currency-formatter.hook.mjs +20 -0
  131. package/dist/modules/accounts/hooks/use-currency-formatter.hook.mjs.map +1 -0
  132. package/dist/modules/cards/hooks/handle-delete-card.hook.mjs +2 -1
  133. package/dist/modules/cards/hooks/handle-delete-card.hook.mjs.map +1 -1
  134. package/dist/modules/images/utils/validate-image.mjs +8 -8
  135. package/dist/modules/images/utils/validate-image.mjs.map +1 -1
  136. package/dist/modules/plans/handlers/list-plans.handler.mjs +1 -1
  137. package/dist/modules/plans/handlers/list-plans.handler.mjs.map +1 -1
  138. package/dist/modules/plans/hooks/list-plans.hook.mjs +2 -2
  139. package/dist/modules/plans/hooks/list-plans.hook.mjs.map +1 -1
  140. package/dist/modules/plans/services/plans.service.mjs +1 -1
  141. package/dist/modules/plans/services/plans.service.mjs.map +1 -1
  142. package/dist/modules/plans/types/plan.type.mjs +9 -2
  143. package/dist/modules/plans/types/plan.type.mjs.map +1 -1
  144. package/dist/modules/plans/utils/map-api-plan-to-ui.mjs +66 -34
  145. package/dist/modules/plans/utils/map-api-plan-to-ui.mjs.map +1 -1
  146. package/dist/modules/projects/services/projects.service.mjs +9 -0
  147. package/dist/modules/projects/services/projects.service.mjs.map +1 -1
  148. package/dist/modules/subscriptions/utils/periodicity.mjs +20 -14
  149. package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -1
  150. package/dist/providers/auth.provider.mjs +9 -1
  151. package/dist/providers/auth.provider.mjs.map +1 -1
  152. package/dist/server.mjs +2 -0
  153. package/dist/server.mjs.map +1 -1
  154. package/dist/utils/format/currency.mjs +32 -4
  155. package/dist/utils/format/currency.mjs.map +1 -1
  156. package/dist/utils/intl/cookie-domain.mjs +17 -0
  157. package/dist/utils/intl/cookie-domain.mjs.map +1 -0
  158. package/dist/utils/intl/locale-cookie.mjs +13 -0
  159. package/dist/utils/intl/locale-cookie.mjs.map +1 -0
  160. package/dist/utils/intl/locales.mjs +3 -2
  161. package/dist/utils/intl/locales.mjs.map +1 -1
  162. package/package.json +7 -1
  163. package/src/components/account/ConfigurationsMyAccountModal.tsx +10 -6
  164. package/src/components/account/ConfirmDeleteAccountModal.tsx +22 -13
  165. package/src/components/account/ConfirmGlobalPreferencesModal.tsx +12 -10
  166. package/src/components/account/DeleteAccountModal.tsx +34 -24
  167. package/src/components/account/DisableTwoFactorAuthModal.tsx +11 -6
  168. package/src/components/account/IsntPossibleDeleteAccountModal.tsx +8 -6
  169. package/src/components/account/TwoFactorAuthModal.tsx +33 -29
  170. package/src/components/account/constants.ts +8 -5
  171. package/src/components/account/hooks/useChangeEmailForm.tsx +5 -3
  172. package/src/components/account/hooks/useChangePasswordForm.tsx +20 -6
  173. package/src/components/account/hooks/useChangePhoneForm.tsx +16 -10
  174. package/src/components/account/hooks/useDisableTwoFactorAuthForm.tsx +20 -6
  175. package/src/components/account/hooks/useOtpVerification.tsx +16 -4
  176. package/src/components/account/hooks/useTwoFactorAuthForm.tsx +21 -7
  177. package/src/components/account/sections/ChangeEmailModal.tsx +35 -21
  178. package/src/components/account/sections/ChangePasswordSection.tsx +10 -6
  179. package/src/components/account/sections/ChangePhoneModal.tsx +50 -22
  180. package/src/components/account/sections/MyProfileSection.tsx +37 -23
  181. package/src/components/account/sections/PreferencesSection.tsx +52 -25
  182. package/src/components/account/sections/SecuritySection.tsx +19 -10
  183. package/src/components/account/sections/TokenSection.tsx +22 -10
  184. package/src/components/layouts/NavBar.tsx +5 -3
  185. package/src/components/layouts/NotificationsPopover.tsx +5 -3
  186. package/src/components/layouts/ProfilePopover.tsx +6 -4
  187. package/src/components/layouts/UsersSelectorPopover.tsx +9 -7
  188. package/src/components/modals/BuyCreditsModal.tsx +18 -16
  189. package/src/components/modals/CreditsDisabledModal.tsx +6 -6
  190. package/src/components/modals/PaidPlanRequiredModal.tsx +5 -3
  191. package/src/components/modals/cards/AddCardModal.tsx +89 -62
  192. package/src/components/modals/cards/CannotDeleteCardModal.tsx +9 -8
  193. package/src/components/modals/cards/CardFormFields.tsx +93 -75
  194. package/src/components/modals/cards/DeleteCardModal.tsx +10 -8
  195. package/src/components/navigation/CancelledSubscriptionBanner.tsx +4 -2
  196. package/src/components/navigation/OverdueInvoiceBanner.tsx +4 -2
  197. package/src/components/navigation/PendingCancellationBanner.tsx +4 -2
  198. package/src/components/navigation/ProjectSelectorPopover.tsx +8 -6
  199. package/src/components/navigation/UpcomingInvoiceBanner.tsx +4 -2
  200. package/src/components/navigation/subcomponents/BottomLinks.tsx +5 -3
  201. package/src/components/navigation/subcomponents/CreditsCard.tsx +3 -1
  202. package/src/components/navigation/subcomponents/PlanCard.tsx +3 -1
  203. package/src/components/navigation/subcomponents/ProjectSelector.tsx +5 -3
  204. package/src/components/pages/NotFoundPage.tsx +5 -3
  205. package/src/components/pages/notifications/Notifications.tsx +13 -10
  206. package/src/components/ui/buttons/CopyButton.tsx +10 -5
  207. package/src/components/ui/data-display/CardItem.tsx +7 -5
  208. package/src/components/ui/data-display/PaymentInfoCard.tsx +10 -8
  209. package/src/components/ui/feedback/CircularProgress.tsx +4 -0
  210. package/src/components/ui/feedback/DefaultCircularProgress.tsx +3 -1
  211. package/src/components/ui/form/ComboboxField.tsx +11 -6
  212. package/src/components/ui/form/DatePicker.tsx +5 -2
  213. package/src/components/ui/form/DateRangePicker.tsx +5 -2
  214. package/src/components/ui/form/PhoneInput.tsx +5 -3
  215. package/src/components/ui/form/SelectField.tsx +6 -3
  216. package/src/components/widgets/ImageUpload/ImageCropModal.tsx +19 -11
  217. package/src/components/widgets/ImageUpload/ImageTooSmallModal.tsx +6 -5
  218. package/src/i18n/config.ts +17 -0
  219. package/src/i18n/country-language.ts +60 -0
  220. package/src/i18n/messages/en-us.ts +515 -0
  221. package/src/i18n/messages/es-es.ts +516 -0
  222. package/src/i18n/messages/index.ts +24 -0
  223. package/src/i18n/messages/pt-br.ts +539 -0
  224. package/src/i18n/normalize.ts +15 -0
  225. package/src/i18n/resolve-locale.ts +77 -0
  226. package/src/i18n.ts +10 -0
  227. package/src/index.ts +13 -2
  228. package/src/modules/accounts/hooks/use-currency-formatter.hook.tsx +32 -0
  229. package/src/modules/cards/hooks/handle-delete-card.hook.ts +8 -3
  230. package/src/modules/images/utils/validate-image.ts +23 -8
  231. package/src/modules/plans/handlers/list-plans.handler.ts +1 -1
  232. package/src/modules/plans/hooks/list-plans.hook.ts +2 -2
  233. package/src/modules/plans/services/plans.service.ts +1 -1
  234. package/src/modules/plans/types/plan.type.ts +9 -1
  235. package/src/modules/plans/utils/map-api-plan-to-ui.ts +115 -46
  236. package/src/modules/projects/services/projects.service.ts +12 -0
  237. package/src/modules/subscriptions/utils/periodicity.ts +29 -12
  238. package/src/providers/auth.provider.tsx +13 -1
  239. package/src/server.ts +2 -0
  240. package/src/utils/format/currency.ts +62 -7
  241. package/src/utils/intl/cookie-domain.ts +29 -0
  242. package/src/utils/intl/locale-cookie.ts +18 -0
  243. package/src/utils/intl/locales.ts +3 -2
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import { useCallback, useState } from 'react';
3
+ import { useCallback, useState, useEffect } from 'react';
4
4
  import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../ui/overlay/Dialog';
5
5
  import { Button } from '../../ui/buttons/Button';
6
6
  import { Toast } from '../../ui/feedback/Toast';
@@ -8,8 +8,9 @@ import { useModalManager } from '../../../store/useModalManager';
8
8
  import { useCreateCard } from '../../../modules/cards/hooks/create-card.hook';
9
9
  import { useCreateSetupIntent } from '../../../modules/cards/hooks/create-setup-intent.hook';
10
10
  import { useUpdateAccount } from '../../../modules/accounts/hooks/useAccountManagement';
11
+ import { useCurrentAccount } from '../../../modules/accounts/hooks/current-account.hook';
11
12
  import { useExternalContracting } from '../../../providers/whitelabel.provider';
12
- import { CardFormFields, BillingFormFields, cardFormSchema } from './CardFormFields';
13
+ import { CardFormFields, BillingFormFields, buildCardFormSchema } from './CardFormFields';
13
14
  import type { CardFormData, StripeElementsStatus } from './CardFormFields';
14
15
  import { IconX, IconCreditCard, IconCheck, IconChevronRight } from '@tabler/icons-react';
15
16
  import { cn } from '../../../infra/utils/clsx';
@@ -17,6 +18,7 @@ import { useForm } from 'react-hook-form';
17
18
  import { zodResolver } from '@hookform/resolvers/zod';
18
19
  import { CardNumberElement, useElements, useStripe } from '@stripe/react-stripe-js';
19
20
  import { toast } from 'sonner';
21
+ import { useTranslations } from 'next-intl';
20
22
 
21
23
  const INITIAL_STRIPE_STATUS: StripeElementsStatus = {
22
24
  cardNumber: false,
@@ -24,15 +26,15 @@ const INITIAL_STRIPE_STATUS: StripeElementsStatus = {
24
26
  cardCvc: false,
25
27
  };
26
28
 
27
- const STEPS = [
28
- { number: 1, label: 'Cobrança' },
29
- { number: 2, label: 'Cartão' },
30
- ] as const;
31
-
32
29
  function CardStepper({ currentStep }: { readonly currentStep: number }) {
30
+ const translate = useTranslations();
31
+ const steps = [
32
+ { number: 1, label: translate('common.cards.add.stepBilling') },
33
+ { number: 2, label: translate('common.cards.add.stepCard') },
34
+ ];
33
35
  return (
34
36
  <div className="flex items-center justify-start gap-2 px-4 py-3 bg-zinc-50 border-b border-zinc-200 lg:border-b-0">
35
- {STEPS.map((step, idx) => {
37
+ {steps.map((step, idx) => {
36
38
  const isCompleted = currentStep > step.number;
37
39
  const isCurrent = currentStep === step.number;
38
40
  const isPending = !isCompleted && !isCurrent;
@@ -61,7 +63,7 @@ function CardStepper({ currentStep }: { readonly currentStep: number }) {
61
63
  >
62
64
  {step.label}
63
65
  </span>
64
- {idx < STEPS.length - 1 && (
66
+ {idx < steps.length - 1 && (
65
67
  <IconChevronRight size={16} className="text-zinc-300 ml-1" />
66
68
  )}
67
69
  </div>
@@ -72,9 +74,12 @@ function CardStepper({ currentStep }: { readonly currentStep: number }) {
72
74
  }
73
75
 
74
76
  export default function AddCardModal() {
77
+ const translate = useTranslations();
75
78
  const { activeModal, modalData, closeModal } = useModalManager();
76
79
  const isOpen = activeModal === 'addCardModal';
77
80
  const { isExternalContracting, redirectToExternal } = useExternalContracting();
81
+ const { data: account } = useCurrentAccount();
82
+ const isInternational = account?.gateway === 'stripe_usd';
78
83
  const [currentStep, setCurrentStep] = useState(1);
79
84
  const [stripeStatus, setStripeStatus] = useState<StripeElementsStatus>(INITIAL_STRIPE_STATUS);
80
85
  const [stripeErrors, setStripeErrors] = useState<Record<string, string | undefined>>({});
@@ -89,7 +94,7 @@ export default function AddCardModal() {
89
94
  const stripe = useStripe();
90
95
 
91
96
  const form = useForm<CardFormData>({
92
- resolver: zodResolver(cardFormSchema),
97
+ resolver: zodResolver(buildCardFormSchema(isInternational)),
93
98
  mode: 'onSubmit',
94
99
  reValidateMode: 'onChange',
95
100
  defaultValues: {
@@ -98,6 +103,12 @@ export default function AddCardModal() {
98
103
  },
99
104
  });
100
105
 
106
+ useEffect(() => {
107
+ if (isInternational) {
108
+ form.setValue('country', 'US');
109
+ }
110
+ }, [isInternational, form]);
111
+
101
112
  const handleClose = useCallback(() => {
102
113
  form.reset();
103
114
  setCurrentStep(1);
@@ -118,18 +129,13 @@ export default function AddCardModal() {
118
129
  );
119
130
 
120
131
  const handleContinue = useCallback(async () => {
121
- const isValid = await form.trigger([
122
- 'fullName',
123
- 'cep',
124
- 'street',
125
- 'streetNumber',
126
- 'neighborhood',
127
- 'city',
128
- 'state',
129
- ]);
132
+ const fields: (keyof CardFormData)[] = isInternational
133
+ ? ['fullName', 'cep', 'street', 'city', 'state']
134
+ : ['fullName', 'cep', 'street', 'streetNumber', 'neighborhood', 'city', 'state'];
135
+ const isValid = await form.trigger(fields);
130
136
  if (!isValid) return;
131
137
  setCurrentStep(2);
132
- }, [form]);
138
+ }, [form, isInternational]);
133
139
 
134
140
  const handleBack = useCallback(() => {
135
141
  setCurrentStep(1);
@@ -137,9 +143,9 @@ export default function AddCardModal() {
137
143
 
138
144
  async function handleSubmit(data: CardFormData) {
139
145
  const newStripeErrors: Record<string, string | undefined> = {};
140
- if (!stripeStatus.cardNumber) newStripeErrors.cardNumber = 'Número do cartão é obrigatório';
141
- if (!stripeStatus.cardExpiry) newStripeErrors.cardExpiry = 'Data de validade é obrigatória';
142
- if (!stripeStatus.cardCvc) newStripeErrors.cardCvc = 'Código de segurança é obrigatório';
146
+ if (!stripeStatus.cardNumber) newStripeErrors.cardNumber = translate('common.cards.form.cardNumberRequired');
147
+ if (!stripeStatus.cardExpiry) newStripeErrors.cardExpiry = translate('common.cards.form.cardExpiryRequired');
148
+ if (!stripeStatus.cardCvc) newStripeErrors.cardCvc = translate('common.cards.form.cardCvcRequired');
143
149
  setStripeErrors(newStripeErrors);
144
150
 
145
151
  const stripeValid =
@@ -159,7 +165,7 @@ export default function AddCardModal() {
159
165
  (t) => (
160
166
  <Toast
161
167
  variant="error"
162
- message="Não foi possível iniciar a autenticação do cartão, tente novamente."
168
+ message={translate('common.cards.add.errorInitAuth')}
163
169
  toastId={t}
164
170
  />
165
171
  ),
@@ -168,10 +174,24 @@ export default function AddCardModal() {
168
174
  return;
169
175
  }
170
176
 
177
+ const billingDetails = isInternational
178
+ ? {
179
+ name: data.name,
180
+ address: {
181
+ line1: data.street,
182
+ line2: data.complement || undefined,
183
+ city: data.city,
184
+ state: data.state,
185
+ postal_code: data.cep,
186
+ country: data.country,
187
+ },
188
+ }
189
+ : { name: data.name };
190
+
171
191
  const { setupIntent, error } = await stripe.confirmCardSetup(intent.client_secret, {
172
192
  payment_method: {
173
193
  card: cardElement,
174
- billing_details: { name: data.name },
194
+ billing_details: billingDetails,
175
195
  },
176
196
  });
177
197
 
@@ -180,7 +200,7 @@ export default function AddCardModal() {
180
200
  (t) => (
181
201
  <Toast
182
202
  variant="error"
183
- message={error.message || 'Falha na autenticação do cartão.'}
203
+ message={error.message || translate('common.cards.add.errorAuth')}
184
204
  toastId={t}
185
205
  />
186
206
  ),
@@ -194,7 +214,7 @@ export default function AddCardModal() {
194
214
  (t) => (
195
215
  <Toast
196
216
  variant="error"
197
- message={`Autenticação não concluída (status: ${setupIntent?.status ?? 'desconhecido'}).`}
217
+ message={translate('common.cards.add.errorAuthStatus', { status: setupIntent?.status ?? translate('common.cards.add.statusUnknown') })}
198
218
  toastId={t}
199
219
  />
200
220
  ),
@@ -210,14 +230,18 @@ export default function AddCardModal() {
210
230
  set_default: true,
211
231
  }),
212
232
  updateAccountMutation.mutateAsync({
213
- financial_document_type: data.personType === 'pf' ? 1 : 2,
214
- financial_document: data.personType === 'pf' ? data.cpf : data.cnpj,
233
+ ...(isInternational
234
+ ? {}
235
+ : {
236
+ financial_document_type: data.personType === 'pf' ? 1 : 2,
237
+ financial_document: data.personType === 'pf' ? data.cpf : data.cnpj,
238
+ }),
215
239
  financial_name: data.fullName,
216
240
  zipcode: data.cep,
217
241
  address: data.street,
218
- address_number: data.streetNumber,
242
+ address_number: data.streetNumber || '',
219
243
  address_complement: data.complement || '',
220
- neighborhood: data.neighborhood,
244
+ neighborhood: data.neighborhood || '',
221
245
  city: data.city,
222
246
  state: data.state,
223
247
  country: data.country,
@@ -229,7 +253,7 @@ export default function AddCardModal() {
229
253
  }
230
254
 
231
255
  toast.custom(
232
- (t) => <Toast variant="success" message="Cartão adicionado com sucesso." toastId={t} />,
256
+ (t) => <Toast variant="success" message={translate('common.cards.add.successToast')} toastId={t} />,
233
257
  { duration: 5000 }
234
258
  );
235
259
  handleClose();
@@ -238,7 +262,7 @@ export default function AddCardModal() {
238
262
  (t) => (
239
263
  <Toast
240
264
  variant="error"
241
- message="Não foi possível salvar o seu novo cartão, tente novamente."
265
+ message={translate('common.cards.add.errorSave')}
242
266
  toastId={t}
243
267
  />
244
268
  ),
@@ -256,22 +280,24 @@ export default function AddCardModal() {
256
280
 
257
281
  const watchedValues = form.watch(['name', 'country', 'personType', 'cpf', 'cnpj', 'fullName', 'cep', 'street', 'streetNumber', 'neighborhood', 'city', 'state']);
258
282
  const [name, country, personType, cpf, cnpj, fullName, cep, street, streetNumber, neighborhood, city, state] = watchedValues;
259
- const isBillingValid =
260
- !!fullName &&
261
- !!cep && cep.length >= 9 &&
262
- !!street &&
263
- !!streetNumber &&
264
- !!neighborhood &&
265
- !!city &&
266
- !!state;
267
- const isCardValid =
268
- !!name &&
269
- !!country &&
270
- !!personType &&
271
- (personType === 'pf' ? !!cpf && cpf.length >= 14 : !!cnpj && cnpj.length >= 18) &&
272
- stripeStatus.cardNumber &&
273
- stripeStatus.cardExpiry &&
274
- stripeStatus.cardCvc;
283
+ const isBillingValid = isInternational
284
+ ? !!fullName && !!cep && !!street && !!city && !!state
285
+ : !!fullName &&
286
+ !!cep && cep.length >= 9 &&
287
+ !!street &&
288
+ !!streetNumber &&
289
+ !!neighborhood &&
290
+ !!city &&
291
+ !!state;
292
+ const isCardValid = isInternational
293
+ ? !!name && !!country && stripeStatus.cardNumber && stripeStatus.cardExpiry && stripeStatus.cardCvc
294
+ : !!name &&
295
+ !!country &&
296
+ !!personType &&
297
+ (personType === 'pf' ? !!cpf && cpf.length >= 14 : !!cnpj && cnpj.length >= 18) &&
298
+ stripeStatus.cardNumber &&
299
+ stripeStatus.cardExpiry &&
300
+ stripeStatus.cardCvc;
275
301
 
276
302
  if (isExternalContracting) {
277
303
  return (
@@ -283,10 +309,10 @@ export default function AddCardModal() {
283
309
  </div>
284
310
  <div className="flex flex-col gap-2">
285
311
  <DialogTitle className="paragraph-medium-semibold text-zinc-950">
286
- Gerenciamento de cartões indisponível
312
+ {translate('common.cards.add.externalTitle')}
287
313
  </DialogTitle>
288
314
  <span className="paragraph-small-regular text-zinc-600">
289
- Acesse sua área de assinatura para gerenciar formas de pagamento.
315
+ {translate('common.cards.add.externalDescription')}
290
316
  </span>
291
317
  </div>
292
318
  </DialogHeader>
@@ -298,7 +324,7 @@ export default function AddCardModal() {
298
324
  redirectToExternal('contracting');
299
325
  }}
300
326
  >
301
- Acessar área de assinatura
327
+ {translate('common.cards.add.externalButton')}
302
328
  </Button>
303
329
  </div>
304
330
  </DialogContent>
@@ -315,7 +341,7 @@ export default function AddCardModal() {
315
341
  <DialogHeader className="p-0">
316
342
  <div className="flex items-center justify-center px-4 py-3 relative border-b border-zinc-200 lg:border-b-0">
317
343
  <DialogTitle className="paragraph-medium-semibold text-zinc-950 text-center">
318
- Adicionar cartão
344
+ {translate('common.cards.add.title')}
319
345
  </DialogTitle>
320
346
  <Button
321
347
  type="button"
@@ -336,18 +362,19 @@ export default function AddCardModal() {
336
362
  >
337
363
  <div className={`flex flex-col gap-6 lg:gap-8 p-4 lg:p-5 flex-1 lg:flex-none ${currentStep !== 1 ? 'hidden' : ''}`}>
338
364
  <h2 className="font-[family-name:var(--font-outfit)] text-[18px] leading-tight font-semibold text-zinc-950">
339
- Adicione suas informações de cobrança
365
+ {translate('common.cards.add.billingHeading')}
340
366
  </h2>
341
- <BillingFormFields form={form} />
367
+ <BillingFormFields form={form} isInternational={isInternational} />
342
368
  </div>
343
369
  <div className={`flex flex-col gap-6 lg:gap-8 p-4 lg:p-5 flex-1 lg:flex-none ${currentStep !== 2 ? 'hidden' : ''}`}>
344
370
  <h2 className="font-[family-name:var(--font-outfit)] text-[18px] leading-tight font-semibold text-zinc-950">
345
- Adicione informações do seu cartão
371
+ {translate('common.cards.add.cardHeading')}
346
372
  </h2>
347
373
  <CardFormFields
348
374
  form={form}
349
375
  onStripeChange={handleStripeChange}
350
376
  stripeErrors={stripeErrors}
377
+ isInternational={isInternational}
351
378
  />
352
379
  </div>
353
380
 
@@ -355,7 +382,7 @@ export default function AddCardModal() {
355
382
  {currentStep === 1 ? (
356
383
  <>
357
384
  <Button variant="secondary" type="button" onClick={handleClose} className="h-10!">
358
- Cancelar
385
+ {translate('common.actions.cancel')}
359
386
  </Button>
360
387
  <Button
361
388
  type="button"
@@ -363,13 +390,13 @@ export default function AddCardModal() {
363
390
  onClick={handleContinue}
364
391
  disabled={!isBillingValid}
365
392
  >
366
- Continuar
393
+ {translate('common.actions.continue')}
367
394
  </Button>
368
395
  </>
369
396
  ) : (
370
397
  <>
371
398
  <Button variant="secondary" type="button" onClick={handleBack} className="h-10!">
372
- Voltar
399
+ {translate('common.actions.back')}
373
400
  </Button>
374
401
  <Button
375
402
  type="submit"
@@ -378,10 +405,10 @@ export default function AddCardModal() {
378
405
  loading={isAuthenticating || isSubmitting}
379
406
  >
380
407
  {isAuthenticating
381
- ? 'Autenticando...'
408
+ ? translate('common.cards.add.authenticating')
382
409
  : isSubmitting
383
- ? 'Adicionando cartão...'
384
- : 'Adicionar cartão'}
410
+ ? translate('common.cards.add.submitting')
411
+ : translate('common.cards.add.submit')}
385
412
  </Button>
386
413
  </>
387
414
  )}
@@ -12,8 +12,10 @@ import { useCards } from '../../../modules/cards/hooks/cards.hook';
12
12
  import { useActiveSubscription } from '../../../modules/subscriptions/hooks/find-active-subscription.hook';
13
13
  import { useUpdateSubscriptionPayment } from '../../../modules/subscriptions/hooks/update-subscription-payment.hook';
14
14
  import type { Card } from '../../../modules/cards/types';
15
+ import { useTranslations } from 'next-intl';
15
16
 
16
17
  export function CannotDeleteCardModal() {
18
+ const translate = useTranslations();
17
19
  const { activeModal, modalData, closeModal, openModal } = useModalManager();
18
20
  const { data: cardsData } = useCards();
19
21
  const { mutateAsync: updatePayment } = useUpdateSubscriptionPayment();
@@ -49,7 +51,7 @@ export function CannotDeleteCardModal() {
49
51
  message={
50
52
  error instanceof Error
51
53
  ? error.message
52
- : 'Erro ao atualizar cartão da assinatura'
54
+ : translate('common.cards.cannotDelete.errorUpdateCard')
53
55
  }
54
56
  toastId={t}
55
57
  />
@@ -69,7 +71,7 @@ export function CannotDeleteCardModal() {
69
71
  return (
70
72
  <Dialog open={isOpen} onOpenChange={(open) => !open && closeModal()}>
71
73
  <DialogTitle className="sr-only">
72
- Não é possível excluir este cartão
74
+ {translate('common.cards.cannotDelete.title')}
73
75
  </DialogTitle>
74
76
  <DialogContent className="flex flex-col p-0 max-w-full sm:max-w-full border-0 rounded-t-2xl rounded-b-none h-dvh top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0 lg:max-w-[436px] lg:h-auto lg:max-h-[90vh] lg:rounded-lg lg:border lg:top-[50%] lg:left-[50%] lg:right-auto lg:bottom-auto lg:translate-x-[-50%] lg:translate-y-[-50%] overflow-hidden">
75
77
  <div className="flex flex-col gap-5 p-4 lg:p-5">
@@ -79,11 +81,10 @@ export function CannotDeleteCardModal() {
79
81
 
80
82
  <div className="flex flex-col gap-2">
81
83
  <h2 className="paragraph-medium-semibold text-zinc-950">
82
- Não é possível excluir este cartão
84
+ {translate('common.cards.cannotDelete.title')}
83
85
  </h2>
84
86
  <p className="paragraph-small-regular text-zinc-600">
85
- Este cartão está em uso e tem uma assinatura ativa vinculada a ele.
86
- Selecione outro cartão como padrão ou adicione um novo.
87
+ {translate('common.cards.cannotDelete.description')}
87
88
  </p>
88
89
  </div>
89
90
  </div>
@@ -91,7 +92,7 @@ export function CannotDeleteCardModal() {
91
92
  {availableCards.length > 0 && (
92
93
  <div className="flex flex-col gap-3 px-4 lg:px-5 pb-4 lg:pb-5 overflow-y-auto max-h-[200px] flex-1 lg:flex-none">
93
94
  <span className="paragraph-xsmall-semibold text-zinc-600">
94
- Selecione um cartão como padrão:
95
+ {translate('common.cards.cannotDelete.selectDefault')}
95
96
  </span>
96
97
  {availableCards.map((card) => (
97
98
  <CardItem
@@ -107,14 +108,14 @@ export function CannotDeleteCardModal() {
107
108
  <div className="flex flex-row gap-2 p-4 lg:p-5 border-t border-zinc-200 mt-auto lg:mt-0">
108
109
  <Button onClick={handleAddCard} className="h-10! flex-1">
109
110
  <IconPlus size={20} />
110
- Adicionar novo cartão
111
+ {translate('common.cards.cannotDelete.addNewCard')}
111
112
  </Button>
112
113
  <Button
113
114
  variant="secondary"
114
115
  onClick={() => closeModal()}
115
116
  className="h-10! flex-1"
116
117
  >
117
- Cancelar
118
+ {translate('common.actions.cancel')}
118
119
  </Button>
119
120
  </div>
120
121
  </DialogContent>