@greatapps/common 1.1.543 → 1.1.547

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 (40) hide show
  1. package/dist/components/account/ConfirmDeleteAccountModal.mjs +12 -10
  2. package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -1
  3. package/dist/components/account/DeleteAccountModal.mjs +21 -5
  4. package/dist/components/account/DeleteAccountModal.mjs.map +1 -1
  5. package/dist/components/account/sections/MyProfileSection.mjs +3 -61
  6. package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
  7. package/dist/components/modals/BuyCreditsModal.mjs +1 -1
  8. package/dist/components/modals/BuyCreditsModal.mjs.map +1 -1
  9. package/dist/components/navigation/CancelledSubscriptionBanner.mjs +5 -4
  10. package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -1
  11. package/dist/modules/accounts/actions/account-management.action.mjs +2 -2
  12. package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -1
  13. package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -1
  14. package/dist/modules/accounts/services/account.service.mjs +5 -2
  15. package/dist/modules/accounts/services/account.service.mjs.map +1 -1
  16. package/dist/modules/auth/hooks/useUserQuery.mjs +1 -1
  17. package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -1
  18. package/dist/modules/cards/types.mjs +13 -12
  19. package/dist/modules/cards/types.mjs.map +1 -1
  20. package/dist/modules/plans/utils/map-api-plan-to-ui.mjs +1 -1
  21. package/dist/modules/plans/utils/map-api-plan-to-ui.mjs.map +1 -1
  22. package/dist/modules/subscriptions/types/subscription.type.mjs +2 -1
  23. package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -1
  24. package/dist/store/useAccountModals.mjs +25 -4
  25. package/dist/store/useAccountModals.mjs.map +1 -1
  26. package/package.json +1 -1
  27. package/src/components/account/ConfirmDeleteAccountModal.tsx +16 -7
  28. package/src/components/account/DeleteAccountModal.tsx +24 -4
  29. package/src/components/account/sections/MyProfileSection.tsx +2 -68
  30. package/src/components/modals/BuyCreditsModal.tsx +1 -1
  31. package/src/components/navigation/CancelledSubscriptionBanner.tsx +7 -4
  32. package/src/modules/accounts/actions/account-management.action.ts +3 -2
  33. package/src/modules/accounts/hooks/useAccountManagement.ts +2 -1
  34. package/src/modules/accounts/services/account.service.ts +6 -2
  35. package/src/modules/accounts/types.ts +4 -0
  36. package/src/modules/auth/hooks/useUserQuery.ts +1 -1
  37. package/src/modules/cards/types.ts +14 -12
  38. package/src/modules/plans/utils/map-api-plan-to-ui.ts +1 -1
  39. package/src/modules/subscriptions/types/subscription.type.ts +2 -1
  40. package/src/store/useAccountModals.ts +41 -8
@@ -15,6 +15,7 @@ import type {
15
15
  ChangeUserPhotoResponse,
16
16
  CreateAccountUserRequest,
17
17
  CreateAccountUserResponse,
18
+ DeleteAccountRequest,
18
19
  DeleteAccountResponse,
19
20
  DeleteAccountUserResponse,
20
21
  GetAccountDataResponse,
@@ -94,9 +95,12 @@ class AccountService {
94
95
  return response;
95
96
  }
96
97
 
97
- async deleteAccount(): Promise<DeleteAccountResponse> {
98
+ async deleteAccount(data: DeleteAccountRequest): Promise<DeleteAccountResponse> {
98
99
  const { id_account } = await getUserContext();
99
- const response = await api.apps.delete<DeleteAccountResponse>(`/accounts/${id_account}`);
100
+ const response = await api.apps.delete<DeleteAccountResponse>(
101
+ `/accounts/${id_account}`,
102
+ { body: JSON.stringify(data) }
103
+ );
100
104
 
101
105
  if (response.status === 0) {
102
106
  throw new ApiError(response.message || 'Erro ao deletar conta', 'DELETE_ACCOUNT_FAILED', 400);
@@ -127,6 +127,10 @@ export interface DeleteAccountUserResponse {
127
127
  message?: string;
128
128
  }
129
129
 
130
+ export interface DeleteAccountRequest {
131
+ password: string;
132
+ }
133
+
130
134
  export interface DeleteAccountResponse {
131
135
  status: 0 | 1;
132
136
  message?: string;
@@ -25,7 +25,7 @@ export function useUserQuery() {
25
25
  return useQuery({
26
26
  queryKey,
27
27
  queryFn: fetchUser,
28
- staleTime: 5 * 60 * 1000,
28
+ staleTime: 60 * 1000,
29
29
  gcTime: 10 * 60 * 1000,
30
30
  retry: false,
31
31
  });
@@ -1,16 +1,22 @@
1
1
  import z from 'zod';
2
2
 
3
+ import {
4
+ PaginationParamsSchema,
5
+ SearchParamsSchema,
6
+ SortParamsSchema,
7
+ } from '../../infra/api/types';
8
+
3
9
  export const CardSchema = z.object({
4
10
  id: z.union([z.number(), z.string()]),
5
- id_wl: z.number().optional(),
6
- id_account: z.union([z.number(), z.string()]).optional(),
11
+ id_wl: z.number(),
12
+ id_account: z.union([z.number(), z.string()]),
7
13
  id_gateway: z.union([z.number(), z.string()]).optional(),
8
- gateway_account: z.string().optional(),
9
- gateway_card: z.string().optional(),
14
+ gateway_account: z.string(),
15
+ gateway_card: z.string(),
10
16
  brand: z.string(),
11
17
  name: z.string(),
12
18
  number: z.string().nullable(),
13
- date: z.string().nullable().optional(),
19
+ date: z.string().nullable(),
14
20
  deleted: z
15
21
  .number()
16
22
  .transform((val) => val === 1)
@@ -31,12 +37,8 @@ export const CreateCardRequestSchema = z.object({
31
37
 
32
38
  export type CreateCardRequest = z.infer<typeof CreateCardRequestSchema>;
33
39
 
34
- export const FindCardsParamsSchema = z.object({
35
- page: z.number().optional(),
36
- limit: z.number().optional(),
37
- search: z.string().optional(),
38
- sort: z.string().optional(),
39
- order: z.enum(['asc', 'desc']).optional(),
40
- });
40
+ export const FindCardsParamsSchema = PaginationParamsSchema.extend(SearchParamsSchema.shape).extend(
41
+ SortParamsSchema.shape
42
+ );
41
43
 
42
44
  export type FindCardsParams = z.infer<typeof FindCardsParamsSchema>;
@@ -16,7 +16,7 @@ const BASE_FEATURES: PlanFeature[] = [
16
16
  { icon: "check", text: "Compartilhar páginas", tooltip: "sharePages" },
17
17
  { icon: "check", text: "Hospedagem inclusa" },
18
18
  { icon: "check", text: "SSL (HTTPS) + CDN" },
19
- { icon: "check", text: "Templates Free" },
19
+ { icon: "check", text: "Templates gratuitos" },
20
20
  ];
21
21
 
22
22
  function buildMainFeaturesFromItems(items: Plan["items"]): PlanMainFeatures {
@@ -41,7 +41,7 @@ export const SubscriptionSchema = z.object({
41
41
  id_gateway: z.union([z.number(), z.string()]).nullable(),
42
42
  gateway_account: z.string().nullable(),
43
43
  date_hiring: z.coerce.date().nullable(),
44
- date_due: z.coerce.date(),
44
+ date_due: z.coerce.date().nullable(),
45
45
  date_cancellation: z.coerce.date().nullable(),
46
46
  date_verification: z.coerce.date().nullable(),
47
47
  cancellation_reason: z.string().nullable(),
@@ -52,6 +52,7 @@ export const SubscriptionSchema = z.object({
52
52
  card_name: z.string().nullable().optional(),
53
53
  card_brand: z.string().nullable().optional(),
54
54
  card_number: z.string().nullable().optional(),
55
+ card: z.record(z.string(), z.unknown()).nullable().optional(),
55
56
  items: z.array(SubscriptionItemSchema),
56
57
  pending_change: z.object({
57
58
  schedule_id: z.string(),
@@ -13,18 +13,29 @@ export interface AccountModalsConfig {
13
13
  onGoToSubscription?: () => void;
14
14
  }
15
15
 
16
+ interface DeleteAccountPayload {
17
+ password: string;
18
+ }
19
+
16
20
  interface AccountModalsState {
17
21
  activeModal: AccountModalType | null;
18
22
  config: AccountModalsConfig;
19
23
  initialSection?: AccountSectionType;
20
24
 
25
+ /** Payload coletado no DeleteAccountModal, consumido pelo ConfirmDeleteAccountModal. */
26
+ deleteAccountPayload: DeleteAccountPayload | null;
27
+ /** Mensagem de erro do backend quando o delete falha (ex.: senha inválida).
28
+ * Mostrada no DeleteAccountModal quando o usuário é mandado de volta. */
29
+ deleteAccountError: string | null;
30
+
21
31
  /** Called by <AccountModals> to keep app-level config in sync */
22
32
  updateConfig: (config: AccountModalsConfig) => void;
23
33
 
24
34
  openConfigurations: (initialSection?: AccountSectionType) => void;
25
- openDeleteAccount: () => void;
35
+ openDeleteAccount: (error?: string) => void;
26
36
  openIsntPossibleDelete: () => void;
27
- openConfirmDelete: () => void;
37
+ openConfirmDelete: (payload: DeleteAccountPayload) => void;
38
+ clearDeleteAccountError: () => void;
28
39
  close: () => void;
29
40
  }
30
41
 
@@ -32,21 +43,43 @@ export const useAccountModals = create<AccountModalsState>((set) => ({
32
43
  activeModal: null,
33
44
  config: {},
34
45
  initialSection: undefined,
46
+ deleteAccountPayload: null,
47
+ deleteAccountError: null,
35
48
 
36
49
  updateConfig: (config) => set({ config }),
37
50
 
38
51
  openConfigurations: (initialSection) =>
39
- set({ activeModal: 'configurations', initialSection }),
52
+ set({
53
+ activeModal: 'configurations',
54
+ initialSection,
55
+ deleteAccountPayload: null,
56
+ deleteAccountError: null,
57
+ }),
40
58
 
41
- openDeleteAccount: () =>
42
- set({ activeModal: 'deleteAccount' }),
59
+ openDeleteAccount: (error) =>
60
+ set({
61
+ activeModal: 'deleteAccount',
62
+ deleteAccountPayload: null,
63
+ deleteAccountError: error ?? null,
64
+ }),
43
65
 
44
66
  openIsntPossibleDelete: () =>
45
67
  set({ activeModal: 'isntPossibleDelete' }),
46
68
 
47
- openConfirmDelete: () =>
48
- set({ activeModal: 'confirmDelete' }),
69
+ openConfirmDelete: (payload) =>
70
+ set({
71
+ activeModal: 'confirmDelete',
72
+ deleteAccountPayload: payload,
73
+ deleteAccountError: null,
74
+ }),
75
+
76
+ clearDeleteAccountError: () => set({ deleteAccountError: null }),
49
77
 
50
78
  close: () =>
51
- set({ activeModal: null, initialSection: undefined }),
79
+ set({
80
+ activeModal: null,
81
+ initialSection: undefined,
82
+ deleteAccountPayload: null,
83
+ deleteAccountError: null,
84
+ }),
52
85
  }));