@greatapps/common 1.1.541 → 1.1.543

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 (73) hide show
  1. package/dist/components/account/ConfigurationsMyAccountModal.mjs +1 -1
  2. package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
  3. package/dist/components/account/ConfirmDeleteAccountModal.mjs +46 -7
  4. package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -1
  5. package/dist/components/account/DeleteAccountModal.mjs +2 -2
  6. package/dist/components/account/DeleteAccountModal.mjs.map +1 -1
  7. package/dist/index.mjs +8 -0
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/modules/accounts/actions/account-management.action.mjs +15 -14
  10. package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -1
  11. package/dist/modules/auth/utils/require-valid-session.mjs +17 -0
  12. package/dist/modules/auth/utils/require-valid-session.mjs.map +1 -0
  13. package/dist/modules/cards/actions/create-card.action.mjs +2 -2
  14. package/dist/modules/cards/actions/create-card.action.mjs.map +1 -1
  15. package/dist/modules/cards/actions/delete-card.action.mjs +2 -2
  16. package/dist/modules/cards/actions/delete-card.action.mjs.map +1 -1
  17. package/dist/modules/cards/actions/set-default-card.action.mjs +2 -2
  18. package/dist/modules/cards/actions/set-default-card.action.mjs.map +1 -1
  19. package/dist/modules/pages/actions/count-pages.action.mjs +12 -0
  20. package/dist/modules/pages/actions/count-pages.action.mjs.map +1 -0
  21. package/dist/modules/pages/constants/query-keys.constants.mjs +5 -0
  22. package/dist/modules/pages/constants/query-keys.constants.mjs.map +1 -0
  23. package/dist/modules/pages/hooks/count-pages.hook.mjs +23 -0
  24. package/dist/modules/pages/hooks/count-pages.hook.mjs.map +1 -0
  25. package/dist/modules/pages/services/pages.service.mjs +24 -0
  26. package/dist/modules/pages/services/pages.service.mjs.map +1 -0
  27. package/dist/modules/projects/actions/add-project-user.action.mjs +2 -2
  28. package/dist/modules/projects/actions/add-project-user.action.mjs.map +1 -1
  29. package/dist/modules/projects/actions/create-project.action.mjs +2 -2
  30. package/dist/modules/projects/actions/create-project.action.mjs.map +1 -1
  31. package/dist/modules/projects/actions/delete-project.action.mjs +2 -2
  32. package/dist/modules/projects/actions/delete-project.action.mjs.map +1 -1
  33. package/dist/modules/projects/actions/remove-project-user.action.mjs +2 -2
  34. package/dist/modules/projects/actions/remove-project-user.action.mjs.map +1 -1
  35. package/dist/modules/projects/actions/update-project.action.mjs +2 -2
  36. package/dist/modules/projects/actions/update-project.action.mjs.map +1 -1
  37. package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs +2 -2
  38. package/dist/modules/subscriptions/actions/update-subscription-plan.action.mjs.map +1 -1
  39. package/dist/modules/users/action/mark-all-messages-as-read.action.mjs +2 -2
  40. package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +1 -1
  41. package/dist/modules/users/action/mark-message-as-read.action.mjs +2 -2
  42. package/dist/modules/users/action/mark-message-as-read.action.mjs.map +1 -1
  43. package/dist/server.mjs +6 -0
  44. package/dist/server.mjs.map +1 -1
  45. package/dist/store/useAccountModals.mjs +2 -3
  46. package/dist/store/useAccountModals.mjs.map +1 -1
  47. package/dist/utils/safeMutationAction.mjs +13 -0
  48. package/dist/utils/safeMutationAction.mjs.map +1 -0
  49. package/package.json +1 -1
  50. package/src/components/account/ConfigurationsMyAccountModal.tsx +1 -0
  51. package/src/components/account/ConfirmDeleteAccountModal.tsx +47 -10
  52. package/src/components/account/DeleteAccountModal.tsx +2 -2
  53. package/src/index.ts +5 -0
  54. package/src/modules/accounts/actions/account-management.action.ts +15 -14
  55. package/src/modules/auth/utils/require-valid-session.ts +35 -0
  56. package/src/modules/cards/actions/create-card.action.ts +2 -2
  57. package/src/modules/cards/actions/delete-card.action.ts +2 -2
  58. package/src/modules/cards/actions/set-default-card.action.ts +2 -2
  59. package/src/modules/pages/actions/count-pages.action.ts +10 -0
  60. package/src/modules/pages/constants/query-keys.constants.ts +1 -0
  61. package/src/modules/pages/hooks/count-pages.hook.ts +22 -0
  62. package/src/modules/pages/services/pages.service.ts +27 -0
  63. package/src/modules/projects/actions/add-project-user.action.ts +2 -2
  64. package/src/modules/projects/actions/create-project.action.ts +2 -2
  65. package/src/modules/projects/actions/delete-project.action.ts +2 -2
  66. package/src/modules/projects/actions/remove-project-user.action.ts +2 -2
  67. package/src/modules/projects/actions/update-project.action.ts +2 -2
  68. package/src/modules/subscriptions/actions/update-subscription-plan.action.ts +2 -2
  69. package/src/modules/users/action/mark-all-messages-as-read.action.ts +2 -2
  70. package/src/modules/users/action/mark-message-as-read.action.ts +2 -2
  71. package/src/server.ts +3 -0
  72. package/src/store/useAccountModals.ts +6 -8
  73. package/src/utils/safeMutationAction.ts +30 -0
@@ -0,0 +1,12 @@
1
+ "use server";
2
+ import { safeServerAction } from "../../../utils/safeServerAction";
3
+ import { pagesService } from "../services/pages.service";
4
+ async function countPagesAction() {
5
+ return safeServerAction(async () => ({
6
+ total: await pagesService.countPages()
7
+ }));
8
+ }
9
+ export {
10
+ countPagesAction
11
+ };
12
+ //# sourceMappingURL=count-pages.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/pages/actions/count-pages.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { pagesService } from '../services/pages.service';\n\nexport async function countPagesAction() {\n return safeServerAction(async () => ({\n total: await pagesService.countPages(),\n }));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,mBAAmB;AACvC,SAAO,iBAAiB,aAAa;AAAA,IACnC,OAAO,MAAM,aAAa,WAAW;AAAA,EACvC,EAAE;AACJ;","names":[]}
@@ -0,0 +1,5 @@
1
+ const PAGES_QUERY_KEY = ["pages"];
2
+ export {
3
+ PAGES_QUERY_KEY
4
+ };
5
+ //# sourceMappingURL=query-keys.constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/pages/constants/query-keys.constants.ts"],"sourcesContent":["export const PAGES_QUERY_KEY = ['pages'] as const;\n"],"mappings":"AAAO,MAAM,kBAAkB,CAAC,OAAO;","names":[]}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { countPagesAction } from "../actions/count-pages.action";
4
+ import { PAGES_QUERY_KEY } from "../constants/query-keys.constants";
5
+ import { withAction } from "../../../utils/withAction";
6
+ import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
7
+ const COUNT_PAGES_QUERY_KEY = [...PAGES_QUERY_KEY, "count"];
8
+ function useCountPages() {
9
+ const queryKey = useAuthQueryKey([...COUNT_PAGES_QUERY_KEY]);
10
+ return useQuery({
11
+ queryKey,
12
+ queryFn: async () => {
13
+ const result = await withAction(countPagesAction)();
14
+ return result.total;
15
+ },
16
+ staleTime: 3e4
17
+ });
18
+ }
19
+ export {
20
+ COUNT_PAGES_QUERY_KEY,
21
+ useCountPages
22
+ };
23
+ //# sourceMappingURL=count-pages.hook.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/pages/hooks/count-pages.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { countPagesAction } from '../actions/count-pages.action';\nimport { PAGES_QUERY_KEY } from '../constants/query-keys.constants';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\n\nexport const COUNT_PAGES_QUERY_KEY = [...PAGES_QUERY_KEY, 'count'] as const;\n\nexport function useCountPages() {\n const queryKey = useAuthQueryKey([...COUNT_PAGES_QUERY_KEY]);\n\n return useQuery({\n queryKey,\n queryFn: async () => {\n const result = await withAction(countPagesAction)();\n return result.total;\n },\n staleTime: 30_000,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAEzB,MAAM,wBAAwB,CAAC,GAAG,iBAAiB,OAAO;AAE1D,SAAS,gBAAgB;AAC9B,QAAM,WAAW,gBAAgB,CAAC,GAAG,qBAAqB,CAAC;AAE3D,SAAO,SAAS;AAAA,IACd;AAAA,IACA,SAAS,YAAY;AACnB,YAAM,SAAS,MAAM,WAAW,gBAAgB,EAAE;AAClD,aAAO,OAAO;AAAA,IAChB;AAAA,IACA,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
@@ -0,0 +1,24 @@
1
+ import "server-only";
2
+ import { api } from "../../../infra/api/client";
3
+ import { ApiError } from "../../../infra/api/types";
4
+ import { getUserContext } from "../../auth/utils/get-user-context";
5
+ class PagesService {
6
+ async countPages() {
7
+ const { id_account } = await getUserContext();
8
+ const url = `/account/${id_account}/pages?limit=1`;
9
+ const response = await api.pages.get(url);
10
+ if (response.status === 0) {
11
+ throw new ApiError(
12
+ response.message || "Erro ao contar p\xE1ginas",
13
+ "COUNT_PAGES_FAILED",
14
+ 400
15
+ );
16
+ }
17
+ return response.total;
18
+ }
19
+ }
20
+ const pagesService = new PagesService();
21
+ export {
22
+ pagesService
23
+ };
24
+ //# sourceMappingURL=pages.service.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/modules/pages/services/pages.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { ApiError, ApiPaginatedActionResult } from '../../../infra/api/types';\nimport { getUserContext } from '../../auth/utils/get-user-context';\n\nclass PagesService {\n async countPages(): Promise<number> {\n const { id_account } = await getUserContext();\n\n const url = `/account/${id_account}/pages?limit=1`;\n\n const response = await api.pages.get<ApiPaginatedActionResult<unknown>>(url);\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao contar páginas',\n 'COUNT_PAGES_FAILED',\n 400,\n );\n }\n\n return response.total;\n }\n}\n\nexport const pagesService = new PagesService();\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAA0C;AACnD,SAAS,sBAAsB;AAE/B,MAAM,aAAa;AAAA,EACjB,MAAM,aAA8B;AAClC,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,MAAM,YAAY,UAAU;AAElC,UAAM,WAAW,MAAM,IAAI,MAAM,IAAuC,GAAG;AAE3E,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AACF;AAEO,MAAM,eAAe,IAAI,aAAa;","names":[]}
@@ -1,8 +1,8 @@
1
1
  "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
2
+ import { safeMutationAction } from "../../../utils/safeMutationAction";
3
3
  import { projectUsersService } from "../services/project-users.service";
4
4
  async function addProjectUserAction(params) {
5
- return safeServerAction(() => projectUsersService.addToProject(params));
5
+ return safeMutationAction(() => projectUsersService.addToProject(params));
6
6
  }
7
7
  export {
8
8
  addProjectUserAction
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/projects/actions/add-project-user.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { AddRemoveProjectUsersParams } from '../types';\n\nexport async function addProjectUserAction(params: AddRemoveProjectUsersParams) {\n return safeServerAction(() => projectUsersService.addToProject(params));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AAGpC,eAAsB,qBAAqB,QAAqC;AAC9E,SAAO,iBAAiB,MAAM,oBAAoB,aAAa,MAAM,CAAC;AACxE;","names":[]}
1
+ {"version":3,"sources":["../../../../src/modules/projects/actions/add-project-user.action.ts"],"sourcesContent":["'use server';\n\nimport { safeMutationAction } from '../../../utils/safeMutationAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { AddRemoveProjectUsersParams } from '../types';\n\nexport async function addProjectUserAction(params: AddRemoveProjectUsersParams) {\n return safeMutationAction(() => projectUsersService.addToProject(params));\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AAGpC,eAAsB,qBAAqB,QAAqC;AAC9E,SAAO,mBAAmB,MAAM,oBAAoB,aAAa,MAAM,CAAC;AAC1E;","names":[]}
@@ -1,8 +1,8 @@
1
1
  "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
2
+ import { safeMutationAction } from "../../../utils/safeMutationAction";
3
3
  import { projectsService } from "../services/projects.service";
4
4
  async function createProjectAction(data) {
5
- return safeServerAction(() => projectsService.create(data));
5
+ return safeMutationAction(() => projectsService.create(data));
6
6
  }
7
7
  export {
8
8
  createProjectAction
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/projects/actions/create-project.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectsService } from '../services/projects.service';\nimport type { CreateProjectRequest } from '../types';\n\nexport async function createProjectAction(data: CreateProjectRequest) {\n return safeServerAction(() => projectsService.create(data));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAGhC,eAAsB,oBAAoB,MAA4B;AACpE,SAAO,iBAAiB,MAAM,gBAAgB,OAAO,IAAI,CAAC;AAC5D;","names":[]}
1
+ {"version":3,"sources":["../../../../src/modules/projects/actions/create-project.action.ts"],"sourcesContent":["'use server';\n\nimport { safeMutationAction } from '../../../utils/safeMutationAction';\nimport { projectsService } from '../services/projects.service';\nimport type { CreateProjectRequest } from '../types';\n\nexport async function createProjectAction(data: CreateProjectRequest) {\n return safeMutationAction(() => projectsService.create(data));\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAGhC,eAAsB,oBAAoB,MAA4B;AACpE,SAAO,mBAAmB,MAAM,gBAAgB,OAAO,IAAI,CAAC;AAC9D;","names":[]}
@@ -1,8 +1,8 @@
1
1
  "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
2
+ import { safeMutationAction } from "../../../utils/safeMutationAction";
3
3
  import { projectsService } from "../services/projects.service";
4
4
  async function deleteProjectAction(projectId, moveToProjectId) {
5
- return safeServerAction(() => projectsService.delete(projectId, moveToProjectId));
5
+ return safeMutationAction(() => projectsService.delete(projectId, moveToProjectId));
6
6
  }
7
7
  export {
8
8
  deleteProjectAction
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/projects/actions/delete-project.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectsService } from '../services/projects.service';\n\nexport async function deleteProjectAction(projectId: number, moveToProjectId: number) {\n return safeServerAction(() => projectsService.delete(projectId, moveToProjectId));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEhC,eAAsB,oBAAoB,WAAmB,iBAAyB;AACpF,SAAO,iBAAiB,MAAM,gBAAgB,OAAO,WAAW,eAAe,CAAC;AAClF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/modules/projects/actions/delete-project.action.ts"],"sourcesContent":["'use server';\n\nimport { safeMutationAction } from '../../../utils/safeMutationAction';\nimport { projectsService } from '../services/projects.service';\n\nexport async function deleteProjectAction(projectId: number, moveToProjectId: number) {\n return safeMutationAction(() => projectsService.delete(projectId, moveToProjectId));\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAEhC,eAAsB,oBAAoB,WAAmB,iBAAyB;AACpF,SAAO,mBAAmB,MAAM,gBAAgB,OAAO,WAAW,eAAe,CAAC;AACpF;","names":[]}
@@ -1,8 +1,8 @@
1
1
  "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
2
+ import { safeMutationAction } from "../../../utils/safeMutationAction";
3
3
  import { projectUsersService } from "../services/project-users.service";
4
4
  async function removeProjectUserAction(params) {
5
- return safeServerAction(() => projectUsersService.removeFromProject(params));
5
+ return safeMutationAction(() => projectUsersService.removeFromProject(params));
6
6
  }
7
7
  export {
8
8
  removeProjectUserAction
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/projects/actions/remove-project-user.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { AddRemoveProjectUsersParams } from '../types';\n\nexport async function removeProjectUserAction(params: AddRemoveProjectUsersParams) {\n return safeServerAction(() => projectUsersService.removeFromProject(params));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AAGpC,eAAsB,wBAAwB,QAAqC;AACjF,SAAO,iBAAiB,MAAM,oBAAoB,kBAAkB,MAAM,CAAC;AAC7E;","names":[]}
1
+ {"version":3,"sources":["../../../../src/modules/projects/actions/remove-project-user.action.ts"],"sourcesContent":["'use server';\n\nimport { safeMutationAction } from '../../../utils/safeMutationAction';\nimport { projectUsersService } from '../services/project-users.service';\nimport type { AddRemoveProjectUsersParams } from '../types';\n\nexport async function removeProjectUserAction(params: AddRemoveProjectUsersParams) {\n return safeMutationAction(() => projectUsersService.removeFromProject(params));\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AAGpC,eAAsB,wBAAwB,QAAqC;AACjF,SAAO,mBAAmB,MAAM,oBAAoB,kBAAkB,MAAM,CAAC;AAC/E;","names":[]}
@@ -1,8 +1,8 @@
1
1
  "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
2
+ import { safeMutationAction } from "../../../utils/safeMutationAction";
3
3
  import { projectsService } from "../services/projects.service";
4
4
  async function updateProjectAction(projectId, data) {
5
- return safeServerAction(() => projectsService.update(projectId, data));
5
+ return safeMutationAction(() => projectsService.update(projectId, data));
6
6
  }
7
7
  export {
8
8
  updateProjectAction
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/projects/actions/update-project.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectsService } from '../services/projects.service';\nimport type { UpdateProjectRequest } from '../types';\n\nexport async function updateProjectAction(projectId: number, data: UpdateProjectRequest) {\n return safeServerAction(() => projectsService.update(projectId, data));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAGhC,eAAsB,oBAAoB,WAAmB,MAA4B;AACvF,SAAO,iBAAiB,MAAM,gBAAgB,OAAO,WAAW,IAAI,CAAC;AACvE;","names":[]}
1
+ {"version":3,"sources":["../../../../src/modules/projects/actions/update-project.action.ts"],"sourcesContent":["'use server';\n\nimport { safeMutationAction } from '../../../utils/safeMutationAction';\nimport { projectsService } from '../services/projects.service';\nimport type { UpdateProjectRequest } from '../types';\n\nexport async function updateProjectAction(projectId: number, data: UpdateProjectRequest) {\n return safeMutationAction(() => projectsService.update(projectId, data));\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAGhC,eAAsB,oBAAoB,WAAmB,MAA4B;AACvF,SAAO,mBAAmB,MAAM,gBAAgB,OAAO,WAAW,IAAI,CAAC;AACzE;","names":[]}
@@ -1,8 +1,8 @@
1
1
  "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
2
+ import { safeMutationAction } from "../../../utils/safeMutationAction";
3
3
  import { subscriptionsService } from "../services/subscriptions.service";
4
4
  async function updateSubscriptionPlanAction(subscriptionId, data) {
5
- return safeServerAction(async () => {
5
+ return safeMutationAction(async () => {
6
6
  return subscriptionsService.updateSubscriptionPlan(subscriptionId, data);
7
7
  });
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/subscriptions/actions/update-subscription-plan.action.ts"],"sourcesContent":["\"use server\";\n\nimport { safeServerAction } from \"../../../utils/safeServerAction\";\nimport type { UpdateSubscriptionPlanRequest } from \"../types/calculate-subscription.type\";\nimport { subscriptionsService } from \"../services/subscriptions.service\";\n\nexport async function updateSubscriptionPlanAction(\n subscriptionId: number | string,\n data: UpdateSubscriptionPlanRequest,\n) {\n return safeServerAction(async () => {\n return subscriptionsService.updateSubscriptionPlan(subscriptionId, data);\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AAEjC,SAAS,4BAA4B;AAErC,eAAsB,6BACpB,gBACA,MACA;AACA,SAAO,iBAAiB,YAAY;AAClC,WAAO,qBAAqB,uBAAuB,gBAAgB,IAAI;AAAA,EACzE,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../../../src/modules/subscriptions/actions/update-subscription-plan.action.ts"],"sourcesContent":["\"use server\";\n\nimport { safeMutationAction } from \"../../../utils/safeMutationAction\";\nimport type { UpdateSubscriptionPlanRequest } from \"../types/calculate-subscription.type\";\nimport { subscriptionsService } from \"../services/subscriptions.service\";\n\nexport async function updateSubscriptionPlanAction(\n subscriptionId: number | string,\n data: UpdateSubscriptionPlanRequest,\n) {\n return safeMutationAction(async () => {\n return subscriptionsService.updateSubscriptionPlan(subscriptionId, data);\n });\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AAEnC,SAAS,4BAA4B;AAErC,eAAsB,6BACpB,gBACA,MACA;AACA,SAAO,mBAAmB,YAAY;AACpC,WAAO,qBAAqB,uBAAuB,gBAAgB,IAAI;AAAA,EACzE,CAAC;AACH;","names":[]}
@@ -1,8 +1,8 @@
1
1
  "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
2
+ import { safeMutationAction } from "../../../utils/safeMutationAction";
3
3
  import { messagesService } from "../services/messages.service";
4
4
  async function markAllMessagesAsReadAction() {
5
- return safeServerAction(() => messagesService.markAllAsRead());
5
+ return safeMutationAction(() => messagesService.markAllAsRead());
6
6
  }
7
7
  export {
8
8
  markAllMessagesAsReadAction
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/users/action/mark-all-messages-as-read.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { messagesService } from '../services/messages.service';\n\nexport async function markAllMessagesAsReadAction() {\n return safeServerAction(() => messagesService.markAllAsRead());\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEhC,eAAsB,8BAA8B;AAClD,SAAO,iBAAiB,MAAM,gBAAgB,cAAc,CAAC;AAC/D;","names":[]}
1
+ {"version":3,"sources":["../../../../src/modules/users/action/mark-all-messages-as-read.action.ts"],"sourcesContent":["'use server';\n\nimport { safeMutationAction } from '../../../utils/safeMutationAction';\nimport { messagesService } from '../services/messages.service';\n\nexport async function markAllMessagesAsReadAction() {\n return safeMutationAction(() => messagesService.markAllAsRead());\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAEhC,eAAsB,8BAA8B;AAClD,SAAO,mBAAmB,MAAM,gBAAgB,cAAc,CAAC;AACjE;","names":[]}
@@ -1,8 +1,8 @@
1
1
  "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
2
+ import { safeMutationAction } from "../../../utils/safeMutationAction";
3
3
  import { messagesService } from "../services/messages.service";
4
4
  async function markMessageAsReadAction(messageId) {
5
- return safeServerAction(() => messagesService.markAsRead(messageId));
5
+ return safeMutationAction(() => messagesService.markAsRead(messageId));
6
6
  }
7
7
  export {
8
8
  markMessageAsReadAction
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/users/action/mark-message-as-read.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { messagesService } from '../services/messages.service';\n\nexport async function markMessageAsReadAction(messageId: string) {\n return safeServerAction(() => messagesService.markAsRead(messageId));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEhC,eAAsB,wBAAwB,WAAmB;AAC/D,SAAO,iBAAiB,MAAM,gBAAgB,WAAW,SAAS,CAAC;AACrE;","names":[]}
1
+ {"version":3,"sources":["../../../../src/modules/users/action/mark-message-as-read.action.ts"],"sourcesContent":["'use server';\n\nimport { safeMutationAction } from '../../../utils/safeMutationAction';\nimport { messagesService } from '../services/messages.service';\n\nexport async function markMessageAsReadAction(messageId: string) {\n return safeMutationAction(() => messagesService.markAsRead(messageId));\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAEhC,eAAsB,wBAAwB,WAAmB;AAC/D,SAAO,mBAAmB,MAAM,gBAAgB,WAAW,SAAS,CAAC;AACvE;","names":[]}
package/dist/server.mjs CHANGED
@@ -26,6 +26,7 @@ import { createCardAction } from "./modules/cards/actions/create-card.action";
26
26
  import { resolvePlanExtrasPrices } from "./modules/subscriptions/utils/resolve-plan-extras-prices";
27
27
  import { hasSubscriptionExpired } from "./modules/subscriptions/utils/has-subscription-expired";
28
28
  import { listIaCreditsAction } from "./modules/ia-credits/actions/list-ia-credits.action";
29
+ import { countPagesAction } from "./modules/pages/actions/count-pages.action";
29
30
  import { projectsService } from "./modules/projects/services/projects.service";
30
31
  import { listProjectsAction } from "./modules/projects/actions/list-projects.action";
31
32
  import { findProjectAction } from "./modules/projects/actions/find-project.action";
@@ -58,8 +59,10 @@ import {
58
59
  } from "./modules/accounts/actions/account-management.action";
59
60
  import { getClientInfoFromRequest } from "./infra/utils/client-info";
60
61
  import { getUserContext } from "./modules/auth/utils/get-user-context";
62
+ import { requireValidSession } from "./modules/auth/utils/require-valid-session";
61
63
  import { buildWlOverride, buildWlOverrideFromJwt } from "./modules/auth/utils/build-wl-override";
62
64
  import { safeServerAction } from "./utils/safeServerAction";
65
+ import { safeMutationAction } from "./utils/safeMutationAction";
63
66
  import { processImageAction } from "./modules/images/actions/process-image.action";
64
67
  import { processImage } from "./modules/images/services/image-processing.service";
65
68
  export {
@@ -81,6 +84,7 @@ export {
81
84
  confirmEmailChangeAction,
82
85
  confirmPhoneChangeAction,
83
86
  confirmTwoFactorAction,
87
+ countPagesAction,
84
88
  createAccountUserAction,
85
89
  createCardAction,
86
90
  createProjectAction,
@@ -115,8 +119,10 @@ export {
115
119
  removeProjectUserAction,
116
120
  requestEmailChangeAction,
117
121
  requestPhoneChangeAction,
122
+ requireValidSession,
118
123
  resolvePlanExtrasPrices,
119
124
  revalidateWhitelabelAction,
125
+ safeMutationAction,
120
126
  safeServerAction,
121
127
  subscriptionsService,
122
128
  twoFactorService,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"sourcesContent":["import 'server-only';\r\n\r\n// API Client\r\nexport { ApiClient, api, apiClient } from './infra/api/client';\r\n\r\n// Services\r\nexport { authService } from './modules/auth/services/auth.service';\r\nexport { whitelabelService } from './modules/whitelabel/services/whitelabel.service';\r\nexport { revalidateWhitelabelAction } from './modules/whitelabel/actions/revalidate-whitelabel.action';\r\nexport { assertManagementPermission } from './modules/auth/utils/assert-management-permission';\r\nexport { assertManagementSubscription } from './modules/auth/utils/assert-management-subscription';\r\nexport { assertSubscriptionAddon } from './modules/auth/utils/assert-subscription-addon';\r\nexport { assertPaidSubscription } from './modules/auth/utils/assert-paid-subscription';\r\nexport { subscriptionsService } from './modules/subscriptions/services/subscriptions.service';\r\nexport { plansService } from './modules/plans/services/plans.service';\r\nexport { cardsService } from './modules/cards/services/cards.service';\r\nexport { iaCreditsService } from './modules/ia-credits/services/ia-credits.service';\r\n\r\n// Actions\r\nexport { findWhitelabel } from './modules/whitelabel/actions/find-whitelabel.action';\r\nexport { validateSessionAction } from './modules/auth/actions/validate-session.action';\r\nexport { findUserById } from './modules/users/action/find-user-by-id.action';\r\nexport { findCurrentAccount } from './modules/accounts/actions/find-current-account.action';\r\nexport { getAccountTokenAction } from './modules/accounts/actions/get-account-token.action';\r\nexport { listSubscriptionsAction } from './modules/subscriptions/actions/list-subscriptions.action';\r\nexport { findPlanByIdAction } from './modules/plans/actions/find-plan-by-id.action';\r\nexport { listPlansAction } from './modules/plans/actions/list-plans.action';\r\nexport { calculateSubscriptionAction } from './modules/subscriptions/actions/calculate-subscription.action';\r\nexport { updateSubscriptionPlanAction } from './modules/subscriptions/actions/update-subscription-plan.action';\r\nexport { listCardsAction } from './modules/cards/actions/list-cards.action';\r\nexport { createCardAction } from './modules/cards/actions/create-card.action';\r\nexport { resolvePlanExtrasPrices } from './modules/subscriptions/utils/resolve-plan-extras-prices';\r\nexport { hasSubscriptionExpired } from './modules/subscriptions/utils/has-subscription-expired';\r\nexport { listIaCreditsAction } from './modules/ia-credits/actions/list-ia-credits.action';\r\n\r\n// Project Services & Actions (server-only)\r\nexport { projectsService } from './modules/projects/services/projects.service';\r\nexport { listProjectsAction } from './modules/projects/actions/list-projects.action';\r\nexport { findProjectAction } from './modules/projects/actions/find-project.action';\r\nexport { createProjectAction } from './modules/projects/actions/create-project.action';\r\nexport { updateProjectAction } from './modules/projects/actions/update-project.action';\r\nexport { deleteProjectAction } from './modules/projects/actions/delete-project.action';\r\n\r\n// Project Users Services & Actions (server-only)\r\nexport { projectUsersService } from './modules/projects/services/project-users.service';\r\nexport { listProjectUsersAction } from './modules/projects/actions/list-project-users.action';\r\nexport { listAvailableUsersAction } from './modules/projects/actions/list-available-users.action';\r\nexport { addProjectUserAction } from './modules/projects/actions/add-project-user.action';\r\nexport { removeProjectUserAction } from './modules/projects/actions/remove-project-user.action';\r\n\r\n// Account Services & Actions (server-only)\r\nexport { accountService } from './modules/accounts/services/account.service';\r\nexport { twoFactorService } from './modules/accounts/services/two-factor.service';\r\nexport {\r\n listAccountUsersAction,\r\n updateUserAction,\r\n updateAccountAction,\r\n updateAccountUserByIdAction,\r\n deleteAccountUserAction,\r\n deleteAccountAction,\r\n createAccountUserAction,\r\n changePasswordAction,\r\n requestEmailChangeAction,\r\n confirmEmailChangeAction,\r\n requestPhoneChangeAction,\r\n confirmPhoneChangeAction,\r\n generateTwoFactorAction,\r\n confirmTwoFactorAction,\r\n disableTwoFactorAction,\r\n} from './modules/accounts/actions/account-management.action';\r\n\r\n// Server Utils\r\nexport { getClientInfoFromRequest } from './infra/utils/client-info';\r\nexport { getUserContext } from './modules/auth/utils/get-user-context';\r\nexport { buildWlOverride, buildWlOverrideFromJwt } from './modules/auth/utils/build-wl-override';\r\nexport { safeServerAction } from './utils/safeServerAction';\r\n\r\n// Image Processing (server-side)\r\nexport { processImageAction } from './modules/images/actions/process-image.action';\r\nexport { processImage } from './modules/images/services/image-processing.service';\r\nexport type {\r\n ProcessImageInput,\r\n ProcessImageOutput,\r\n ProcessImageActionInput,\r\n ProcessImageActionOutput,\r\n} from './modules/images/types/image.type';\r\n"],"mappings":"AAAA,OAAO;AAGP,SAAS,WAAW,KAAK,iBAAiB;AAG1C,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,kCAAkC;AAC3C,SAAS,kCAAkC;AAC3C,SAAS,oCAAoC;AAC7C,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAGjC,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AACxC,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAChC,SAAS,mCAAmC;AAC5C,SAAS,oCAAoC;AAC7C,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AAGpC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAGpC,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAS,gCAAgC;AACzC,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AAGxC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB,8BAA8B;AACxD,SAAS,wBAAwB;AAGjC,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;","names":[]}
1
+ {"version":3,"sources":["../src/server.ts"],"sourcesContent":["import 'server-only';\r\n\r\n// API Client\r\nexport { ApiClient, api, apiClient } from './infra/api/client';\r\n\r\n// Services\r\nexport { authService } from './modules/auth/services/auth.service';\r\nexport { whitelabelService } from './modules/whitelabel/services/whitelabel.service';\r\nexport { revalidateWhitelabelAction } from './modules/whitelabel/actions/revalidate-whitelabel.action';\r\nexport { assertManagementPermission } from './modules/auth/utils/assert-management-permission';\r\nexport { assertManagementSubscription } from './modules/auth/utils/assert-management-subscription';\r\nexport { assertSubscriptionAddon } from './modules/auth/utils/assert-subscription-addon';\r\nexport { assertPaidSubscription } from './modules/auth/utils/assert-paid-subscription';\r\nexport { subscriptionsService } from './modules/subscriptions/services/subscriptions.service';\r\nexport { plansService } from './modules/plans/services/plans.service';\r\nexport { cardsService } from './modules/cards/services/cards.service';\r\nexport { iaCreditsService } from './modules/ia-credits/services/ia-credits.service';\r\n\r\n// Actions\r\nexport { findWhitelabel } from './modules/whitelabel/actions/find-whitelabel.action';\r\nexport { validateSessionAction } from './modules/auth/actions/validate-session.action';\r\nexport { findUserById } from './modules/users/action/find-user-by-id.action';\r\nexport { findCurrentAccount } from './modules/accounts/actions/find-current-account.action';\r\nexport { getAccountTokenAction } from './modules/accounts/actions/get-account-token.action';\r\nexport { listSubscriptionsAction } from './modules/subscriptions/actions/list-subscriptions.action';\r\nexport { findPlanByIdAction } from './modules/plans/actions/find-plan-by-id.action';\r\nexport { listPlansAction } from './modules/plans/actions/list-plans.action';\r\nexport { calculateSubscriptionAction } from './modules/subscriptions/actions/calculate-subscription.action';\r\nexport { updateSubscriptionPlanAction } from './modules/subscriptions/actions/update-subscription-plan.action';\r\nexport { listCardsAction } from './modules/cards/actions/list-cards.action';\r\nexport { createCardAction } from './modules/cards/actions/create-card.action';\r\nexport { resolvePlanExtrasPrices } from './modules/subscriptions/utils/resolve-plan-extras-prices';\r\nexport { hasSubscriptionExpired } from './modules/subscriptions/utils/has-subscription-expired';\r\nexport { listIaCreditsAction } from './modules/ia-credits/actions/list-ia-credits.action';\r\nexport { countPagesAction } from './modules/pages/actions/count-pages.action';\r\n\r\n// Project Services & Actions (server-only)\r\nexport { projectsService } from './modules/projects/services/projects.service';\r\nexport { listProjectsAction } from './modules/projects/actions/list-projects.action';\r\nexport { findProjectAction } from './modules/projects/actions/find-project.action';\r\nexport { createProjectAction } from './modules/projects/actions/create-project.action';\r\nexport { updateProjectAction } from './modules/projects/actions/update-project.action';\r\nexport { deleteProjectAction } from './modules/projects/actions/delete-project.action';\r\n\r\n// Project Users Services & Actions (server-only)\r\nexport { projectUsersService } from './modules/projects/services/project-users.service';\r\nexport { listProjectUsersAction } from './modules/projects/actions/list-project-users.action';\r\nexport { listAvailableUsersAction } from './modules/projects/actions/list-available-users.action';\r\nexport { addProjectUserAction } from './modules/projects/actions/add-project-user.action';\r\nexport { removeProjectUserAction } from './modules/projects/actions/remove-project-user.action';\r\n\r\n// Account Services & Actions (server-only)\r\nexport { accountService } from './modules/accounts/services/account.service';\r\nexport { twoFactorService } from './modules/accounts/services/two-factor.service';\r\nexport {\r\n listAccountUsersAction,\r\n updateUserAction,\r\n updateAccountAction,\r\n updateAccountUserByIdAction,\r\n deleteAccountUserAction,\r\n deleteAccountAction,\r\n createAccountUserAction,\r\n changePasswordAction,\r\n requestEmailChangeAction,\r\n confirmEmailChangeAction,\r\n requestPhoneChangeAction,\r\n confirmPhoneChangeAction,\r\n generateTwoFactorAction,\r\n confirmTwoFactorAction,\r\n disableTwoFactorAction,\r\n} from './modules/accounts/actions/account-management.action';\r\n\r\n// Server Utils\r\nexport { getClientInfoFromRequest } from './infra/utils/client-info';\r\nexport { getUserContext } from './modules/auth/utils/get-user-context';\r\nexport { requireValidSession } from './modules/auth/utils/require-valid-session';\r\nexport { buildWlOverride, buildWlOverrideFromJwt } from './modules/auth/utils/build-wl-override';\r\nexport { safeServerAction } from './utils/safeServerAction';\r\nexport { safeMutationAction } from './utils/safeMutationAction';\r\n\r\n// Image Processing (server-side)\r\nexport { processImageAction } from './modules/images/actions/process-image.action';\r\nexport { processImage } from './modules/images/services/image-processing.service';\r\nexport type {\r\n ProcessImageInput,\r\n ProcessImageOutput,\r\n ProcessImageActionInput,\r\n ProcessImageActionOutput,\r\n} from './modules/images/types/image.type';\r\n"],"mappings":"AAAA,OAAO;AAGP,SAAS,WAAW,KAAK,iBAAiB;AAG1C,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,kCAAkC;AAC3C,SAAS,kCAAkC;AAC3C,SAAS,oCAAoC;AAC7C,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAGjC,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,+BAA+B;AACxC,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAChC,SAAS,mCAAmC;AAC5C,SAAS,oCAAoC;AAC7C,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AAGjC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAGpC,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAS,gCAAgC;AACzC,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AAGxC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,gCAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AACpC,SAAS,iBAAiB,8BAA8B;AACxD,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AAGnC,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;","names":[]}
@@ -4,12 +4,11 @@ const useAccountModals = create((set) => ({
4
4
  activeModal: null,
5
5
  config: {},
6
6
  initialSection: void 0,
7
- pagesCount: 0,
8
7
  updateConfig: (config) => set({ config }),
9
8
  openConfigurations: (initialSection) => set({ activeModal: "configurations", initialSection }),
10
- openDeleteAccount: (pagesCount = 0) => set({ activeModal: "deleteAccount", pagesCount }),
9
+ openDeleteAccount: () => set({ activeModal: "deleteAccount" }),
11
10
  openIsntPossibleDelete: () => set({ activeModal: "isntPossibleDelete" }),
12
- openConfirmDelete: (pagesCount = 0) => set({ activeModal: "confirmDelete", pagesCount }),
11
+ openConfirmDelete: () => set({ activeModal: "confirmDelete" }),
13
12
  close: () => set({ activeModal: null, initialSection: void 0 })
14
13
  }));
15
14
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/store/useAccountModals.ts"],"sourcesContent":["'use client';\n\nimport { create } from 'zustand';\nimport type { AccountSectionType } from '../enums/AccountSectionType';\n\ntype AccountModalType =\n | 'configurations'\n | 'deleteAccount'\n | 'isntPossibleDelete'\n | 'confirmDelete';\n\nexport interface AccountModalsConfig {\n onGoToSubscription?: () => void;\n}\n\ninterface AccountModalsState {\n activeModal: AccountModalType | null;\n config: AccountModalsConfig;\n initialSection?: AccountSectionType;\n pagesCount: number;\n\n /** Called by <AccountModals> to keep app-level config in sync */\n updateConfig: (config: AccountModalsConfig) => void;\n\n openConfigurations: (initialSection?: AccountSectionType) => void;\n openDeleteAccount: (pagesCount?: number) => void;\n openIsntPossibleDelete: () => void;\n openConfirmDelete: (pagesCount?: number) => void;\n close: () => void;\n}\n\nexport const useAccountModals = create<AccountModalsState>((set) => ({\n activeModal: null,\n config: {},\n initialSection: undefined,\n pagesCount: 0,\n\n updateConfig: (config) => set({ config }),\n\n openConfigurations: (initialSection) =>\n set({ activeModal: 'configurations', initialSection }),\n\n openDeleteAccount: (pagesCount = 0) =>\n set({ activeModal: 'deleteAccount', pagesCount }),\n\n openIsntPossibleDelete: () =>\n set({ activeModal: 'isntPossibleDelete' }),\n\n openConfirmDelete: (pagesCount = 0) =>\n set({ activeModal: 'confirmDelete', pagesCount }),\n\n close: () =>\n set({ activeModal: null, initialSection: undefined }),\n}));\n"],"mappings":";AAEA,SAAS,cAAc;AA6BhB,MAAM,mBAAmB,OAA2B,CAAC,SAAS;AAAA,EACnE,aAAa;AAAA,EACb,QAAQ,CAAC;AAAA,EACT,gBAAgB;AAAA,EAChB,YAAY;AAAA,EAEZ,cAAc,CAAC,WAAW,IAAI,EAAE,OAAO,CAAC;AAAA,EAExC,oBAAoB,CAAC,mBACnB,IAAI,EAAE,aAAa,kBAAkB,eAAe,CAAC;AAAA,EAEvD,mBAAmB,CAAC,aAAa,MAC/B,IAAI,EAAE,aAAa,iBAAiB,WAAW,CAAC;AAAA,EAElD,wBAAwB,MACtB,IAAI,EAAE,aAAa,qBAAqB,CAAC;AAAA,EAE3C,mBAAmB,CAAC,aAAa,MAC/B,IAAI,EAAE,aAAa,iBAAiB,WAAW,CAAC;AAAA,EAElD,OAAO,MACL,IAAI,EAAE,aAAa,MAAM,gBAAgB,OAAU,CAAC;AACxD,EAAE;","names":[]}
1
+ {"version":3,"sources":["../../src/store/useAccountModals.ts"],"sourcesContent":["'use client';\n\nimport { create } from 'zustand';\nimport type { AccountSectionType } from '../enums/AccountSectionType';\n\ntype AccountModalType =\n | 'configurations'\n | 'deleteAccount'\n | 'isntPossibleDelete'\n | 'confirmDelete';\n\nexport interface AccountModalsConfig {\n onGoToSubscription?: () => void;\n}\n\ninterface AccountModalsState {\n activeModal: AccountModalType | null;\n config: AccountModalsConfig;\n initialSection?: AccountSectionType;\n\n /** Called by <AccountModals> to keep app-level config in sync */\n updateConfig: (config: AccountModalsConfig) => void;\n\n openConfigurations: (initialSection?: AccountSectionType) => void;\n openDeleteAccount: () => void;\n openIsntPossibleDelete: () => void;\n openConfirmDelete: () => void;\n close: () => void;\n}\n\nexport const useAccountModals = create<AccountModalsState>((set) => ({\n activeModal: null,\n config: {},\n initialSection: undefined,\n\n updateConfig: (config) => set({ config }),\n\n openConfigurations: (initialSection) =>\n set({ activeModal: 'configurations', initialSection }),\n\n openDeleteAccount: () =>\n set({ activeModal: 'deleteAccount' }),\n\n openIsntPossibleDelete: () =>\n set({ activeModal: 'isntPossibleDelete' }),\n\n openConfirmDelete: () =>\n set({ activeModal: 'confirmDelete' }),\n\n close: () =>\n set({ activeModal: null, initialSection: undefined }),\n}));\n"],"mappings":";AAEA,SAAS,cAAc;AA4BhB,MAAM,mBAAmB,OAA2B,CAAC,SAAS;AAAA,EACnE,aAAa;AAAA,EACb,QAAQ,CAAC;AAAA,EACT,gBAAgB;AAAA,EAEhB,cAAc,CAAC,WAAW,IAAI,EAAE,OAAO,CAAC;AAAA,EAExC,oBAAoB,CAAC,mBACnB,IAAI,EAAE,aAAa,kBAAkB,eAAe,CAAC;AAAA,EAEvD,mBAAmB,MACjB,IAAI,EAAE,aAAa,gBAAgB,CAAC;AAAA,EAEtC,wBAAwB,MACtB,IAAI,EAAE,aAAa,qBAAqB,CAAC;AAAA,EAE3C,mBAAmB,MACjB,IAAI,EAAE,aAAa,gBAAgB,CAAC;AAAA,EAEtC,OAAO,MACL,IAAI,EAAE,aAAa,MAAM,gBAAgB,OAAU,CAAC;AACxD,EAAE;","names":[]}
@@ -0,0 +1,13 @@
1
+ import "server-only";
2
+ import { requireValidSession } from "../modules/auth/utils/require-valid-session";
3
+ import { safeServerAction } from "./safeServerAction";
4
+ async function safeMutationAction(fn) {
5
+ return safeServerAction(async () => {
6
+ await requireValidSession();
7
+ return fn();
8
+ });
9
+ }
10
+ export {
11
+ safeMutationAction
12
+ };
13
+ //# sourceMappingURL=safeMutationAction.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/safeMutationAction.ts"],"sourcesContent":["import 'server-only';\n\nimport type { ActionResult } from '../infra/api/types';\nimport { requireValidSession } from '../modules/auth/utils/require-valid-session';\nimport { safeServerAction } from './safeServerAction';\n\n/**\n * Wrapper para server actions que mutam estado (delete/update/create/publish/\n * billing/etc.). Faz validação de sessão contra o backend (`POST /auth/keep`)\n * antes de executar a ação e roteia erros via `safeServerAction`.\n *\n * A validação é deduplicada por request — múltiplas actions sensíveis que\n * rodem dentro de uma mesma request pagam 1 round-trip ao backend, não N.\n *\n * Motivação (resumo): o backend confia no par `(whitelabel-token, id_account\n * no path)` nos endpoints de CRUD; o Next.js deriva `id_account` de\n * `atob(cookie)` sem verificar assinatura. Chamar `requireValidSession`\n * aqui garante que o cookie corresponde a uma sessão real no banco antes\n * de qualquer mutação.\n *\n * Para reads não-sensíveis, continue usando `safeServerAction` direto.\n */\nexport async function safeMutationAction<T>(\n fn: () => Promise<T>\n): Promise<ActionResult<T>> {\n return safeServerAction(async () => {\n await requireValidSession();\n return fn();\n });\n}\n"],"mappings":"AAAA,OAAO;AAGP,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AAkBjC,eAAsB,mBACpB,IAC0B;AAC1B,SAAO,iBAAiB,YAAY;AAClC,UAAM,oBAAoB;AAC1B,WAAO,GAAG;AAAA,EACZ,CAAC;AACH;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greatapps/common",
3
- "version": "1.1.541",
3
+ "version": "1.1.543",
4
4
  "description": "Shared library for GreatApps frontend applications",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./src/index.ts",
@@ -36,6 +36,7 @@ export default function ConfigurationsMyAccountModal() {
36
36
  const isBlockingSubscription =
37
37
  isPaidSubscriptionType &&
38
38
  subscription.active === true &&
39
+ !subscription.date_cancellation &&
39
40
  !hasSubscriptionExpired(subscription.date_due);
40
41
 
41
42
  const { user } = useAuth();
@@ -6,20 +6,52 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../ui/overlay/
6
6
  import { Button } from '../ui/buttons/Button';
7
7
  import { Toast } from '../ui/feedback/Toast';
8
8
  import { useAccountModals } from '../../store/useAccountModals';
9
+ import { useCountPages } from '../../modules/pages/hooks/count-pages.hook';
10
+ import {
11
+ useDeleteAccount,
12
+ useDeleteAccountUser,
13
+ } from '../../modules/accounts/hooks/useAccountManagement';
14
+ import { useAuth } from '../../providers/auth.provider';
15
+ import { UserProfile } from '../../modules/users/schema';
9
16
 
10
17
  export default function ConfirmDeleteAccountModal() {
11
- const { activeModal, pagesCount, close } = useAccountModals();
18
+ const { activeModal, close } = useAccountModals();
12
19
  const open = activeModal === 'confirmDelete';
13
20
 
14
- const handleConfirm = () => {
15
- toast.custom((t) => (
16
- <Toast variant="success" message="Conta excluída com sucesso" toastId={t} />
17
- ));
18
- close();
21
+ const { data: pagesCount = 0 } = useCountPages();
22
+
23
+ const { user, logout } = useAuth();
24
+ const isOwner = user?.profile === UserProfile.owner;
25
+
26
+ const deleteAccount = useDeleteAccount();
27
+ const deleteAccountUser = useDeleteAccountUser();
28
+ const isDeleting = deleteAccount.isPending || deleteAccountUser.isPending;
29
+
30
+ const handleConfirm = async () => {
31
+ try {
32
+ if (isOwner) {
33
+ await deleteAccount.mutateAsync();
34
+ } else {
35
+ await deleteAccountUser.mutateAsync(user!.id);
36
+ }
37
+ close();
38
+ toast.custom((t) => (
39
+ <Toast variant="success" message="Conta excluída com sucesso" toastId={t} />
40
+ ));
41
+ await logout();
42
+ } catch (error) {
43
+ toast.custom((t) => (
44
+ <Toast
45
+ variant="error"
46
+ message={error instanceof Error ? error.message : 'Erro ao excluir. Tente novamente.'}
47
+ toastId={t}
48
+ />
49
+ ));
50
+ }
19
51
  };
20
52
 
21
53
  return (
22
- <Dialog open={open} onOpenChange={close}>
54
+ <Dialog open={open} onOpenChange={isDeleting ? undefined : close}>
23
55
  <DialogContent className="flex flex-col p-0 gap-0 max-w-[calc(100%-2rem)]! w-full rounded-lg border sm:max-w-[400px]! lg:max-w-[470px]! lg:top-[50%]! lg:left-[50%]! lg:right-auto! lg:bottom-auto! lg:translate-x-[-50%]! lg:translate-y-[-50%]!">
24
56
  <div className="flex flex-col gap-5 p-4 lg:p-5">
25
57
  <DialogHeader className="p-0">
@@ -42,11 +74,16 @@ export default function ConfirmDeleteAccountModal() {
42
74
  <div className="h-px bg-gray-200" />
43
75
 
44
76
  <div className="flex items-center gap-2 p-4 lg:p-5">
45
- <Button className="h-10 flex-1" onClick={close}>
77
+ <Button className="h-10 flex-1" onClick={close} disabled={isDeleting}>
46
78
  Manter minha conta
47
79
  </Button>
48
- <Button variant="secondary" className="h-10! flex-1" onClick={handleConfirm}>
49
- Excluir mesmo assim
80
+ <Button
81
+ variant="secondary"
82
+ className="h-10! flex-1"
83
+ onClick={handleConfirm}
84
+ disabled={isDeleting}
85
+ >
86
+ {isDeleting ? 'Excluindo...' : 'Excluir mesmo assim'}
50
87
  </Button>
51
88
  </div>
52
89
  </DialogContent>
@@ -23,7 +23,7 @@ const REASON_OPTIONS = [
23
23
  ];
24
24
 
25
25
  export default function DeleteAccountModal() {
26
- const { activeModal, pagesCount, openConfigurations, openConfirmDelete, close } = useAccountModals();
26
+ const { activeModal, openConfigurations, openConfirmDelete, close } = useAccountModals();
27
27
  const open = activeModal === 'deleteAccount';
28
28
 
29
29
  const [reason, setReason] = useState('');
@@ -53,7 +53,7 @@ export default function DeleteAccountModal() {
53
53
  return;
54
54
  }
55
55
  resetForm();
56
- openConfirmDelete(pagesCount);
56
+ openConfirmDelete();
57
57
  };
58
58
 
59
59
  return (
package/src/index.ts CHANGED
@@ -135,6 +135,11 @@ export {
135
135
  } from "./modules/cards/types";
136
136
  export { buildPlanExtras } from "./modules/subscriptions/utils/build-plan-extras";
137
137
  export { hasSubscriptionExpired } from "./modules/subscriptions/utils/has-subscription-expired";
138
+ export {
139
+ useCountPages,
140
+ COUNT_PAGES_QUERY_KEY,
141
+ } from "./modules/pages/hooks/count-pages.hook";
142
+ export { PAGES_QUERY_KEY } from "./modules/pages/constants/query-keys.constants";
138
143
  export {
139
144
  getPriceFromCalculatedData,
140
145
  getOriginalPriceFromCalculatedData,
@@ -1,6 +1,7 @@
1
1
  'use server';
2
2
 
3
3
  import { safeServerAction } from '../../../utils/safeServerAction';
4
+ import { safeMutationAction } from '../../../utils/safeMutationAction';
4
5
  import { accountService } from '../services/account.service';
5
6
  import type {
6
7
  AccountUsersPaginationParams,
@@ -22,18 +23,18 @@ export async function listAccountUsersAction(params?: AccountUsersPaginationPara
22
23
  }
23
24
 
24
25
  export async function updateUserAction(user: UpdateAccountUserRequest) {
25
- return safeServerAction(() => accountService.updateAccountUser(user));
26
+ return safeMutationAction(() => accountService.updateAccountUser(user));
26
27
  }
27
28
 
28
29
  export async function updateAccountUserByIdAction(
29
30
  userId: number,
30
31
  user: UpdateAccountUserRequest
31
32
  ) {
32
- return safeServerAction(() => accountService.updateAccountUserById(userId, user));
33
+ return safeMutationAction(() => accountService.updateAccountUserById(userId, user));
33
34
  }
34
35
 
35
36
  export async function updateAccountAction(data: UpdateAccountRequest) {
36
- return safeServerAction(async () => {
37
+ return safeMutationAction(async () => {
37
38
  if (data.name !== undefined) {
38
39
  const userResult = await findUserById();
39
40
  if (!userResult.success || userResult.data?.profile !== UserProfile.owner) {
@@ -50,39 +51,39 @@ export async function updateAccountAction(data: UpdateAccountRequest) {
50
51
  }
51
52
 
52
53
  export async function deleteAccountUserAction(userId: number) {
53
- return safeServerAction(() => accountService.deleteAccountUser(userId));
54
+ return safeMutationAction(() => accountService.deleteAccountUser(userId));
54
55
  }
55
56
 
56
57
  export async function deleteAccountAction() {
57
- return safeServerAction(() => accountService.deleteAccount());
58
+ return safeMutationAction(() => accountService.deleteAccount());
58
59
  }
59
60
 
60
61
  export async function createAccountUserAction(user: CreateAccountUserRequest) {
61
- return safeServerAction(() => accountService.createAccountUser(user));
62
+ return safeMutationAction(() => accountService.createAccountUser(user));
62
63
  }
63
64
 
64
65
  export async function changePasswordAction(data: ChangePasswordRequest) {
65
- return safeServerAction(() => accountService.changePassword(data));
66
+ return safeMutationAction(() => accountService.changePassword(data));
66
67
  }
67
68
 
68
69
  export async function requestEmailChangeAction(newEmail: string) {
69
- return safeServerAction(() => accountService.requestContactReset('email', newEmail));
70
+ return safeMutationAction(() => accountService.requestContactReset('email', newEmail));
70
71
  }
71
72
 
72
73
  export async function confirmEmailChangeAction(token: string, newEmail: string) {
73
- return safeServerAction(() => accountService.confirmContactReset('email', token, newEmail));
74
+ return safeMutationAction(() => accountService.confirmContactReset('email', token, newEmail));
74
75
  }
75
76
 
76
77
  export async function requestPhoneChangeAction(newPhone: string, ddi?: string) {
77
- return safeServerAction(() => accountService.requestContactReset('phone', newPhone, ddi));
78
+ return safeMutationAction(() => accountService.requestContactReset('phone', newPhone, ddi));
78
79
  }
79
80
 
80
81
  export async function confirmPhoneChangeAction(token: string, newPhone: string, ddi?: string) {
81
- return safeServerAction(() => accountService.confirmContactReset('phone', token, newPhone, ddi));
82
+ return safeMutationAction(() => accountService.confirmContactReset('phone', token, newPhone, ddi));
82
83
  }
83
84
 
84
85
  export async function generateTwoFactorAction() {
85
- return safeServerAction(async () => {
86
+ return safeMutationAction(async () => {
86
87
  const result = await twoFactorService.generate();
87
88
  return {
88
89
  qrcode: result.data.qrcode,
@@ -92,14 +93,14 @@ export async function generateTwoFactorAction() {
92
93
  }
93
94
 
94
95
  export async function confirmTwoFactorAction(code: string) {
95
- return safeServerAction(async () => {
96
+ return safeMutationAction(async () => {
96
97
  await twoFactorService.confirm(code);
97
98
  await accountService.updateAccountUser({ two_factor_authentication: true });
98
99
  });
99
100
  }
100
101
 
101
102
  export async function disableTwoFactorAction(code: string) {
102
- return safeServerAction(async () => {
103
+ return safeMutationAction(async () => {
103
104
  await twoFactorService.verify(code);
104
105
  await twoFactorService.disable();
105
106
  await accountService.updateAccountUser({ two_factor_authentication: false });