@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.
- package/dist/components/layouts/AppMobileNavBar.mjs +5 -64
- package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -1
- package/dist/components/layouts/AppNavBar.mjs +0 -2
- package/dist/components/layouts/AppNavBar.mjs.map +1 -1
- package/dist/components/layouts/NavBar.mjs +52 -111
- package/dist/components/layouts/NavBar.mjs.map +1 -1
- package/dist/components/modals/cards/AddCardModal.mjs +3 -2
- package/dist/components/modals/cards/AddCardModal.mjs.map +1 -1
- package/dist/components/ui/form/PhoneInput.mjs +1 -1
- package/dist/components/ui/form/PhoneInput.mjs.map +1 -1
- package/dist/handlers.mjs +0 -2
- package/dist/handlers.mjs.map +1 -1
- package/dist/i18n/messages/en-us.mjs +1 -3
- package/dist/i18n/messages/en-us.mjs.map +1 -1
- package/dist/i18n/messages/es-es.mjs +1 -3
- package/dist/i18n/messages/es-es.mjs.map +1 -1
- package/dist/i18n/messages/pt-br.mjs +1 -3
- package/dist/i18n/messages/pt-br.mjs.map +1 -1
- package/dist/index.mjs +1 -9
- package/dist/index.mjs.map +1 -1
- package/dist/infra/api/client.mjs +1 -5
- package/dist/infra/api/client.mjs.map +1 -1
- package/dist/infra/api/types.mjs +1 -1
- package/dist/infra/api/types.mjs.map +1 -1
- package/dist/infra/route/safe-route-handler.mjs +1 -4
- package/dist/infra/route/safe-route-handler.mjs.map +1 -1
- package/dist/modules/auth/utils/assert-account-not-frozen.mjs +5 -6
- package/dist/modules/auth/utils/assert-account-not-frozen.mjs.map +1 -1
- package/dist/modules/auth/utils/assert-management-subscription.mjs +14 -7
- package/dist/modules/auth/utils/assert-management-subscription.mjs.map +1 -1
- package/dist/modules/auth/utils/assert-paid-subscription.mjs +12 -7
- package/dist/modules/auth/utils/assert-paid-subscription.mjs.map +1 -1
- package/dist/modules/auth/utils/assert-subscription-addon.mjs +10 -2
- package/dist/modules/auth/utils/assert-subscription-addon.mjs.map +1 -1
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/actions/update-subscription-payment.action.mjs.map +1 -1
- package/dist/modules/subscriptions/constants/subscription.constants.mjs +0 -2
- package/dist/modules/subscriptions/constants/subscription.constants.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +13 -2
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/update-subscription-payment.hook.mjs +10 -2
- package/dist/modules/subscriptions/hooks/update-subscription-payment.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/services/subscriptions.service.mjs +12 -27
- package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -1
- package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -1
- package/dist/modules/subscriptions/utils/has-active-paid-subscription.mjs +1 -1
- package/dist/modules/subscriptions/utils/has-active-paid-subscription.mjs.map +1 -1
- package/dist/modules/subscriptions/utils/has-paid-subscription.mjs +1 -1
- package/dist/modules/subscriptions/utils/has-paid-subscription.mjs.map +1 -1
- package/dist/server.mjs +0 -4
- package/dist/server.mjs.map +1 -1
- package/dist/store/useMdSidebarStore.mjs +4 -17
- package/dist/store/useMdSidebarStore.mjs.map +1 -1
- package/dist/utils/safeServerAction.mjs +1 -4
- package/dist/utils/safeServerAction.mjs.map +1 -1
- package/dist/utils/withAction.mjs +1 -2
- package/dist/utils/withAction.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/layouts/AppMobileNavBar.tsx +6 -90
- package/src/components/layouts/AppNavBar.tsx +1 -5
- package/src/components/layouts/NavBar.tsx +66 -160
- package/src/components/modals/cards/AddCardModal.tsx +15 -2
- package/src/components/ui/form/PhoneInput.tsx +1 -1
- package/src/handlers.ts +0 -1
- package/src/i18n/messages/en-us.ts +0 -2
- package/src/i18n/messages/es-es.ts +0 -2
- package/src/i18n/messages/pt-br.ts +0 -2
- package/src/index.ts +2 -7
- package/src/infra/api/client.ts +3 -11
- package/src/infra/api/types.ts +5 -7
- package/src/infra/route/safe-route-handler.ts +1 -4
- package/src/modules/auth/utils/assert-account-not-frozen.ts +6 -7
- package/src/modules/auth/utils/assert-management-subscription.ts +23 -15
- package/src/modules/auth/utils/assert-paid-subscription.ts +15 -7
- package/src/modules/auth/utils/assert-subscription-addon.ts +12 -2
- package/src/modules/plans/hooks/use-plan-by-id.hook.ts +1 -1
- package/src/modules/subscriptions/actions/update-subscription-payment.action.ts +6 -1
- package/src/modules/subscriptions/constants/subscription.constants.ts +0 -3
- package/src/modules/subscriptions/hooks/find-active-subscription.hook.ts +17 -7
- package/src/modules/subscriptions/hooks/update-subscription-payment.hook.ts +21 -3
- package/src/modules/subscriptions/services/subscriptions.service.ts +46 -38
- package/src/modules/subscriptions/types/subscription.type.ts +27 -2
- package/src/modules/subscriptions/utils/has-active-paid-subscription.ts +2 -1
- package/src/modules/subscriptions/utils/has-paid-subscription.ts +2 -1
- package/src/server.ts +0 -2
- package/src/store/useMdSidebarStore.ts +5 -20
- package/src/utils/safeServerAction.ts +6 -4
- package/src/utils/withAction.ts +1 -2
- package/dist/components/layouts/GreatDomainIcon.mjs +0 -40
- package/dist/components/layouts/GreatDomainIcon.mjs.map +0 -1
- package/dist/modules/subscriptions/actions/get-current-subscription.action.mjs +0 -10
- package/dist/modules/subscriptions/actions/get-current-subscription.action.mjs.map +0 -1
- package/dist/modules/subscriptions/handlers/current-subscription.handler.mjs +0 -17
- package/dist/modules/subscriptions/handlers/current-subscription.handler.mjs.map +0 -1
- package/dist/modules/subscriptions/hooks/use-current-subscription.hook.mjs +0 -28
- package/dist/modules/subscriptions/hooks/use-current-subscription.hook.mjs.map +0 -1
- package/dist/modules/subscriptions/utils/group-subscriptions-by-product.mjs +0 -16
- package/dist/modules/subscriptions/utils/group-subscriptions-by-product.mjs.map +0 -1
- package/dist/modules/subscriptions/utils/read-current-subscription.mjs +0 -21
- package/dist/modules/subscriptions/utils/read-current-subscription.mjs.map +0 -1
- package/src/components/layouts/GreatDomainIcon.tsx +0 -43
- package/src/modules/subscriptions/actions/get-current-subscription.action.ts +0 -8
- package/src/modules/subscriptions/handlers/current-subscription.handler.ts +0 -16
- package/src/modules/subscriptions/hooks/use-current-subscription.hook.ts +0 -38
- package/src/modules/subscriptions/utils/group-subscriptions-by-product.ts +0 -23
- 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
|
-
);
|