@greatapps/common 1.1.673 → 1.1.675
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/account/ConfigurationsMyAccountModal.mjs +6 -8
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
- package/dist/components/account/ConfirmDeleteAccountModal.mjs +19 -20
- package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +11 -10
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -1
- package/dist/components/account/DeleteAccountModal.mjs +28 -34
- package/dist/components/account/DeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/DisableTwoFactorAuthModal.mjs +5 -7
- package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +9 -8
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/TwoFactorAuthModal.mjs +23 -22
- package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/hooks/useChangeEmailForm.mjs +3 -5
- package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -1
- package/dist/components/account/hooks/useChangePasswordForm.mjs +3 -26
- package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -1
- package/dist/components/account/hooks/useChangePhoneForm.mjs +9 -18
- package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -1
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +3 -26
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/hooks/useOtpVerification.mjs +3 -19
- package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -1
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +4 -27
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/sections/ChangeEmailModal.mjs +28 -25
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -1
- package/dist/components/account/sections/ChangePasswordSection.mjs +6 -8
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -1
- package/dist/components/account/sections/ChangePhoneModal.mjs +27 -24
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -1
- package/dist/components/account/sections/MyProfileSection.mjs +22 -37
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
- package/dist/components/account/sections/PreferencesSection.mjs +24 -48
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
- package/dist/components/account/sections/SecuritySection.mjs +9 -11
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -1
- package/dist/components/account/sections/TokenSection.mjs +8 -24
- package/dist/components/account/sections/TokenSection.mjs.map +1 -1
- package/dist/components/layouts/AppMobileNavBar.mjs +148 -2
- package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -1
- package/dist/components/layouts/NavBar.mjs +3 -5
- package/dist/components/layouts/NavBar.mjs.map +1 -1
- package/dist/components/layouts/NotificationsPopover.mjs +3 -5
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -1
- package/dist/components/layouts/ProfilePopover.mjs +4 -6
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -1
- package/dist/components/layouts/UsersSelectorPopover.mjs +7 -9
- package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -1
- package/dist/components/modals/BuyCreditsModal.mjs +18 -17
- package/dist/components/modals/BuyCreditsModal.mjs.map +1 -1
- package/dist/components/modals/CreditsDisabledModal.mjs +4 -6
- package/dist/components/modals/CreditsDisabledModal.mjs.map +1 -1
- package/dist/components/modals/PaidPlanRequiredModal.mjs +3 -5
- package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -1
- package/dist/components/modals/cards/AddCardModal.mjs +24 -27
- package/dist/components/modals/cards/AddCardModal.mjs.map +1 -1
- package/dist/components/modals/cards/CannotDeleteCardModal.mjs +7 -9
- package/dist/components/modals/cards/CannotDeleteCardModal.mjs.map +1 -1
- package/dist/components/modals/cards/CardFormFields.mjs +22 -25
- package/dist/components/modals/cards/CardFormFields.mjs.map +1 -1
- package/dist/components/modals/cards/DeleteCardModal.mjs +8 -10
- package/dist/components/modals/cards/DeleteCardModal.mjs.map +1 -1
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs +2 -4
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -1
- package/dist/components/navigation/OverdueInvoiceBanner.mjs +2 -4
- package/dist/components/navigation/OverdueInvoiceBanner.mjs.map +1 -1
- package/dist/components/navigation/PendingCancellationBanner.mjs +6 -4
- package/dist/components/navigation/PendingCancellationBanner.mjs.map +1 -1
- package/dist/components/navigation/ProjectSelectorPopover.mjs +6 -8
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -1
- package/dist/components/navigation/UpcomingInvoiceBanner.mjs +6 -4
- package/dist/components/navigation/UpcomingInvoiceBanner.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/BottomLinks.mjs +3 -5
- package/dist/components/navigation/subcomponents/BottomLinks.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/CreditsCard.mjs +1 -3
- package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/PlanCard.mjs +1 -3
- package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +3 -5
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -1
- package/dist/components/pages/NotFoundPage.mjs +3 -5
- package/dist/components/pages/NotFoundPage.mjs.map +1 -1
- package/dist/components/pages/notifications/Notifications.mjs +10 -13
- package/dist/components/pages/notifications/Notifications.mjs.map +1 -1
- package/dist/components/ui/buttons/CopyButton.mjs +5 -9
- package/dist/components/ui/buttons/CopyButton.mjs.map +1 -1
- package/dist/components/ui/data-display/CardItem.mjs +5 -7
- package/dist/components/ui/data-display/CardItem.mjs.map +1 -1
- package/dist/components/ui/data-display/PaymentInfoCard.mjs +8 -10
- package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs +1 -3
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -1
- package/dist/components/ui/form/ComboboxField.mjs +6 -11
- package/dist/components/ui/form/ComboboxField.mjs.map +1 -1
- package/dist/components/ui/form/DatePicker.mjs +2 -5
- package/dist/components/ui/form/DatePicker.mjs.map +1 -1
- package/dist/components/ui/form/DateRangePicker.mjs +2 -5
- package/dist/components/ui/form/DateRangePicker.mjs.map +1 -1
- package/dist/components/ui/form/PhoneInput.mjs +3 -5
- package/dist/components/ui/form/PhoneInput.mjs.map +1 -1
- package/dist/components/ui/form/SelectField.mjs +3 -6
- package/dist/components/ui/form/SelectField.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageCropModal.mjs +18 -11
- package/dist/components/widgets/ImageUpload/ImageCropModal.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageTooSmallModal.mjs +15 -6
- package/dist/components/widgets/ImageUpload/ImageTooSmallModal.mjs.map +1 -1
- package/dist/index.mjs +2 -16
- package/dist/index.mjs.map +1 -1
- package/dist/modules/cards/hooks/handle-delete-card.hook.mjs +1 -2
- package/dist/modules/cards/hooks/handle-delete-card.hook.mjs.map +1 -1
- package/dist/modules/plans/types/plan.type.mjs +0 -3
- package/dist/modules/plans/types/plan.type.mjs.map +1 -1
- package/dist/modules/plans/utils/map-api-plan-to-ui.mjs +8 -15
- package/dist/modules/plans/utils/map-api-plan-to-ui.mjs.map +1 -1
- package/dist/providers/auth.provider.mjs +1 -9
- package/dist/providers/auth.provider.mjs.map +1 -1
- package/dist/server.mjs +0 -2
- package/dist/server.mjs.map +1 -1
- package/dist/utils/format/currency.mjs +4 -32
- package/dist/utils/format/currency.mjs.map +1 -1
- package/dist/utils/intl/locales.mjs +2 -3
- package/dist/utils/intl/locales.mjs.map +1 -1
- package/package.json +1 -7
- package/src/components/account/ConfigurationsMyAccountModal.tsx +6 -10
- package/src/components/account/ConfirmDeleteAccountModal.tsx +13 -22
- package/src/components/account/ConfirmGlobalPreferencesModal.tsx +10 -12
- package/src/components/account/DeleteAccountModal.tsx +24 -34
- package/src/components/account/DisableTwoFactorAuthModal.tsx +6 -11
- package/src/components/account/IsntPossibleDeleteAccountModal.tsx +6 -8
- package/src/components/account/TwoFactorAuthModal.tsx +29 -33
- package/src/components/account/hooks/useChangeEmailForm.tsx +3 -5
- package/src/components/account/hooks/useChangePasswordForm.tsx +6 -20
- package/src/components/account/hooks/useChangePhoneForm.tsx +10 -16
- package/src/components/account/hooks/useDisableTwoFactorAuthForm.tsx +6 -20
- package/src/components/account/hooks/useOtpVerification.tsx +4 -16
- package/src/components/account/hooks/useTwoFactorAuthForm.tsx +7 -21
- package/src/components/account/sections/ChangeEmailModal.tsx +21 -35
- package/src/components/account/sections/ChangePasswordSection.tsx +6 -10
- package/src/components/account/sections/ChangePhoneModal.tsx +22 -50
- package/src/components/account/sections/MyProfileSection.tsx +23 -37
- package/src/components/account/sections/PreferencesSection.tsx +25 -52
- package/src/components/account/sections/SecuritySection.tsx +10 -19
- package/src/components/account/sections/TokenSection.tsx +10 -22
- package/src/components/layouts/AppMobileNavBar.tsx +154 -1
- package/src/components/layouts/NavBar.tsx +3 -5
- package/src/components/layouts/NotificationsPopover.tsx +3 -5
- package/src/components/layouts/ProfilePopover.tsx +4 -6
- package/src/components/layouts/UsersSelectorPopover.tsx +7 -9
- package/src/components/modals/BuyCreditsModal.tsx +16 -18
- package/src/components/modals/CreditsDisabledModal.tsx +6 -6
- package/src/components/modals/PaidPlanRequiredModal.tsx +3 -5
- package/src/components/modals/cards/AddCardModal.tsx +27 -29
- package/src/components/modals/cards/CannotDeleteCardModal.tsx +8 -9
- package/src/components/modals/cards/CardFormFields.tsx +22 -25
- package/src/components/modals/cards/DeleteCardModal.tsx +8 -10
- package/src/components/navigation/CancelledSubscriptionBanner.tsx +2 -4
- package/src/components/navigation/OverdueInvoiceBanner.tsx +2 -4
- package/src/components/navigation/PendingCancellationBanner.tsx +2 -4
- package/src/components/navigation/ProjectSelectorPopover.tsx +6 -8
- package/src/components/navigation/UpcomingInvoiceBanner.tsx +2 -4
- package/src/components/navigation/subcomponents/BottomLinks.tsx +3 -5
- package/src/components/navigation/subcomponents/CreditsCard.tsx +1 -3
- package/src/components/navigation/subcomponents/PlanCard.tsx +1 -3
- package/src/components/navigation/subcomponents/ProjectSelector.tsx +3 -5
- package/src/components/pages/NotFoundPage.tsx +3 -5
- package/src/components/pages/notifications/Notifications.tsx +10 -13
- package/src/components/ui/buttons/CopyButton.tsx +5 -10
- package/src/components/ui/data-display/CardItem.tsx +5 -7
- package/src/components/ui/data-display/PaymentInfoCard.tsx +8 -10
- package/src/components/ui/feedback/DefaultCircularProgress.tsx +1 -3
- package/src/components/ui/form/ComboboxField.tsx +6 -11
- package/src/components/ui/form/DatePicker.tsx +2 -5
- package/src/components/ui/form/DateRangePicker.tsx +2 -5
- package/src/components/ui/form/PhoneInput.tsx +3 -5
- package/src/components/ui/form/SelectField.tsx +3 -6
- package/src/components/widgets/ImageUpload/ImageCropModal.tsx +11 -19
- package/src/components/widgets/ImageUpload/ImageTooSmallModal.tsx +5 -6
- package/src/index.ts +2 -12
- package/src/modules/cards/hooks/handle-delete-card.hook.ts +3 -8
- package/src/modules/plans/types/plan.type.ts +0 -3
- package/src/modules/plans/utils/map-api-plan-to-ui.ts +7 -30
- package/src/providers/auth.provider.tsx +1 -13
- package/src/server.ts +0 -2
- package/src/utils/format/currency.ts +7 -62
- package/src/utils/intl/locales.ts +2 -3
- package/dist/i18n/config.mjs +0 -13
- package/dist/i18n/config.mjs.map +0 -1
- package/dist/i18n/country-language.mjs +0 -74
- package/dist/i18n/country-language.mjs.map +0 -1
- package/dist/i18n/messages/en-us.mjs +0 -450
- package/dist/i18n/messages/en-us.mjs.map +0 -1
- package/dist/i18n/messages/es-es.mjs +0 -450
- package/dist/i18n/messages/es-es.mjs.map +0 -1
- package/dist/i18n/messages/index.mjs +0 -16
- package/dist/i18n/messages/index.mjs.map +0 -1
- package/dist/i18n/messages/pt-br.mjs +0 -463
- package/dist/i18n/messages/pt-br.mjs.map +0 -1
- package/dist/i18n/normalize.mjs +0 -12
- package/dist/i18n/normalize.mjs.map +0 -1
- package/dist/i18n/resolve-locale.mjs +0 -42
- package/dist/i18n/resolve-locale.mjs.map +0 -1
- package/dist/i18n.mjs +0 -14
- package/dist/i18n.mjs.map +0 -1
- package/dist/modules/accounts/hooks/use-currency-formatter.hook.mjs +0 -20
- package/dist/modules/accounts/hooks/use-currency-formatter.hook.mjs.map +0 -1
- package/dist/utils/intl/cookie-domain.mjs +0 -17
- package/dist/utils/intl/cookie-domain.mjs.map +0 -1
- package/dist/utils/intl/locale-cookie.mjs +0 -13
- package/dist/utils/intl/locale-cookie.mjs.map +0 -1
- package/src/i18n/config.ts +0 -17
- package/src/i18n/country-language.ts +0 -60
- package/src/i18n/messages/en-us.ts +0 -468
- package/src/i18n/messages/es-es.ts +0 -469
- package/src/i18n/messages/index.ts +0 -24
- package/src/i18n/messages/pt-br.ts +0 -492
- package/src/i18n/normalize.ts +0 -15
- package/src/i18n/resolve-locale.ts +0 -77
- package/src/i18n.ts +0 -10
- package/src/modules/accounts/hooks/use-currency-formatter.hook.tsx +0 -32
- package/src/utils/intl/cookie-domain.ts +0 -29
- package/src/utils/intl/locale-cookie.ts +0 -18
package/src/index.ts
CHANGED
|
@@ -137,10 +137,7 @@ export type {
|
|
|
137
137
|
PlanTooltips,
|
|
138
138
|
} from "./modules/plans/types/plan.type";
|
|
139
139
|
export { PlanSchema, PlanItemSchema } from "./modules/plans/types/plan.type";
|
|
140
|
-
export {
|
|
141
|
-
mapApiPlanToUiPlan,
|
|
142
|
-
mapApiPlanToUiPlanForCurrency,
|
|
143
|
-
} from "./modules/plans/utils/map-api-plan-to-ui";
|
|
140
|
+
export { mapApiPlanToUiPlan } from "./modules/plans/utils/map-api-plan-to-ui";
|
|
144
141
|
export type { PlanBillingPeriod } from "./modules/plans/utils/map-api-plan-to-ui";
|
|
145
142
|
export {
|
|
146
143
|
usePlans,
|
|
@@ -465,13 +462,7 @@ export {
|
|
|
465
462
|
formatCNPJ,
|
|
466
463
|
formatCardNumber,
|
|
467
464
|
} from "./utils/format/masks";
|
|
468
|
-
export {
|
|
469
|
-
formatCurrency,
|
|
470
|
-
formatCurrencyNumber,
|
|
471
|
-
parseCurrencyToNumber,
|
|
472
|
-
getCurrencyForGateway,
|
|
473
|
-
} from "./utils/format/currency";
|
|
474
|
-
export type { CurrencyCode } from "./utils/format/currency";
|
|
465
|
+
export { formatCurrencyNumber } from "./utils/format/currency";
|
|
475
466
|
export { BR_STATE_OPTIONS } from "./utils/constants/br-states";
|
|
476
467
|
export type { TimezoneOption } from "./modules/accounts/services/timezone.service";
|
|
477
468
|
export {
|
|
@@ -495,7 +486,6 @@ export {
|
|
|
495
486
|
useCurrentAccount,
|
|
496
487
|
ACCOUNT_QUERY_KEY,
|
|
497
488
|
} from "./modules/accounts/hooks/current-account.hook";
|
|
498
|
-
export { useCurrencyFormatter } from "./modules/accounts/hooks/use-currency-formatter.hook";
|
|
499
489
|
export {
|
|
500
490
|
useUpdateAccount,
|
|
501
491
|
useUpdateAccountUser,
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import { useModalManager } from '../../../store/useModalManager';
|
|
5
5
|
import { useActiveSubscription } from '../../subscriptions/hooks/find-active-subscription.hook';
|
|
6
|
-
import { hasSubscriptionExpired } from '../../subscriptions/utils/has-subscription-expired';
|
|
7
6
|
import type { Card } from '../types';
|
|
8
7
|
|
|
9
8
|
type UseHandleDeleteCardOptions = {
|
|
@@ -19,15 +18,11 @@ export function useHandleDeleteCard({
|
|
|
19
18
|
|
|
20
19
|
return useCallback(
|
|
21
20
|
(card: Card) => {
|
|
22
|
-
// Só bloqueia a exclusão quando o cartão é o método de pagamento de uma
|
|
23
|
-
// assinatura REALMENTE ativa (mesma definição de ConfigurationsMyAccountModal).
|
|
24
|
-
// Se a assinatura foi cancelada ou já expirou, ela não está mais ativa —
|
|
25
|
-
// pula a verificação e segue direto pra exclusão do cartão.
|
|
26
21
|
const isCardLinkedToSubscription =
|
|
27
22
|
!!activeSubscription &&
|
|
28
|
-
activeSubscription.
|
|
29
|
-
!activeSubscription.
|
|
30
|
-
|
|
23
|
+
!!activeSubscription.date_cancellation &&
|
|
24
|
+
(!activeSubscription.date_due ||
|
|
25
|
+
activeSubscription.date_due < new Date()) &&
|
|
31
26
|
card.id.toString() === activeSubscription.id_card?.toString();
|
|
32
27
|
|
|
33
28
|
if (isCardLinkedToSubscription) {
|
|
@@ -14,9 +14,6 @@ export const PlanSchema = z.object({
|
|
|
14
14
|
id_plan: z.number().optional(),
|
|
15
15
|
name: z.string(),
|
|
16
16
|
value: z.number().default(0),
|
|
17
|
-
// Preço em USD (conta stripe_usd). Operador cadastra no backend; ausente em planos
|
|
18
|
-
// sem suporte internacional. Espelha a coluna value_usd de gapps-r3-api.
|
|
19
|
-
value_usd: z.number().nullish(),
|
|
20
17
|
type: z.string().optional(),
|
|
21
18
|
discount_semester: z.number().default(0),
|
|
22
19
|
discount_annual: z.number().default(0),
|
|
@@ -6,10 +6,7 @@ import type {
|
|
|
6
6
|
UiPlan,
|
|
7
7
|
} from "../types/plan.type";
|
|
8
8
|
import { ADDON_IDS } from "../../subscriptions/constants/addons.constants";
|
|
9
|
-
import {
|
|
10
|
-
formatCurrencyNumber,
|
|
11
|
-
type CurrencyCode,
|
|
12
|
-
} from "../../../utils/format/currency";
|
|
9
|
+
import { formatCurrencyNumber } from "../../../utils/format/currency";
|
|
13
10
|
|
|
14
11
|
export type PlanBillingPeriod = "monthly" | "semiannual" | "annual";
|
|
15
12
|
|
|
@@ -46,10 +43,8 @@ function buildMainFeaturesFromItems(items: Plan["items"]): PlanMainFeatures {
|
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
45
|
|
|
49
|
-
function computePricingByPeriod(apiPlan: Plan
|
|
50
|
-
|
|
51
|
-
// não cadastrou o preço internacional. Os descontos por período são percentuais — aplicam igual.
|
|
52
|
-
const monthly = currency === "usd" ? (apiPlan.value_usd ?? apiPlan.value) : apiPlan.value;
|
|
46
|
+
function computePricingByPeriod(apiPlan: Plan): PlanPricingByPeriod {
|
|
47
|
+
const monthly = apiPlan.value;
|
|
53
48
|
const round2 = (n: number) => Math.round(n * 100) / 100;
|
|
54
49
|
return {
|
|
55
50
|
monthly,
|
|
@@ -58,11 +53,11 @@ function computePricingByPeriod(apiPlan: Plan, currency: CurrencyCode): PlanPric
|
|
|
58
53
|
};
|
|
59
54
|
}
|
|
60
55
|
|
|
61
|
-
function
|
|
56
|
+
export function mapApiPlanToUiPlan(plan: Plan): UiPlan {
|
|
62
57
|
const popular = plan.id === 2 || plan.id_plan === 2;
|
|
63
58
|
const buttonVariant = popular ? "brand" : "default";
|
|
64
59
|
|
|
65
|
-
const pricingByPeriod = computePricingByPeriod(plan
|
|
60
|
+
const pricingByPeriod = computePricingByPeriod(plan);
|
|
66
61
|
const monthlyFinal = pricingByPeriod.monthly;
|
|
67
62
|
|
|
68
63
|
const lowerName = plan.name.toLowerCase();
|
|
@@ -95,27 +90,9 @@ function buildUiPlan(plan: Plan, currency: CurrencyCode): UiPlan {
|
|
|
95
90
|
buttonVariant,
|
|
96
91
|
mainFeatures: buildMainFeaturesFromItems(plan.items),
|
|
97
92
|
features,
|
|
98
|
-
originalPrice: formatCurrencyNumber(monthlyFinal
|
|
99
|
-
price: formatCurrencyNumber(monthlyFinal
|
|
93
|
+
originalPrice: formatCurrencyNumber(monthlyFinal),
|
|
94
|
+
price: formatCurrencyNumber(monthlyFinal),
|
|
100
95
|
pricingByPeriod,
|
|
101
96
|
items: plan.items,
|
|
102
97
|
};
|
|
103
98
|
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Mapeia um plano da API para UiPlan em BRL.
|
|
107
|
-
* Assinatura de 1 argumento — seguro em `plans.map(mapApiPlanToUiPlan)`.
|
|
108
|
-
*/
|
|
109
|
-
export function mapApiPlanToUiPlan(plan: Plan): UiPlan {
|
|
110
|
-
return buildUiPlan(plan, "brl");
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Variante currency-aware: a moeda vem do gateway da conta (getCurrencyForGateway).
|
|
115
|
-
* Fábrica para uso ergonômico em `.map`: `plans.map(mapApiPlanToUiPlanForCurrency(currency))`.
|
|
116
|
-
* Mantida separada de mapApiPlanToUiPlan para não quebrar callers que passam a fn direto pro `.map`.
|
|
117
|
-
*/
|
|
118
|
-
export const mapApiPlanToUiPlanForCurrency =
|
|
119
|
-
(currency: CurrencyCode) =>
|
|
120
|
-
(plan: Plan): UiPlan =>
|
|
121
|
-
buildUiPlan(plan, currency);
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
ReactNode,
|
|
6
6
|
useCallback,
|
|
7
7
|
useContext,
|
|
8
|
-
useEffect,
|
|
9
8
|
useMemo,
|
|
10
9
|
} from "react";
|
|
11
10
|
import { useQueryClient } from "@tanstack/react-query";
|
|
@@ -42,10 +41,8 @@ import {
|
|
|
42
41
|
useCurrentAccount,
|
|
43
42
|
ACCOUNT_QUERY_KEY,
|
|
44
43
|
} from "../modules/accounts/hooks/current-account.hook";
|
|
45
|
-
import { useWhitelabelUrls
|
|
44
|
+
import { useWhitelabelUrls } from "./whitelabel.provider";
|
|
46
45
|
import { useWlQueryKey } from "../hooks/useAuthQueryKey";
|
|
47
|
-
import { normalizeLocale } from "../i18n/normalize";
|
|
48
|
-
import { setLocaleCookie } from "../utils/intl/locale-cookie";
|
|
49
46
|
|
|
50
47
|
interface AuthContextProps extends AuthState {
|
|
51
48
|
login: (credentials: LoginRequest) => Promise<LoginResult>;
|
|
@@ -71,17 +68,8 @@ export function AuthProvider({ children }: AuthProviderProps) {
|
|
|
71
68
|
const queryClient = useQueryClient();
|
|
72
69
|
const setUserData = useSetUserData();
|
|
73
70
|
const { accountsUrl, pagesUrl } = useWhitelabelUrls();
|
|
74
|
-
const { whitelabel } = useWhitelabel();
|
|
75
71
|
const accountKey = useWlQueryKey([...ACCOUNT_QUERY_KEY]);
|
|
76
72
|
|
|
77
|
-
// Mantém o cookie NEXT_LOCALE alinhado à preferência da conta (login, sessão existente,
|
|
78
|
-
// atualização). Compartilhado entre subdomínios via domínio do whitelabel. A próxima
|
|
79
|
-
// navegação/requisição passa a resolver o locale pela preferência do usuário.
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
const locale = normalizeLocale(user?.language);
|
|
82
|
-
if (locale) setLocaleCookie(locale, whitelabel?.domain);
|
|
83
|
-
}, [user?.language, whitelabel?.domain]);
|
|
84
|
-
|
|
85
73
|
const { mutateAsync: loginMutate, isPending: isLogging } = useLogin();
|
|
86
74
|
const { mutateAsync: registerMutate, isPending: isRegistering } =
|
|
87
75
|
useRegister();
|
package/src/server.ts
CHANGED
|
@@ -74,8 +74,6 @@ export {
|
|
|
74
74
|
// Server Utils
|
|
75
75
|
export { getClientInfoFromRequest } from './infra/utils/client-info';
|
|
76
76
|
export { getUserContext } from './modules/auth/utils/get-user-context';
|
|
77
|
-
export { resolveLocale } from './i18n/resolve-locale';
|
|
78
|
-
export type { ResolveLocaleOptions } from './i18n/resolve-locale';
|
|
79
77
|
export { requireValidSession } from './modules/auth/utils/require-valid-session';
|
|
80
78
|
export { requireTokenNotExpired } from './modules/auth/utils/require-token-not-expired';
|
|
81
79
|
export { buildWlOverride, buildWlOverrideFromJwt } from './modules/auth/utils/build-wl-override';
|
|
@@ -1,69 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Formata um número (opcional) para moeda BRL
|
|
3
|
+
* @param value - Número a ser formatado (pode ser undefined ou null)
|
|
4
|
+
* @param decimals - Casas decimais (padrão: 2)
|
|
5
|
+
* @returns String formatada como "R$ X.XXX,XX"
|
|
4
6
|
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
const CURRENCY_FORMAT: Record<CurrencyCode, { locale: string; currency: string }> = {
|
|
8
|
-
brl: { locale: 'pt-BR', currency: 'BRL' },
|
|
9
|
-
usd: { locale: 'en-US', currency: 'USD' },
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Deriva a moeda de exibição a partir do gateway da conta.
|
|
14
|
-
* A moeda é definida pelo backend no roteamento de gateway — read-only para o usuário.
|
|
15
|
-
* @param gateway - account.gateway ('stripe_usd' | 'stripe_brl' | 'vindi' | ...)
|
|
16
|
-
*/
|
|
17
|
-
export const getCurrencyForGateway = (gateway?: string | null): CurrencyCode =>
|
|
18
|
-
gateway === 'stripe_usd' ? 'usd' : 'brl';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Formata um valor (string ou número) como moeda.
|
|
22
|
-
* String: assume centavos (remove não-dígitos e divide por 100) — comportamento legado.
|
|
23
|
-
* @param value - valor a formatar
|
|
24
|
-
* @param currency - moeda de exibição (padrão 'brl' por retrocompatibilidade)
|
|
25
|
-
* @returns String formatada (ex: "R$ 1.234,56" ou "$1,234.56")
|
|
26
|
-
*/
|
|
27
|
-
export const formatCurrency = (value: string | number, currency: CurrencyCode = 'brl'): string => {
|
|
28
|
-
const fmt = CURRENCY_FORMAT[currency];
|
|
29
|
-
if (typeof value === 'number') {
|
|
30
|
-
return value.toLocaleString(fmt.locale, {
|
|
31
|
-
style: 'currency',
|
|
32
|
-
currency: fmt.currency,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const numericValue = value.replace(/\D/g, '');
|
|
37
|
-
const numberValue = parseFloat(numericValue) / 100;
|
|
38
|
-
return numberValue.toLocaleString(fmt.locale, {
|
|
39
|
-
style: 'currency',
|
|
40
|
-
currency: fmt.currency,
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Converte uma string de moeda para número (centavos / 100). Independente de moeda.
|
|
46
|
-
* @param value - String com valor de moeda
|
|
47
|
-
* @returns Número decimal
|
|
48
|
-
*/
|
|
49
|
-
export const parseCurrencyToNumber = (value: string): number => {
|
|
50
|
-
const numericValue = value.replace(/\D/g, '');
|
|
51
|
-
return parseFloat(numericValue) / 100;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Formata um número (opcional) como moeda.
|
|
56
|
-
* @param value - Número a formatar (pode ser undefined/null → 0)
|
|
57
|
-
* @param decimals - Casas decimais (padrão 2)
|
|
58
|
-
* @param currency - Moeda de exibição (padrão 'brl' por retrocompatibilidade)
|
|
59
|
-
* @returns String formatada (ex: "R$ 1.234,56" ou "$1,234.56")
|
|
60
|
-
*/
|
|
61
|
-
export const formatCurrencyNumber = (value?: number | null, decimals = 2, currency: CurrencyCode = 'brl'): string => {
|
|
7
|
+
export const formatCurrencyNumber = (value?: number | null, decimals = 2): string => {
|
|
62
8
|
const safeValue = value ?? 0;
|
|
63
|
-
|
|
64
|
-
return safeValue.toLocaleString(fmt.locale, {
|
|
9
|
+
return safeValue.toLocaleString('pt-BR', {
|
|
65
10
|
style: 'currency',
|
|
66
|
-
currency:
|
|
11
|
+
currency: 'BRL',
|
|
67
12
|
minimumFractionDigits: decimals,
|
|
68
13
|
maximumFractionDigits: decimals,
|
|
69
14
|
});
|
|
@@ -6,9 +6,8 @@ export type LocaleOption = {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export const LANGUAGE_OPTIONS: LocaleOption[] = [
|
|
9
|
-
{ value: 'pt-
|
|
10
|
-
{ value: 'en-
|
|
11
|
-
{ value: 'es-es', label: 'Espanhol', displayValue: 'Espanhol', apiValue: 'es' },
|
|
9
|
+
{ value: 'pt-BR', label: 'Português (Brasil)', displayValue: 'Português (Brasil)', apiValue: 'pt-br' },
|
|
10
|
+
{ value: 'en-US', label: 'Inglês (EUA)', displayValue: 'Inglês (EUA)', apiValue: 'en' },
|
|
12
11
|
];
|
|
13
12
|
|
|
14
13
|
export function buildLocaleOptions(): LocaleOption[] {
|
package/dist/i18n/config.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const LOCALES = ["pt-br", "en-us", "es-es"];
|
|
2
|
-
const DEFAULT_LOCALE = "pt-br";
|
|
3
|
-
const LOCALE_COOKIE = "NEXT_LOCALE";
|
|
4
|
-
function isLocale(value) {
|
|
5
|
-
return typeof value === "string" && LOCALES.includes(value);
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
DEFAULT_LOCALE,
|
|
9
|
-
LOCALES,
|
|
10
|
-
LOCALE_COOKIE,
|
|
11
|
-
isLocale
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=config.mjs.map
|
package/dist/i18n/config.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i18n/config.ts"],"sourcesContent":["/**\n * Locales suportados pela plataforma GreatApps.\n * Identificadores no padrão `idioma-REGIÃO` em minúsculas: `pt-br`, `en-us`, `es-es`.\n */\nexport const LOCALES = ['pt-br', 'en-us', 'es-es'] as const;\n\nexport type Locale = (typeof LOCALES)[number];\n\n/** Idioma padrão — fallback final (o produto nasce em pt-BR). */\nexport const DEFAULT_LOCALE: Locale = 'pt-br';\n\n/** Nome do cookie onde o locale resolvido é persistido (convenção next-intl). */\nexport const LOCALE_COOKIE = 'NEXT_LOCALE';\n\nexport function isLocale(value: unknown): value is Locale {\n return typeof value === 'string' && (LOCALES as readonly string[]).includes(value);\n}\n"],"mappings":"AAIO,MAAM,UAAU,CAAC,SAAS,SAAS,OAAO;AAK1C,MAAM,iBAAyB;AAG/B,MAAM,gBAAgB;AAEtB,SAAS,SAAS,OAAiC;AACxD,SAAO,OAAO,UAAU,YAAa,QAA8B,SAAS,KAAK;AACnF;","names":[]}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
const PORTUGUESE_COUNTRIES = /* @__PURE__ */ new Set([
|
|
2
|
-
"BR",
|
|
3
|
-
// Brasil
|
|
4
|
-
"PT",
|
|
5
|
-
// Portugal
|
|
6
|
-
"AO",
|
|
7
|
-
// Angola
|
|
8
|
-
"MZ",
|
|
9
|
-
// Moçambique
|
|
10
|
-
"CV",
|
|
11
|
-
// Cabo Verde
|
|
12
|
-
"GW",
|
|
13
|
-
// Guiné-Bissau
|
|
14
|
-
"ST",
|
|
15
|
-
// São Tomé e Príncipe
|
|
16
|
-
"TL"
|
|
17
|
-
// Timor-Leste
|
|
18
|
-
]);
|
|
19
|
-
const SPANISH_COUNTRIES = /* @__PURE__ */ new Set([
|
|
20
|
-
"ES",
|
|
21
|
-
// Espanha
|
|
22
|
-
"MX",
|
|
23
|
-
// México
|
|
24
|
-
"AR",
|
|
25
|
-
// Argentina
|
|
26
|
-
"CO",
|
|
27
|
-
// Colômbia
|
|
28
|
-
"PE",
|
|
29
|
-
// Peru
|
|
30
|
-
"VE",
|
|
31
|
-
// Venezuela
|
|
32
|
-
"CL",
|
|
33
|
-
// Chile
|
|
34
|
-
"EC",
|
|
35
|
-
// Equador
|
|
36
|
-
"GT",
|
|
37
|
-
// Guatemala
|
|
38
|
-
"CU",
|
|
39
|
-
// Cuba
|
|
40
|
-
"BO",
|
|
41
|
-
// Bolívia
|
|
42
|
-
"DO",
|
|
43
|
-
// República Dominicana
|
|
44
|
-
"HN",
|
|
45
|
-
// Honduras
|
|
46
|
-
"PY",
|
|
47
|
-
// Paraguai
|
|
48
|
-
"SV",
|
|
49
|
-
// El Salvador
|
|
50
|
-
"NI",
|
|
51
|
-
// Nicarágua
|
|
52
|
-
"CR",
|
|
53
|
-
// Costa Rica
|
|
54
|
-
"PA",
|
|
55
|
-
// Panamá
|
|
56
|
-
"UY",
|
|
57
|
-
// Uruguai
|
|
58
|
-
"PR",
|
|
59
|
-
// Porto Rico
|
|
60
|
-
"GQ"
|
|
61
|
-
// Guiné Equatorial
|
|
62
|
-
]);
|
|
63
|
-
function localeFromCountry(country) {
|
|
64
|
-
if (!country) return null;
|
|
65
|
-
const code = country.trim().toUpperCase();
|
|
66
|
-
if (code === "XX" || code === "T1") return null;
|
|
67
|
-
if (PORTUGUESE_COUNTRIES.has(code)) return "pt-br";
|
|
68
|
-
if (SPANISH_COUNTRIES.has(code)) return "es-es";
|
|
69
|
-
return "en-us";
|
|
70
|
-
}
|
|
71
|
-
export {
|
|
72
|
-
localeFromCountry
|
|
73
|
-
};
|
|
74
|
-
//# sourceMappingURL=country-language.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i18n/country-language.ts"],"sourcesContent":["import { Locale } from './config';\n\n/**\n * Países de língua portuguesa (ISO 3166-1 alpha-2).\n */\nconst PORTUGUESE_COUNTRIES = new Set<string>([\n 'BR', // Brasil\n 'PT', // Portugal\n 'AO', // Angola\n 'MZ', // Moçambique\n 'CV', // Cabo Verde\n 'GW', // Guiné-Bissau\n 'ST', // São Tomé e Príncipe\n 'TL', // Timor-Leste\n]);\n\n/**\n * Países de língua espanhola (ISO 3166-1 alpha-2).\n */\nconst SPANISH_COUNTRIES = new Set<string>([\n 'ES', // Espanha\n 'MX', // México\n 'AR', // Argentina\n 'CO', // Colômbia\n 'PE', // Peru\n 'VE', // Venezuela\n 'CL', // Chile\n 'EC', // Equador\n 'GT', // Guatemala\n 'CU', // Cuba\n 'BO', // Bolívia\n 'DO', // República Dominicana\n 'HN', // Honduras\n 'PY', // Paraguai\n 'SV', // El Salvador\n 'NI', // Nicarágua\n 'CR', // Costa Rica\n 'PA', // Panamá\n 'UY', // Uruguai\n 'PR', // Porto Rico\n 'GQ', // Guiné Equatorial\n]);\n\n/**\n * Infere o idioma a partir do código de país (ex.: header `CF-IPCountry` da Cloudflare\n * ou `session.location.country` do JWT):\n * - país lusófono → `pt`\n * - país hispanófono → `es`\n * - demais países → `en`\n *\n * Retorna `null` quando o país é desconhecido/ausente (deixa o fallback de locale decidir).\n */\nexport function localeFromCountry(country?: string | null): Locale | null {\n if (!country) return null;\n const code = country.trim().toUpperCase();\n if (code === 'XX' || code === 'T1') return null; // Cloudflare: desconhecido / Tor\n if (PORTUGUESE_COUNTRIES.has(code)) return 'pt-br';\n if (SPANISH_COUNTRIES.has(code)) return 'es-es';\n return 'en-us';\n}\n"],"mappings":"AAKA,MAAM,uBAAuB,oBAAI,IAAY;AAAA,EAC3C;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF,CAAC;AAKD,MAAM,oBAAoB,oBAAI,IAAY;AAAA,EACxC;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF,CAAC;AAWM,SAAS,kBAAkB,SAAwC;AACxE,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,OAAO,QAAQ,KAAK,EAAE,YAAY;AACxC,MAAI,SAAS,QAAQ,SAAS,KAAM,QAAO;AAC3C,MAAI,qBAAqB,IAAI,IAAI,EAAG,QAAO;AAC3C,MAAI,kBAAkB,IAAI,IAAI,EAAG,QAAO;AACxC,SAAO;AACT;","names":[]}
|