@greatapps/common 1.1.784 → 1.1.785

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 (106) hide show
  1. package/dist/components/layouts/AppMobileNavBar.mjs +5 -64
  2. package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -1
  3. package/dist/components/layouts/AppNavBar.mjs +0 -2
  4. package/dist/components/layouts/AppNavBar.mjs.map +1 -1
  5. package/dist/components/layouts/NavBar.mjs +52 -111
  6. package/dist/components/layouts/NavBar.mjs.map +1 -1
  7. package/dist/components/modals/cards/AddCardModal.mjs +3 -2
  8. package/dist/components/modals/cards/AddCardModal.mjs.map +1 -1
  9. package/dist/components/ui/form/PhoneInput.mjs +1 -1
  10. package/dist/components/ui/form/PhoneInput.mjs.map +1 -1
  11. package/dist/handlers.mjs +0 -2
  12. package/dist/handlers.mjs.map +1 -1
  13. package/dist/i18n/messages/en-us.mjs +1 -3
  14. package/dist/i18n/messages/en-us.mjs.map +1 -1
  15. package/dist/i18n/messages/es-es.mjs +1 -3
  16. package/dist/i18n/messages/es-es.mjs.map +1 -1
  17. package/dist/i18n/messages/pt-br.mjs +1 -3
  18. package/dist/i18n/messages/pt-br.mjs.map +1 -1
  19. package/dist/index.mjs +1 -9
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/infra/api/client.mjs +1 -5
  22. package/dist/infra/api/client.mjs.map +1 -1
  23. package/dist/infra/api/types.mjs +1 -1
  24. package/dist/infra/api/types.mjs.map +1 -1
  25. package/dist/infra/route/safe-route-handler.mjs +1 -4
  26. package/dist/infra/route/safe-route-handler.mjs.map +1 -1
  27. package/dist/modules/auth/utils/assert-account-not-frozen.mjs +5 -6
  28. package/dist/modules/auth/utils/assert-account-not-frozen.mjs.map +1 -1
  29. package/dist/modules/auth/utils/assert-management-subscription.mjs +14 -7
  30. package/dist/modules/auth/utils/assert-management-subscription.mjs.map +1 -1
  31. package/dist/modules/auth/utils/assert-paid-subscription.mjs +12 -7
  32. package/dist/modules/auth/utils/assert-paid-subscription.mjs.map +1 -1
  33. package/dist/modules/auth/utils/assert-subscription-addon.mjs +10 -2
  34. package/dist/modules/auth/utils/assert-subscription-addon.mjs.map +1 -1
  35. package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -1
  36. package/dist/modules/subscriptions/actions/update-subscription-payment.action.mjs.map +1 -1
  37. package/dist/modules/subscriptions/constants/subscription.constants.mjs +0 -2
  38. package/dist/modules/subscriptions/constants/subscription.constants.mjs.map +1 -1
  39. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +13 -2
  40. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -1
  41. package/dist/modules/subscriptions/hooks/update-subscription-payment.hook.mjs +10 -2
  42. package/dist/modules/subscriptions/hooks/update-subscription-payment.hook.mjs.map +1 -1
  43. package/dist/modules/subscriptions/services/subscriptions.service.mjs +12 -27
  44. package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -1
  45. package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -1
  46. package/dist/modules/subscriptions/utils/has-active-paid-subscription.mjs +1 -1
  47. package/dist/modules/subscriptions/utils/has-active-paid-subscription.mjs.map +1 -1
  48. package/dist/modules/subscriptions/utils/has-paid-subscription.mjs +1 -1
  49. package/dist/modules/subscriptions/utils/has-paid-subscription.mjs.map +1 -1
  50. package/dist/server.mjs +0 -4
  51. package/dist/server.mjs.map +1 -1
  52. package/dist/store/useMdSidebarStore.mjs +4 -17
  53. package/dist/store/useMdSidebarStore.mjs.map +1 -1
  54. package/dist/utils/safeServerAction.mjs +1 -4
  55. package/dist/utils/safeServerAction.mjs.map +1 -1
  56. package/dist/utils/withAction.mjs +1 -2
  57. package/dist/utils/withAction.mjs.map +1 -1
  58. package/package.json +1 -1
  59. package/src/components/layouts/AppMobileNavBar.tsx +6 -90
  60. package/src/components/layouts/AppNavBar.tsx +1 -5
  61. package/src/components/layouts/NavBar.tsx +66 -160
  62. package/src/components/modals/cards/AddCardModal.tsx +15 -2
  63. package/src/components/ui/form/PhoneInput.tsx +1 -1
  64. package/src/handlers.ts +0 -1
  65. package/src/i18n/messages/en-us.ts +0 -2
  66. package/src/i18n/messages/es-es.ts +0 -2
  67. package/src/i18n/messages/pt-br.ts +0 -2
  68. package/src/index.ts +2 -7
  69. package/src/infra/api/client.ts +3 -11
  70. package/src/infra/api/types.ts +5 -7
  71. package/src/infra/route/safe-route-handler.ts +1 -4
  72. package/src/modules/auth/utils/assert-account-not-frozen.ts +6 -7
  73. package/src/modules/auth/utils/assert-management-subscription.ts +23 -15
  74. package/src/modules/auth/utils/assert-paid-subscription.ts +15 -7
  75. package/src/modules/auth/utils/assert-subscription-addon.ts +12 -2
  76. package/src/modules/plans/hooks/use-plan-by-id.hook.ts +1 -1
  77. package/src/modules/subscriptions/actions/update-subscription-payment.action.ts +6 -1
  78. package/src/modules/subscriptions/constants/subscription.constants.ts +0 -3
  79. package/src/modules/subscriptions/hooks/find-active-subscription.hook.ts +17 -7
  80. package/src/modules/subscriptions/hooks/update-subscription-payment.hook.ts +21 -3
  81. package/src/modules/subscriptions/services/subscriptions.service.ts +46 -38
  82. package/src/modules/subscriptions/types/subscription.type.ts +27 -2
  83. package/src/modules/subscriptions/utils/has-active-paid-subscription.ts +2 -1
  84. package/src/modules/subscriptions/utils/has-paid-subscription.ts +2 -1
  85. package/src/server.ts +0 -2
  86. package/src/store/useMdSidebarStore.ts +5 -20
  87. package/src/utils/safeServerAction.ts +6 -4
  88. package/src/utils/withAction.ts +1 -2
  89. package/dist/components/layouts/GreatDomainIcon.mjs +0 -40
  90. package/dist/components/layouts/GreatDomainIcon.mjs.map +0 -1
  91. package/dist/modules/subscriptions/actions/get-current-subscription.action.mjs +0 -10
  92. package/dist/modules/subscriptions/actions/get-current-subscription.action.mjs.map +0 -1
  93. package/dist/modules/subscriptions/handlers/current-subscription.handler.mjs +0 -17
  94. package/dist/modules/subscriptions/handlers/current-subscription.handler.mjs.map +0 -1
  95. package/dist/modules/subscriptions/hooks/use-current-subscription.hook.mjs +0 -28
  96. package/dist/modules/subscriptions/hooks/use-current-subscription.hook.mjs.map +0 -1
  97. package/dist/modules/subscriptions/utils/group-subscriptions-by-product.mjs +0 -16
  98. package/dist/modules/subscriptions/utils/group-subscriptions-by-product.mjs.map +0 -1
  99. package/dist/modules/subscriptions/utils/read-current-subscription.mjs +0 -21
  100. package/dist/modules/subscriptions/utils/read-current-subscription.mjs.map +0 -1
  101. package/src/components/layouts/GreatDomainIcon.tsx +0 -43
  102. package/src/modules/subscriptions/actions/get-current-subscription.action.ts +0 -8
  103. package/src/modules/subscriptions/handlers/current-subscription.handler.ts +0 -16
  104. package/src/modules/subscriptions/hooks/use-current-subscription.hook.ts +0 -38
  105. package/src/modules/subscriptions/utils/group-subscriptions-by-product.ts +0 -23
  106. package/src/modules/subscriptions/utils/read-current-subscription.ts +0 -34
@@ -1,38 +0,0 @@
1
- 'use client';
2
-
3
- import { useQuery } from '@tanstack/react-query';
4
- import { apiFetch } from '../../../infra/http/api-fetch';
5
- import { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';
6
- import type { PaginatedSuccessResult, SuccessResult } from '../../../infra/api/types';
7
- import type { Subscription } from '../types/subscription.type';
8
- import { SUBSCRIPTIONS_QUERY_KEY } from '../constants/query-keys.constants';
9
-
10
- /**
11
- * A assinatura corrente do plano da conta, pela regra única do backend
12
- * (contrato de domínio nunca é corrente; encerrada é decidida por `active`).
13
- *
14
- * Devolvida na mesma forma paginada de `useSubscriptions`/`useActiveSubscription`
15
- * (`{ data: [sub] }`) para não exigir mudança nos call sites que já leem
16
- * `data?.[0]`: só a URL e a regra por trás mudam.
17
- */
18
- export function useCurrentSubscription() {
19
- const queryKey = useAuthQueryKey([...SUBSCRIPTIONS_QUERY_KEY, 'current']);
20
-
21
- return useQuery({
22
- queryKey,
23
- queryFn: async ({ signal }): Promise<PaginatedSuccessResult<Subscription>> => {
24
- const result = await apiFetch<SuccessResult<Subscription | null>>(
25
- '/api/subscriptions/current',
26
- { signal },
27
- );
28
- const subscription = result.data ?? null;
29
-
30
- return {
31
- success: true,
32
- data: subscription ? [subscription] : [],
33
- total: subscription ? 1 : 0,
34
- };
35
- },
36
- staleTime: 10_000,
37
- });
38
- }
@@ -1,23 +0,0 @@
1
- import type { Subscription } from '../types/subscription.type';
2
-
3
- /**
4
- * Agrupa assinaturas por `id_product`, preservando a ordem de chegada dentro
5
- * de cada grupo. Base da seção "Domínios registrados" do painel e da aba
6
- * Assinatura agrupada por produto no admin.
7
- */
8
- export function groupSubscriptionsByProduct(
9
- subscriptions: Subscription[],
10
- ): Map<number, Subscription[]> {
11
- const groups = new Map<number, Subscription[]>();
12
-
13
- for (const subscription of subscriptions) {
14
- const group = groups.get(subscription.id_product);
15
- if (group) {
16
- group.push(subscription);
17
- } else {
18
- groups.set(subscription.id_product, [subscription]);
19
- }
20
- }
21
-
22
- return groups;
23
- }
@@ -1,34 +0,0 @@
1
- import "server-only";
2
-
3
- import { cache } from "react";
4
-
5
- import { ApiError } from "../../../infra/api/types";
6
- import { getCurrentSubscriptionAction } from "../actions/get-current-subscription.action";
7
- import type { Subscription } from "../types/subscription.type";
8
-
9
- /**
10
- * Leitura única por request de "qual é a assinatura corrente do plano desta
11
- * conta", deduplicada via React.cache. Os quatro gates de auth
12
- * (`assertAccountNotFrozen`, `assertManagementSubscription`,
13
- * `assertPaidSubscription`, `assertSubscriptionAddon`) chamam esta função em
14
- * vez de repetir a própria leitura cada um: eram até 4 cópias da mesma
15
- * pergunta disputando a mesma fila (0,7 a 7s cada, medido em produção).
16
- *
17
- * Lança em falha de leitura; `assertAccountNotFrozen` é o único chamador que
18
- * precisa de fail-open, e faz isso capturando o erro no próprio call site.
19
- */
20
- export const readCurrentSubscription = cache(
21
- async (): Promise<Subscription | null> => {
22
- const result = await getCurrentSubscriptionAction();
23
-
24
- if (!result.success) {
25
- throw new ApiError(
26
- result.error || "Não foi possível validar a assinatura atual",
27
- "SUBSCRIPTION_CONTEXT_FAILED",
28
- 403,
29
- );
30
- }
31
-
32
- return result.data?.data ?? null;
33
- },
34
- );