@greatapps/common 1.1.785 → 1.1.787

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 (113) hide show
  1. package/dist/components/layouts/AppMobileNavBar.mjs +64 -5
  2. package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -1
  3. package/dist/components/layouts/AppNavBar.mjs +2 -0
  4. package/dist/components/layouts/AppNavBar.mjs.map +1 -1
  5. package/dist/components/layouts/GreatDomainIcon.mjs +40 -0
  6. package/dist/components/layouts/GreatDomainIcon.mjs.map +1 -0
  7. package/dist/components/layouts/NavBar.mjs +111 -52
  8. package/dist/components/layouts/NavBar.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 +2 -0
  12. package/dist/handlers.mjs.map +1 -1
  13. package/dist/i18n/messages/en-us.mjs +3 -1
  14. package/dist/i18n/messages/en-us.mjs.map +1 -1
  15. package/dist/i18n/messages/es-es.mjs +3 -1
  16. package/dist/i18n/messages/es-es.mjs.map +1 -1
  17. package/dist/i18n/messages/pt-br.mjs +3 -1
  18. package/dist/i18n/messages/pt-br.mjs.map +1 -1
  19. package/dist/index.mjs +11 -2
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/infra/api/client.mjs +5 -1
  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 +4 -1
  26. package/dist/infra/route/safe-route-handler.mjs.map +1 -1
  27. package/dist/middlewares/create-auth-middleware.mjs +11 -1
  28. package/dist/middlewares/create-auth-middleware.mjs.map +1 -1
  29. package/dist/modules/auth/utils/assert-account-not-frozen.mjs +6 -5
  30. package/dist/modules/auth/utils/assert-account-not-frozen.mjs.map +1 -1
  31. package/dist/modules/auth/utils/assert-management-subscription.mjs +7 -14
  32. package/dist/modules/auth/utils/assert-management-subscription.mjs.map +1 -1
  33. package/dist/modules/auth/utils/assert-paid-subscription.mjs +7 -12
  34. package/dist/modules/auth/utils/assert-paid-subscription.mjs.map +1 -1
  35. package/dist/modules/auth/utils/assert-subscription-addon.mjs +2 -10
  36. package/dist/modules/auth/utils/assert-subscription-addon.mjs.map +1 -1
  37. package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -1
  38. package/dist/modules/subscriptions/actions/get-current-subscription.action.mjs +10 -0
  39. package/dist/modules/subscriptions/actions/get-current-subscription.action.mjs.map +1 -0
  40. package/dist/modules/subscriptions/constants/subscription.constants.mjs +2 -0
  41. package/dist/modules/subscriptions/constants/subscription.constants.mjs.map +1 -1
  42. package/dist/modules/subscriptions/handlers/current-subscription.handler.mjs +17 -0
  43. package/dist/modules/subscriptions/handlers/current-subscription.handler.mjs.map +1 -0
  44. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +2 -13
  45. package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -1
  46. package/dist/modules/subscriptions/hooks/use-current-subscription.hook.mjs +28 -0
  47. package/dist/modules/subscriptions/hooks/use-current-subscription.hook.mjs.map +1 -0
  48. package/dist/modules/subscriptions/services/subscriptions.service.mjs +26 -0
  49. package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -1
  50. package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -1
  51. package/dist/modules/subscriptions/utils/group-subscriptions-by-product.mjs +16 -0
  52. package/dist/modules/subscriptions/utils/group-subscriptions-by-product.mjs.map +1 -0
  53. package/dist/modules/subscriptions/utils/has-active-paid-subscription.mjs +1 -1
  54. package/dist/modules/subscriptions/utils/has-active-paid-subscription.mjs.map +1 -1
  55. package/dist/modules/subscriptions/utils/has-paid-subscription.mjs +1 -1
  56. package/dist/modules/subscriptions/utils/has-paid-subscription.mjs.map +1 -1
  57. package/dist/modules/subscriptions/utils/read-current-subscription.mjs +21 -0
  58. package/dist/modules/subscriptions/utils/read-current-subscription.mjs.map +1 -0
  59. package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs +9 -6
  60. package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs.map +1 -1
  61. package/dist/modules/whitelabel/services/whitelabel.service.mjs +28 -2
  62. package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +1 -1
  63. package/dist/providers/auth.provider.mjs +12 -9
  64. package/dist/providers/auth.provider.mjs.map +1 -1
  65. package/dist/server.mjs +4 -0
  66. package/dist/server.mjs.map +1 -1
  67. package/dist/store/useMdSidebarStore.mjs +17 -4
  68. package/dist/store/useMdSidebarStore.mjs.map +1 -1
  69. package/dist/utils/redirect.mjs +10 -0
  70. package/dist/utils/redirect.mjs.map +1 -1
  71. package/dist/utils/safeServerAction.mjs +4 -1
  72. package/dist/utils/safeServerAction.mjs.map +1 -1
  73. package/dist/utils/withAction.mjs +2 -1
  74. package/dist/utils/withAction.mjs.map +1 -1
  75. package/package.json +1 -1
  76. package/src/components/layouts/AppMobileNavBar.tsx +90 -6
  77. package/src/components/layouts/AppNavBar.tsx +5 -1
  78. package/src/components/layouts/GreatDomainIcon.tsx +43 -0
  79. package/src/components/layouts/NavBar.tsx +160 -66
  80. package/src/components/ui/form/PhoneInput.tsx +1 -1
  81. package/src/handlers.ts +1 -0
  82. package/src/i18n/messages/en-us.ts +2 -0
  83. package/src/i18n/messages/es-es.ts +2 -0
  84. package/src/i18n/messages/pt-br.ts +2 -0
  85. package/src/index.ts +8 -2
  86. package/src/infra/api/client.ts +11 -3
  87. package/src/infra/api/types.ts +7 -5
  88. package/src/infra/route/safe-route-handler.ts +4 -1
  89. package/src/middlewares/create-auth-middleware.ts +12 -1
  90. package/src/modules/auth/utils/assert-account-not-frozen.ts +7 -6
  91. package/src/modules/auth/utils/assert-management-subscription.ts +15 -23
  92. package/src/modules/auth/utils/assert-paid-subscription.ts +7 -15
  93. package/src/modules/auth/utils/assert-subscription-addon.ts +2 -12
  94. package/src/modules/plans/hooks/use-plan-by-id.hook.ts +1 -1
  95. package/src/modules/subscriptions/actions/get-current-subscription.action.ts +8 -0
  96. package/src/modules/subscriptions/constants/subscription.constants.ts +3 -0
  97. package/src/modules/subscriptions/handlers/current-subscription.handler.ts +16 -0
  98. package/src/modules/subscriptions/hooks/find-active-subscription.hook.ts +7 -17
  99. package/src/modules/subscriptions/hooks/use-current-subscription.hook.ts +38 -0
  100. package/src/modules/subscriptions/services/subscriptions.service.ts +34 -0
  101. package/src/modules/subscriptions/types/subscription.type.ts +2 -0
  102. package/src/modules/subscriptions/utils/group-subscriptions-by-product.ts +23 -0
  103. package/src/modules/subscriptions/utils/has-active-paid-subscription.ts +1 -2
  104. package/src/modules/subscriptions/utils/has-paid-subscription.ts +1 -2
  105. package/src/modules/subscriptions/utils/read-current-subscription.ts +34 -0
  106. package/src/modules/whitelabel/actions/find-whitelabel.action.ts +13 -9
  107. package/src/modules/whitelabel/services/whitelabel.service.ts +34 -2
  108. package/src/providers/auth.provider.tsx +13 -10
  109. package/src/server.ts +2 -0
  110. package/src/store/useMdSidebarStore.ts +20 -5
  111. package/src/utils/redirect.ts +10 -0
  112. package/src/utils/safeServerAction.ts +4 -6
  113. package/src/utils/withAction.ts +2 -1
@@ -10,12 +10,10 @@ export async function safeServerAction<T>(
10
10
  return { success: true, data };
11
11
  } catch (error) {
12
12
  if (isRedirectError(error)) throw error;
13
- const message =
14
- error instanceof ApiError
15
- ? error.message
16
- : error instanceof Error
17
- ? error.message
18
- : 'Erro desconhecido';
13
+ if (error instanceof ApiError) {
14
+ return { success: false, error: error.message, code: error.code, statusCode: error.statusCode };
15
+ }
16
+ const message = error instanceof Error ? error.message : 'Erro desconhecido';
19
17
  return { success: false, error: message };
20
18
  }
21
19
  }
@@ -1,3 +1,4 @@
1
+ import { ApiError } from '../infra/api/types';
1
2
  import type { ActionResult } from '../infra/api/types';
2
3
 
3
4
  export function withAction<TArgs extends any[], TData>(
@@ -6,7 +7,7 @@ export function withAction<TArgs extends any[], TData>(
6
7
  return async (...args) => {
7
8
  const result = await action(...args);
8
9
  if (!result.success) {
9
- throw new Error(result.error ?? 'Erro desconhecido');
10
+ throw new ApiError(result.error, result.code, result.statusCode);
10
11
  }
11
12
  return result.data as TData;
12
13
  };