@greatapps/common 1.1.525 → 1.1.526
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/account/ConfigurationsMyAccountModal.mjs +10 -4
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +3 -1
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/sections/ChangeEmailModal.mjs +3 -1
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -1
- package/dist/components/account/sections/ChangePhoneModal.mjs +3 -1
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -1
- package/dist/components/account/sections/MyProfileSection.mjs +2 -1
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
- package/dist/components/account/sections/TokenSection.mjs +72 -0
- package/dist/components/account/sections/TokenSection.mjs.map +1 -0
- package/dist/components/embeds/ClarityEmbed.mjs +55 -0
- package/dist/components/embeds/ClarityEmbed.mjs.map +1 -0
- package/dist/components/embeds/EmbedWidgets.mjs +3 -1
- package/dist/components/embeds/EmbedWidgets.mjs.map +1 -1
- package/dist/components/layouts/AppMobileNavBar.mjs +3 -1
- package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -1
- package/dist/components/layouts/AppNavBar.mjs +4 -8
- package/dist/components/layouts/AppNavBar.mjs.map +1 -1
- package/dist/components/layouts/NavBar.mjs +10 -9
- package/dist/components/layouts/NavBar.mjs.map +1 -1
- package/dist/components/layouts/NotificationsPopover.mjs +5 -2
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -1
- package/dist/components/layouts/ProfilePopover.mjs +4 -2
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -1
- package/dist/components/layouts/SideBarNavigation.mjs +4 -1
- package/dist/components/layouts/SideBarNavigation.mjs.map +1 -1
- package/dist/components/modals/BuyCreditsModal.mjs +26 -9
- package/dist/components/modals/BuyCreditsModal.mjs.map +1 -1
- package/dist/components/modals/cards/AddCardModal.mjs +3 -1
- package/dist/components/modals/cards/AddCardModal.mjs.map +1 -1
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs +1 -1
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -1
- package/dist/components/navigation/ProjectSelectorPopover.mjs +7 -6
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +39 -19
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -1
- package/dist/components/pages/NotFoundPage.mjs +2 -2
- package/dist/components/pages/NotFoundPage.mjs.map +1 -1
- package/dist/components/ui/buttons/Button.mjs +7 -2
- package/dist/components/ui/buttons/Button.mjs.map +1 -1
- package/dist/components/ui/data-display/CardItem.mjs +1 -1
- package/dist/components/ui/data-display/CardItem.mjs.map +1 -1
- package/dist/components/ui/data-display/PaymentInfoCard.mjs +4 -2
- package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -1
- package/dist/components/ui/data-display/UserAvatar.mjs +6 -2
- package/dist/components/ui/data-display/UserAvatar.mjs.map +1 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs +4 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -1
- package/dist/components/ui/feedback/Toast.mjs +7 -2
- package/dist/components/ui/feedback/Toast.mjs.map +1 -1
- package/dist/components/ui/form/FormField.mjs +1 -1
- package/dist/components/ui/form/FormField.mjs.map +1 -1
- package/dist/components/ui/form/Select.mjs +1 -1
- package/dist/components/ui/form/Select.mjs.map +1 -1
- package/dist/components/ui/overlay/Popover.mjs +1 -1
- package/dist/components/ui/overlay/Popover.mjs.map +1 -1
- package/dist/components/ui/overlay/Sheet.mjs +8 -6
- package/dist/components/ui/overlay/Sheet.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageCropModal.mjs +11 -37
- package/dist/components/widgets/ImageUpload/ImageCropModal.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageUpload.mjs +2 -1
- package/dist/components/widgets/ImageUpload/ImageUpload.mjs.map +1 -1
- package/dist/components/widgets/notifications/NotificationCard.mjs +4 -1
- package/dist/components/widgets/notifications/NotificationCard.mjs.map +1 -1
- package/dist/enums/AccountSectionType.mjs +1 -0
- package/dist/enums/AccountSectionType.mjs.map +1 -1
- package/dist/hooks/useAuthQueryKey.mjs +23 -0
- package/dist/hooks/useAuthQueryKey.mjs.map +1 -0
- package/dist/index.mjs +90 -8
- package/dist/index.mjs.map +1 -1
- package/dist/infra/utils/array.mjs +34 -0
- package/dist/infra/utils/array.mjs.map +1 -0
- package/dist/modules/accounts/actions/get-account-token.action.mjs +10 -0
- package/dist/modules/accounts/actions/get-account-token.action.mjs.map +1 -0
- package/dist/modules/accounts/hooks/current-account.hook.mjs +5 -2
- package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -1
- package/dist/modules/accounts/hooks/use-account-token.hook.mjs +15 -0
- package/dist/modules/accounts/hooks/use-account-token.hook.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useAccountManagement.mjs +19 -9
- package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useCurrencies.mjs +3 -1
- package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useTimezones.mjs +3 -1
- package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -1
- package/dist/modules/accounts/services/account-token.service.mjs +32 -0
- package/dist/modules/accounts/services/account-token.service.mjs.map +1 -0
- package/dist/modules/auth/hooks/useUserQuery.mjs +15 -6
- package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -1
- package/dist/modules/cards/actions/delete-card.action.mjs +10 -0
- package/dist/modules/cards/actions/delete-card.action.mjs.map +1 -0
- package/dist/modules/cards/actions/find-card-by-id.action.mjs +10 -0
- package/dist/modules/cards/actions/find-card-by-id.action.mjs.map +1 -0
- package/dist/modules/cards/actions/set-default-card.action.mjs +10 -0
- package/dist/modules/cards/actions/set-default-card.action.mjs.map +1 -0
- package/dist/modules/cards/hooks/card-by-id.hook.mjs +22 -0
- package/dist/modules/cards/hooks/card-by-id.hook.mjs.map +1 -0
- package/dist/modules/cards/hooks/cards.hook.mjs +11 -3
- package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -1
- package/dist/modules/cards/hooks/create-card.hook.mjs +13 -2
- package/dist/modules/cards/hooks/create-card.hook.mjs.map +1 -1
- package/dist/modules/cards/hooks/delete-card.hook.mjs +50 -0
- package/dist/modules/cards/hooks/delete-card.hook.mjs.map +1 -0
- package/dist/modules/cards/hooks/set-default-card.hook.mjs +51 -0
- package/dist/modules/cards/hooks/set-default-card.hook.mjs.map +1 -0
- package/dist/modules/cards/services/cards.service.mjs +45 -4
- package/dist/modules/cards/services/cards.service.mjs.map +1 -1
- package/dist/modules/cards/types.mjs +11 -3
- package/dist/modules/cards/types.mjs.map +1 -1
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +3 -1
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -1
- package/dist/modules/plans/hooks/list-plans.hook.mjs +3 -1
- package/dist/modules/plans/hooks/list-plans.hook.mjs.map +1 -1
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs +4 -2
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -1
- package/dist/modules/plans/services/plans.service.mjs +4 -2
- package/dist/modules/plans/services/plans.service.mjs.map +1 -1
- package/dist/modules/plans/types/plan.type.mjs.map +1 -1
- package/dist/modules/plans/utils/map-api-plan-to-ui.mjs +20 -10
- package/dist/modules/plans/utils/map-api-plan-to-ui.mjs.map +1 -1
- package/dist/modules/projects/actions/create-project.action.mjs +10 -0
- package/dist/modules/projects/actions/create-project.action.mjs.map +1 -0
- package/dist/modules/projects/actions/delete-project.action.mjs +10 -0
- package/dist/modules/projects/actions/delete-project.action.mjs.map +1 -0
- package/dist/modules/projects/actions/find-project.action.mjs +10 -0
- package/dist/modules/projects/actions/find-project.action.mjs.map +1 -0
- package/dist/modules/projects/actions/list-projects.action.mjs +10 -0
- package/dist/modules/projects/actions/list-projects.action.mjs.map +1 -0
- package/dist/modules/projects/actions/update-project.action.mjs +10 -0
- package/dist/modules/projects/actions/update-project.action.mjs.map +1 -0
- package/dist/modules/projects/hooks/add-project-user.hook.mjs +15 -12
- package/dist/modules/projects/hooks/add-project-user.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/create-project.hook.mjs +71 -0
- package/dist/modules/projects/hooks/create-project.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/delete-project.hook.mjs +53 -0
- package/dist/modules/projects/hooks/delete-project.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/find-project.hook.mjs +19 -0
- package/dist/modules/projects/hooks/find-project.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +3 -1
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs +3 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs +39 -0
- package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-project-users.hook.mjs +3 -1
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-projects.hook.mjs +22 -0
- package/dist/modules/projects/hooks/list-projects.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs +15 -12
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/update-project.hook.mjs +70 -0
- package/dist/modules/projects/hooks/update-project.hook.mjs.map +1 -0
- package/dist/modules/projects/services/projects.service.mjs +99 -0
- package/dist/modules/projects/services/projects.service.mjs.map +1 -0
- package/dist/modules/projects/types.mjs +19 -4
- package/dist/modules/projects/types.mjs.map +1 -1
- package/dist/modules/subscriptions/constants/query-keys.constants.mjs +2 -0
- package/dist/modules/subscriptions/constants/query-keys.constants.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +5 -2
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +3 -1
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs +6 -3
- package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/types/calculate-subscription.type.mjs +29 -2
- package/dist/modules/subscriptions/types/calculate-subscription.type.mjs.map +1 -1
- package/dist/modules/subscriptions/utils/periodicity.mjs +7 -0
- package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -1
- package/dist/modules/users/action/list-messages.action.mjs +14 -2
- package/dist/modules/users/action/list-messages.action.mjs.map +1 -1
- package/dist/modules/users/hooks/messages.hook.mjs +9 -4
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -1
- package/dist/modules/users/services/messages.service.mjs.map +1 -1
- package/dist/providers/auth.provider.mjs +6 -4
- package/dist/providers/auth.provider.mjs.map +1 -1
- package/dist/providers/query.provider.mjs +2 -2
- package/dist/providers/query.provider.mjs.map +1 -1
- package/dist/providers/whitelabel.provider.mjs +5 -0
- package/dist/providers/whitelabel.provider.mjs.map +1 -1
- package/dist/server.mjs +14 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/components/navigation/types.mjs +0 -1
- package/dist/components/navigation/types.mjs.map +0 -1
|
@@ -21,6 +21,24 @@ class CardsService {
|
|
|
21
21
|
const data = response.data.map((item) => CardSchema.parse(item));
|
|
22
22
|
return { data, total: response.total, success: true };
|
|
23
23
|
}
|
|
24
|
+
async findCardById(id) {
|
|
25
|
+
const { id_account } = await getUserContext();
|
|
26
|
+
const response = await api.apps.get(
|
|
27
|
+
`/accounts/${id_account}/cards/${id}`
|
|
28
|
+
);
|
|
29
|
+
if (response.status === 0) {
|
|
30
|
+
throw new ApiError(
|
|
31
|
+
response.message || "Erro ao buscar cart\xE3o",
|
|
32
|
+
"FIND_CARD_BY_ID_FAILED",
|
|
33
|
+
400
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (!response.data?.length) {
|
|
37
|
+
throw new ApiError("Cart\xE3o n\xE3o encontrado", "CARD_NOT_FOUND", 404);
|
|
38
|
+
}
|
|
39
|
+
const data = CardSchema.parse(response.data[0]);
|
|
40
|
+
return { success: true, data };
|
|
41
|
+
}
|
|
24
42
|
async createCard(data) {
|
|
25
43
|
const { id_account } = await getUserContext();
|
|
26
44
|
const response = await api.apps.post(
|
|
@@ -31,10 +49,33 @@ class CardsService {
|
|
|
31
49
|
throw new ApiError(response.message || "Erro ao criar cart\xE3o", "CREATE_CARD_FAILED", 400);
|
|
32
50
|
}
|
|
33
51
|
const cardData = CardSchema.parse(response.data[0]);
|
|
34
|
-
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
52
|
+
return { success: true, data: cardData };
|
|
53
|
+
}
|
|
54
|
+
async setDefaultCard(cardId) {
|
|
55
|
+
const { id_account } = await getUserContext();
|
|
56
|
+
const response = await api.apps.put(
|
|
57
|
+
`/accounts/${id_account}/cards/${cardId}`,
|
|
58
|
+
{ set_default: true }
|
|
59
|
+
);
|
|
60
|
+
if (response.status === 0) {
|
|
61
|
+
throw new ApiError(
|
|
62
|
+
response.message || "Erro ao definir cart\xE3o padr\xE3o",
|
|
63
|
+
"SET_DEFAULT_CARD_FAILED",
|
|
64
|
+
400
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const data = CardSchema.parse(response.data[0]);
|
|
68
|
+
return { success: true, data };
|
|
69
|
+
}
|
|
70
|
+
async deleteCard(id) {
|
|
71
|
+
const { id_account } = await getUserContext();
|
|
72
|
+
const response = await api.apps.delete(
|
|
73
|
+
`/accounts/${id_account}/cards/${id}`
|
|
74
|
+
);
|
|
75
|
+
if (response.status === 0) {
|
|
76
|
+
throw new ApiError(response.message || "Erro ao excluir cart\xE3o", "DELETE_CARD_FAILED", 400);
|
|
77
|
+
}
|
|
78
|
+
return { success: true };
|
|
38
79
|
}
|
|
39
80
|
}
|
|
40
81
|
const cardsService = new CardsService();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/cards/services/cards.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { ApiError, ApiPaginatedActionResult, PaginatedSuccessResult, SuccessResult } from '../../../infra/api/types';\nimport { buildQueryParams } from '../../../infra/utils/params';\nimport { getUserContext } from '../../auth/utils/get-user-context';\nimport { Card, CardSchema, CreateCardRequest } from '../types';\n\nclass CardsService {\n async listCards(): Promise<PaginatedSuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const query = buildQueryParams({ id_account });\n const response = await api.apps.get<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards?${query}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao listar cartões',\n 'LIST_CARDS_FAILED',\n 400\n );\n }\n\n const data = response.data.map((item) => CardSchema.parse(item));\n\n return { data, total: response.total, success: true };\n }\n async createCard(data: CreateCardRequest): Promise<SuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.post<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards`,\n data\n );\n\n if (response.status === 0) {\n throw new ApiError(response.message || 'Erro ao criar cartão', 'CREATE_CARD_FAILED', 400);\n }\n\n const cardData = CardSchema.parse(response.data[0]);\n\n return {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/cards/services/cards.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { ApiError, ApiActionResult, ApiPaginatedActionResult, PaginatedSuccessResult, SuccessResult } from '../../../infra/api/types';\nimport { buildQueryParams } from '../../../infra/utils/params';\nimport { getUserContext } from '../../auth/utils/get-user-context';\nimport { Card, CardSchema, CreateCardRequest } from '../types';\n\nclass CardsService {\n async listCards(): Promise<PaginatedSuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const query = buildQueryParams({ id_account });\n const response = await api.apps.get<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards?${query}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao listar cartões',\n 'LIST_CARDS_FAILED',\n 400\n );\n }\n\n const data = response.data.map((item) => CardSchema.parse(item));\n\n return { data, total: response.total, success: true };\n }\n\n async findCardById(id: number): Promise<SuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.get<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards/${id}`\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao buscar cartão',\n 'FIND_CARD_BY_ID_FAILED',\n 400\n );\n }\n\n if (!response.data?.length) {\n throw new ApiError('Cartão não encontrado', 'CARD_NOT_FOUND', 404);\n }\n\n const data = CardSchema.parse(response.data[0]);\n\n return { success: true, data };\n }\n\n async createCard(data: CreateCardRequest): Promise<SuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.post<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards`,\n data\n );\n\n if (response.status === 0) {\n throw new ApiError(response.message || 'Erro ao criar cartão', 'CREATE_CARD_FAILED', 400);\n }\n\n const cardData = CardSchema.parse(response.data[0]);\n\n return { success: true, data: cardData };\n }\n\n async setDefaultCard(cardId: string): Promise<SuccessResult<Card>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.put<ApiPaginatedActionResult<Card>>(\n `/accounts/${id_account}/cards/${cardId}`,\n { set_default: true }\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || 'Erro ao definir cartão padrão',\n 'SET_DEFAULT_CARD_FAILED',\n 400\n );\n }\n\n const data = CardSchema.parse(response.data[0]);\n\n return { success: true, data };\n }\n\n async deleteCard(id: string): Promise<SuccessResult<void>> {\n const { id_account } = await getUserContext();\n\n const response = await api.apps.delete<ApiActionResult<void>>(\n `/accounts/${id_account}/cards/${id}`\n );\n\n if (response.status === 0) {\n throw new ApiError(response.message || 'Erro ao excluir cartão', 'DELETE_CARD_FAILED', 400);\n }\n\n return { success: true };\n }\n}\n\nexport const cardsService = new CardsService();\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAAkG;AAC3G,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAe,kBAAqC;AAEpD,MAAM,aAAa;AAAA,EACjB,MAAM,YAAmD;AACvD,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,QAAQ,iBAAiB,EAAE,WAAW,CAAC;AAC7C,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,aAAa,UAAU,UAAU,KAAK;AAAA,IACxC;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,OAAO,SAAS,KAAK,IAAI,CAAC,SAAS,WAAW,MAAM,IAAI,CAAC;AAE/D,WAAO,EAAE,MAAM,OAAO,SAAS,OAAO,SAAS,KAAK;AAAA,EACtD;AAAA,EAEA,MAAM,aAAa,IAA0C;AAC3D,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,WAAW,MAAM,IAAI,KAAK;AAAA,MAC9B,aAAa,UAAU,UAAU,EAAE;AAAA,IACrC;AAEA,QAAI,SAAS,WAAW,GAAG;AACzB,YAAM,IAAI;AAAA,QACR,SAAS,WAAW;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,SAAS,MAAM,QAAQ;AAC1B,YAAM,IAAI,SAAS,+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,MAAM,eAAe,IAAI,aAAa;","names":[]}
|
|
@@ -8,8 +8,8 @@ const CardSchema = z.object({
|
|
|
8
8
|
gateway_card: z.string().optional(),
|
|
9
9
|
brand: z.string(),
|
|
10
10
|
name: z.string(),
|
|
11
|
-
number: z.string(),
|
|
12
|
-
date: z.string().optional(),
|
|
11
|
+
number: z.string().nullable(),
|
|
12
|
+
date: z.string().nullable().optional(),
|
|
13
13
|
deleted: z.number().transform((val) => val === 1).optional().default(false),
|
|
14
14
|
is_default: z.boolean().optional().default(false),
|
|
15
15
|
datetime_add: z.union([z.date(), z.coerce.date()]).nullable().optional(),
|
|
@@ -20,8 +20,16 @@ const CreateCardRequestSchema = z.object({
|
|
|
20
20
|
payment_method_id: z.string().min(1, "payment_method_id \xE9 obrigat\xF3rio"),
|
|
21
21
|
set_default: z.boolean().optional()
|
|
22
22
|
});
|
|
23
|
+
const FindCardsParamsSchema = z.object({
|
|
24
|
+
page: z.number().optional(),
|
|
25
|
+
limit: z.number().optional(),
|
|
26
|
+
search: z.string().optional(),
|
|
27
|
+
sort: z.string().optional(),
|
|
28
|
+
order: z.enum(["asc", "desc"]).optional()
|
|
29
|
+
});
|
|
23
30
|
export {
|
|
24
31
|
CardSchema,
|
|
25
|
-
CreateCardRequestSchema
|
|
32
|
+
CreateCardRequestSchema,
|
|
33
|
+
FindCardsParamsSchema
|
|
26
34
|
};
|
|
27
35
|
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/modules/cards/types.ts"],"sourcesContent":["import z from 'zod';\n\nexport const CardSchema = z.object({\n id: z.union([z.number(), z.string()]),\n id_wl: z.number().optional(),\n id_account: z.union([z.number(), z.string()]).optional(),\n id_gateway: z.union([z.number(), z.string()]).optional(),\n gateway_account: z.string().optional(),\n gateway_card: z.string().optional(),\n brand: z.string(),\n name: z.string(),\n number: z.string(),\n date: z.string().optional(),\n deleted: z\n .number()\n .transform((val) => val === 1)\n .optional()\n .default(false),\n is_default: z.boolean().optional().default(false),\n datetime_add: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_alt: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_del: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n});\n\nexport type Card = z.infer<typeof CardSchema>;\n\nexport const CreateCardRequestSchema = z.object({\n payment_method_id: z.string().min(1, 'payment_method_id é obrigatório'),\n set_default: z.boolean().optional(),\n});\n\nexport type CreateCardRequest = z.infer<typeof CreateCardRequestSchema>;\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,aAAa,EAAE,OAAO;AAAA,EACjC,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACpC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACvD,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACvD,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,EAClC,OAAO,EAAE,OAAO;AAAA,EAChB,MAAM,EAAE,OAAO;AAAA,EACf,QAAQ,EAAE,OAAO;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/cards/types.ts"],"sourcesContent":["import z from 'zod';\n\nexport const CardSchema = z.object({\n id: z.union([z.number(), z.string()]),\n id_wl: z.number().optional(),\n id_account: z.union([z.number(), z.string()]).optional(),\n id_gateway: z.union([z.number(), z.string()]).optional(),\n gateway_account: z.string().optional(),\n gateway_card: z.string().optional(),\n brand: z.string(),\n name: z.string(),\n number: z.string().nullable(),\n date: z.string().nullable().optional(),\n deleted: z\n .number()\n .transform((val) => val === 1)\n .optional()\n .default(false),\n is_default: z.boolean().optional().default(false),\n datetime_add: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_alt: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n datetime_del: z.union([z.date(), z.coerce.date()]).nullable().optional(),\n});\n\nexport type Card = z.infer<typeof CardSchema>;\n\nexport const CreateCardRequestSchema = z.object({\n payment_method_id: z.string().min(1, 'payment_method_id é obrigatório'),\n set_default: z.boolean().optional(),\n});\n\nexport type CreateCardRequest = z.infer<typeof CreateCardRequestSchema>;\n\nexport const FindCardsParamsSchema = z.object({\n page: z.number().optional(),\n limit: z.number().optional(),\n search: z.string().optional(),\n sort: z.string().optional(),\n order: z.enum(['asc', 'desc']).optional(),\n});\n\nexport type FindCardsParams = z.infer<typeof FindCardsParamsSchema>;\n"],"mappings":"AAAA,OAAO,OAAO;AAEP,MAAM,aAAa,EAAE,OAAO;AAAA,EACjC,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,EACpC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACvD,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAAA,EACvD,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,EAClC,OAAO,EAAE,OAAO;AAAA,EAChB,MAAM,EAAE,OAAO;AAAA,EACf,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACrC,SAAS,EACN,OAAO,EACP,UAAU,CAAC,QAAQ,QAAQ,CAAC,EAC5B,SAAS,EACT,QAAQ,KAAK;AAAA,EAChB,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,EAChD,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EACvE,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,EACvE,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS;AACzE,CAAC;AAIM,MAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,mBAAmB,EAAE,OAAO,EAAE,IAAI,GAAG,uCAAiC;AAAA,EACtE,aAAa,EAAE,QAAQ,EAAE,SAAS;AACpC,CAAC;AAIM,MAAM,wBAAwB,EAAE,OAAO;AAAA,EAC5C,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,OAAO,EAAE,KAAK,CAAC,OAAO,MAAM,CAAC,EAAE,SAAS;AAC1C,CAAC;","names":[]}
|
|
@@ -4,6 +4,7 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
4
4
|
import { listIaCreditsAction } from "../actions/list-ia-credits.action";
|
|
5
5
|
import { useActiveSubscription } from "../../subscriptions/hooks/find-active-subscription.hook";
|
|
6
6
|
import { withAction } from "../../../utils/withAction";
|
|
7
|
+
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
7
8
|
function calculateSummary(operations) {
|
|
8
9
|
const today = /* @__PURE__ */ new Date();
|
|
9
10
|
const todayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
@@ -52,8 +53,9 @@ function useIaCredits() {
|
|
|
52
53
|
const { data: subscriptionData, isPending: isSubscriptionLoading } = useActiveSubscription();
|
|
53
54
|
const subscription = subscriptionData?.data?.[0] ?? null;
|
|
54
55
|
const subscriptionId = subscription?.id;
|
|
56
|
+
const queryKey = useAuthQueryKey(["ia-credits", subscriptionId]);
|
|
55
57
|
const query = useQuery({
|
|
56
|
-
queryKey
|
|
58
|
+
queryKey,
|
|
57
59
|
queryFn: withAction(() => listIaCreditsAction(subscriptionId)),
|
|
58
60
|
enabled: subscriptionId != null
|
|
59
61
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/ia-credits/hooks/ia-credits.hook.ts"],"sourcesContent":["'use client';\
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/ia-credits/hooks/ia-credits.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\nimport { useQuery } from '@tanstack/react-query';\nimport { listIaCreditsAction } from '../actions/list-ia-credits.action';\nimport type { IaCreditOperation, IaCreditsSummary } from '../types';\nimport { useActiveSubscription } from '../../subscriptions/hooks/find-active-subscription.hook';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\n\nfunction calculateSummary(operations: IaCreditOperation[]): IaCreditsSummary {\n const today = new Date();\n const todayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());\n\n const adds = operations.filter((op) => op.operation === 'add');\n const subtracts = operations.filter((op) => op.operation === 'subtract');\n\n let totalCredits = 0;\n let usedCredits = 0;\n let nextExpirationInDays: number | null = null;\n let nextExpiringCredits: number | null = null;\n\n for (const add of adds) {\n const expirationRaw = add.expiration_time;\n if (!expirationRaw) continue;\n\n const expiration = new Date(expirationRaw);\n const expirationDate = new Date(\n expiration.getFullYear(),\n expiration.getMonth(),\n expiration.getDate()\n );\n\n const expiredByDate = expirationDate.getTime() < todayDate.getTime();\n const hasExpired = add.has_expired || expiredByDate;\n\n if (hasExpired) continue;\n\n const addedCredits = add.operation_value;\n\n const consumedForAdd = subtracts\n .filter((sub) => String(sub.consumed_from_add_id) === String(add.id))\n .reduce((sum, sub) => sum + sub.operation_value, 0);\n\n const remainingForAdd = Math.max(0, addedCredits - consumedForAdd);\n\n totalCredits += addedCredits;\n usedCredits += consumedForAdd;\n\n const diffMs = expirationDate.getTime() - todayDate.getTime();\n const days = Math.max(0, Math.ceil(diffMs / (1000 * 60 * 60 * 24)));\n\n if (remainingForAdd > 0) {\n if (nextExpirationInDays === null || days < nextExpirationInDays) {\n nextExpirationInDays = days;\n nextExpiringCredits = remainingForAdd;\n }\n }\n }\n\n const availableCredits = Math.max(0, totalCredits - usedCredits);\n\n return {\n totalCredits,\n usedCredits,\n availableCredits,\n nextExpiringCredits,\n nextExpirationInDays,\n };\n}\n\nexport function useIaCredits() {\n const { data: subscriptionData, isPending: isSubscriptionLoading } = useActiveSubscription();\n const subscription = subscriptionData?.data?.[0] ?? null;\n const subscriptionId = subscription?.id;\n const queryKey = useAuthQueryKey(['ia-credits', subscriptionId]);\n\n const query = useQuery({\n queryKey,\n queryFn: withAction(() => listIaCreditsAction(subscriptionId!)),\n enabled: subscriptionId != null,\n });\n\n const operations = query.data?.data ?? [];\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const summary = useMemo(() => calculateSummary(operations), [operations]);\n\n return {\n subscription,\n operations,\n summary,\n isLoading: isSubscriptionLoading || query.isPending,\n isSubscriptionLoading,\n isCreditsLoading: query.isPending,\n isError: query.isError,\n error: query.error,\n };\n}\n"],"mappings":";AAEA,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,2BAA2B;AAEpC,SAAS,6BAA6B;AACtC,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAEhC,SAAS,iBAAiB,YAAmD;AAC3E,QAAM,QAAQ,oBAAI,KAAK;AACvB,QAAM,YAAY,IAAI,KAAK,MAAM,YAAY,GAAG,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC;AAEjF,QAAM,OAAO,WAAW,OAAO,CAAC,OAAO,GAAG,cAAc,KAAK;AAC7D,QAAM,YAAY,WAAW,OAAO,CA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AM,iBAAiB,cAAc;AACrC,QAAM,WAAW,gBAAgB,CAAC,cAAc,cAAc,CAAC;AAE/D,QAAM,QAAQ,SAAS;AAAA,IACrB;AAAA,IACA,SAAS,WAAW,MAAM,oBAAoB,cAAe,CAAC;AAAA,IAC9D,SAAS,kBAAkB;AAAA,EAC7B,CAAC;AAED,QAAM,aAAa,MAAM,MAAM,QAAQ,CAAC;AAGxC,QAAM,UAAU,QAAQ,MAAM,iBAAiB,UAAU,GAAG,CAAC,UAAU,CAAC;AAExE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,yBAAyB,MAAM;AAAA,IAC1C;AAAA,IACA,kBAAkB,MAAM;AAAA,IACxB,SAAS,MAAM;AAAA,IACf,OAAO,MAAM;AAAA,EACf;AACF;","names":[]}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { withAction } from "@greatapps/common";
|
|
4
4
|
import { listPlansAction } from "../actions/list-plans.action";
|
|
5
|
+
import { useWlQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
5
6
|
const PLANS_QUERY_KEY = ["plans"];
|
|
6
7
|
function usePlans() {
|
|
8
|
+
const queryKey = useWlQueryKey([...PLANS_QUERY_KEY]);
|
|
7
9
|
return useQuery({
|
|
8
|
-
queryKey
|
|
10
|
+
queryKey,
|
|
9
11
|
queryFn: withAction(listPlansAction),
|
|
10
12
|
staleTime: Infinity,
|
|
11
13
|
gcTime: Infinity,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/plans/hooks/list-plans.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { withAction } from '@greatapps/common';\nimport { listPlansAction } from '../actions/list-plans.action';\nimport type { Plan } from '../types/plan.type';\n\nexport const PLANS_QUERY_KEY = ['plans'];\n\nexport function usePlans() {\n return useQuery<Plan[]>({\n queryKey
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/hooks/list-plans.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { withAction } from '@greatapps/common';\nimport { listPlansAction } from '../actions/list-plans.action';\nimport type { Plan } from '../types/plan.type';\nimport { useWlQueryKey } from '../../../hooks/useAuthQueryKey';\n\nexport const PLANS_QUERY_KEY = ['plans'] as const;\n\nexport function usePlans() {\n const queryKey = useWlQueryKey([...PLANS_QUERY_KEY]);\n\n return useQuery<Plan[]>({\n queryKey,\n queryFn: withAction(listPlansAction),\n staleTime: Infinity,\n gcTime: Infinity,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n refetchOnMount: false,\n retry: 1,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAEhC,SAAS,qBAAqB;AAEvB,MAAM,kBAAkB,CAAC,OAAO;AAEhC,SAAS,WAAW;AACzB,QAAM,WAAW,cAAc,CAAC,GAAG,eAAe,CAAC;AAEnD,SAAO,SAAiB;AAAA,IACtB;AAAA,IACA,SAAS,WAAW,eAAe;AAAA,IACnC,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,sBAAsB;AAAA,IACtB,oBAAoB;AAAA,IACpB,gBAAgB;AAAA,IAChB,OAAO;AAAA,EACT,CAAC;AACH;","names":[]}
|
|
@@ -3,14 +3,16 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
3
3
|
import { withAction } from "../../../utils/withAction";
|
|
4
4
|
import { findPlanByIdAction } from "../actions/find-plan-by-id.action";
|
|
5
5
|
import { PLANS_QUERY_KEY } from "./list-plans.hook";
|
|
6
|
+
import { useWlQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
6
7
|
function usePlanById(idPlan) {
|
|
7
8
|
const queryClient = useQueryClient();
|
|
9
|
+
const plansKey = useWlQueryKey([...PLANS_QUERY_KEY]);
|
|
8
10
|
return useQuery({
|
|
9
|
-
queryKey: [...
|
|
11
|
+
queryKey: [...plansKey, idPlan],
|
|
10
12
|
queryFn: withAction(() => findPlanByIdAction(idPlan)),
|
|
11
13
|
initialData: () => {
|
|
12
14
|
const queries = queryClient.getQueriesData({
|
|
13
|
-
queryKey:
|
|
15
|
+
queryKey: plansKey
|
|
14
16
|
});
|
|
15
17
|
for (const [, data] of queries) {
|
|
16
18
|
if (!data || !Array.isArray(data)) continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/plans/hooks/use-plan-by-id.hook.ts"],"sourcesContent":["\"use client\";\n\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { withAction } from \"../../../utils/withAction\";\nimport { findPlanByIdAction } from \"../actions/find-plan-by-id.action\";\nimport type { Plan } from \"../types/plan.type\";\nimport { PLANS_QUERY_KEY } from \"./list-plans.hook\";\n\nexport function usePlanById(idPlan: number | string | undefined) {\n const queryClient = useQueryClient();\n\n return useQuery({\n queryKey: [...
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/hooks/use-plan-by-id.hook.ts"],"sourcesContent":["\"use client\";\n\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport { withAction } from \"../../../utils/withAction\";\nimport { findPlanByIdAction } from \"../actions/find-plan-by-id.action\";\nimport type { Plan } from \"../types/plan.type\";\nimport { PLANS_QUERY_KEY } from \"./list-plans.hook\";\nimport { useWlQueryKey } from \"../../../hooks/useAuthQueryKey\";\n\nexport function usePlanById(idPlan: number | string | undefined) {\n const queryClient = useQueryClient();\n const plansKey = useWlQueryKey([...PLANS_QUERY_KEY]);\n\n return useQuery({\n queryKey: [...plansKey, idPlan],\n queryFn: withAction(() => findPlanByIdAction(idPlan!)),\n initialData: () => {\n const queries = queryClient.getQueriesData<Plan[]>({\n queryKey: plansKey,\n });\n\n for (const [, data] of queries) {\n if (!data || !Array.isArray(data)) continue;\n const numericId = Number(idPlan);\n const plan = data.find(\n (p) => p.id === numericId || p.id_plan === numericId\n );\n if (plan) {\n return { success: true as const, data: plan };\n }\n }\n\n return undefined;\n },\n initialDataUpdatedAt: 0,\n enabled: !!idPlan,\n });\n}\n"],"mappings":";AAEA,SAAS,UAAU,sBAAsB;AACzC,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AAEnC,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAEvB,SAAS,YAAY,QAAqC;AAC/D,QAAM,cAAc,eAAe;AACnC,QAAM,WAAW,cAAc,CAAC,GAAG,eAAe,CAAC;AAEnD,SAAO,SAAS;AAAA,IACd,UAAU,CAAC,GAAG,UAAU,MAAM;AAAA,IAC9B,SAAS,WAAW,MAAM,mBAAmB,MAAO,CAAC;AAAA,IACrD,aAAa,MAAM;AACjB,YAAM,UAAU,YAAY,eAAuB;AAAA,QACjD,UAAU;AAAA,MACZ,CAAC;AAED,iBAAW,CAAC,EAAE,IAAI,KAAK,SAAS;AAC9B,YAAI,CAAC,QAAQ,CAAC,MAAM,QAAQ,IAAI,EAAG;AACnC,cAAM,YAAY,OAAO,MAAM;AAC/B,cAAM,OAAO,KAAK;AAAA,UAChB,CAAC,MAAM,EAAE,OAAO,aAAa,EAAE,YAAY;AAAA,QAC7C;AACA,YAAI,MAAM;AACR,iBAAO,EAAE,SAAS,MAAe,MAAM,KAAK;AAAA,QAC9C;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,IACA,sBAAsB;AAAA,IACtB,SAAS,CAAC,CAAC;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -22,9 +22,10 @@ class PlansService {
|
|
|
22
22
|
* GET /{id_wl}/plans?active=true&search=client&sort=id:ASC
|
|
23
23
|
*/
|
|
24
24
|
async listPlans(params) {
|
|
25
|
-
const { id_account } = await getUserContext();
|
|
25
|
+
const { id_wl, id_account } = await getUserContext();
|
|
26
26
|
const cacheKey = this.buildCacheKey("plans", {
|
|
27
27
|
...params,
|
|
28
|
+
id_wl,
|
|
28
29
|
id_account
|
|
29
30
|
});
|
|
30
31
|
const cachedData = await this.cache.select(cacheKey);
|
|
@@ -57,8 +58,9 @@ class PlansService {
|
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
async findById(idPlan) {
|
|
60
|
-
const { id_account } = await getUserContext();
|
|
61
|
+
const { id_wl, id_account } = await getUserContext();
|
|
61
62
|
const cacheKey = this.buildCacheKey(`plan-${idPlan}`, {
|
|
63
|
+
id_wl,
|
|
62
64
|
id_account: String(id_account)
|
|
63
65
|
});
|
|
64
66
|
const cachedData = await this.cache.select(cacheKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/plans/services/plans.service.ts"],"sourcesContent":["import \"server-only\";\n\nimport { api, apiClient, getUserContext } from \"@greatapps/common/server\";\nimport { ApiError, buildQueryParams, PlanSchema } from \"@greatapps/common\";\nimport type {\n ApiPaginatedActionResult,\n PaginatedSuccessResult,\n Plan,\n SuccessResult,\n} from \"@greatapps/common\";\nimport greatCache from \"@greatapps/cache\";\n\nexport type ListPlansParams = {\n sort?: string;\n active?: boolean;\n search?: string;\n};\n\nconst PLANS_CACHE_TTL = 604800;\n\nclass PlansService {\n private cache = new greatCache({\n service: \"plans\",\n version: \"1.0.2\",\n domain: \"whitelabel-cache.greatapps.com.br\",\n ambient: process.env.NODE_ENV || \"development\",\n });\n\n private buildCacheKey(key: string, params?: Record<string, unknown>): string {\n const sort = params?.sort ?? \"id:ASC\";\n const active = params?.active ?? \"\";\n const search = params?.search ?? \"\";\n return `${key}-${sort}-${active}-${search}-v2`;\n }\n\n /**\n * Lista planos do whitelabel.\n * Exemplo:\n * GET /{id_wl}/plans?active=true&search=client&sort=id:ASC\n */\n async listPlans(\n params?: ListPlansParams,\n ): Promise<PaginatedSuccessResult<Plan>> {\n const { id_account } = await getUserContext();\n const cacheKey = this.buildCacheKey(\"plans\", {\n ...params,\n id_account,\n });\n\n const cachedData = await this.cache.select(cacheKey);\n\n if (cachedData.status == 1 && \"data\" in cachedData && cachedData.data) {\n const data = JSON.parse(cachedData.data) as Plan[];\n return { data, total: data.length, success: true };\n }\n\n const query = buildQueryParams({\n sort: params?.sort ?? \"id:ASC\",\n active: params?.active,\n search: params?.search,\n id_account: id_account,\n });\n const url = `/plans${query ? `?${query}` : \"\"}`;\n\n const response = await api.apps.get<ApiPaginatedActionResult<Plan[]>>(url);\n\n if (response.status === 0) {\n throw new ApiError(\n (response as { message?: string }).message || \"Erro ao listar planos\",\n \"LIST_PLANS_FAILED\",\n 400,\n );\n }\n\n const rawData = (response as { data?: unknown }).data;\n const data = Array.isArray(rawData)\n ? rawData.map((item) => PlanSchema.parse(item))\n : [];\n\n await this.cache.insert(cacheKey, JSON.stringify(data), PLANS_CACHE_TTL);\n\n return {\n data,\n total: response.total,\n success: true,\n } satisfies PaginatedSuccessResult<Plan>;\n }\n\n async findById(idPlan: number | string): Promise<SuccessResult<Plan>> {\n const { id_account } = await getUserContext();\n const cacheKey = this.buildCacheKey(`plan-${idPlan}`, {\n id_account: String(id_account),\n });\n\n const cachedData = await this.cache.select(cacheKey);\n\n if (cachedData.status == 1 && \"data\" in cachedData && cachedData.data) {\n const data = JSON.parse(cachedData.data) as Plan;\n return { data, success: true };\n }\n\n const query = buildQueryParams({ type: \"client\", id_account });\n\n const response = await api.apps.get<ApiPaginatedActionResult<Plan>>(\n `/plans/${idPlan}?${query}`,\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || \"Erro ao buscar plano\",\n \"FIND_PLAN_FAILED\",\n 400,\n );\n }\n\n if (!response.data?.length) {\n throw new ApiError(\"Plano não encontrado\", \"PLAN_NOT_FOUND\", 404);\n }\n\n const plan = PlanSchema.parse(response.data[0]);\n\n await this.cache.insert(cacheKey, JSON.stringify(plan), PLANS_CACHE_TTL);\n\n return {\n success: true,\n data: plan,\n };\n }\n}\n\nexport const plansService = new PlansService();\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,KAAgB,sBAAsB;AAC/C,SAAS,UAAU,kBAAkB,kBAAkB;AAOvD,OAAO,gBAAgB;AAQvB,MAAM,kBAAkB;AAExB,MAAM,aAAa;AAAA,EACT,QAAQ,IAAI,WAAW;AAAA,IAC7B,SAAS;AAAA,IACT,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,SAAS,QAAQ,IAAI,YAAY;AAAA,EACnC,CAAC;AAAA,EAEO,cAAc,KAAa,QAA0C;AAC3E,UAAM,OAAO,QAAQ,QAAQ;AAC7B,UAAM,SAAS,QAAQ,UAAU;AACjC,UAAM,SAAS,QAAQ,UAAU;AACjC,WAAO,GAAG,GAAG,IAAI,IAAI,IAAI,MAAM,IAAI,MAAM;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,UACJ,QACuC;AACvC,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/services/plans.service.ts"],"sourcesContent":["import \"server-only\";\n\nimport { api, apiClient, getUserContext } from \"@greatapps/common/server\";\nimport { ApiError, buildQueryParams, PlanSchema } from \"@greatapps/common\";\nimport type {\n ApiPaginatedActionResult,\n PaginatedSuccessResult,\n Plan,\n SuccessResult,\n} from \"@greatapps/common\";\nimport greatCache from \"@greatapps/cache\";\n\nexport type ListPlansParams = {\n sort?: string;\n active?: boolean;\n search?: string;\n};\n\nconst PLANS_CACHE_TTL = 604800;\n\nclass PlansService {\n private cache = new greatCache({\n service: \"plans\",\n version: \"1.0.2\",\n domain: \"whitelabel-cache.greatapps.com.br\",\n ambient: process.env.NODE_ENV || \"development\",\n });\n\n private buildCacheKey(key: string, params?: Record<string, unknown>): string {\n const sort = params?.sort ?? \"id:ASC\";\n const active = params?.active ?? \"\";\n const search = params?.search ?? \"\";\n return `${key}-${sort}-${active}-${search}-v2`;\n }\n\n /**\n * Lista planos do whitelabel.\n * Exemplo:\n * GET /{id_wl}/plans?active=true&search=client&sort=id:ASC\n */\n async listPlans(\n params?: ListPlansParams,\n ): Promise<PaginatedSuccessResult<Plan>> {\n const { id_wl, id_account } = await getUserContext();\n const cacheKey = this.buildCacheKey(\"plans\", {\n ...params,\n id_wl,\n id_account,\n });\n\n const cachedData = await this.cache.select(cacheKey);\n\n if (cachedData.status == 1 && \"data\" in cachedData && cachedData.data) {\n const data = JSON.parse(cachedData.data) as Plan[];\n return { data, total: data.length, success: true };\n }\n\n const query = buildQueryParams({\n sort: params?.sort ?? \"id:ASC\",\n active: params?.active,\n search: params?.search,\n id_account: id_account,\n });\n const url = `/plans${query ? `?${query}` : \"\"}`;\n\n const response = await api.apps.get<ApiPaginatedActionResult<Plan[]>>(url);\n\n if (response.status === 0) {\n throw new ApiError(\n (response as { message?: string }).message || \"Erro ao listar planos\",\n \"LIST_PLANS_FAILED\",\n 400,\n );\n }\n\n const rawData = (response as { data?: unknown }).data;\n const data = Array.isArray(rawData)\n ? rawData.map((item) => PlanSchema.parse(item))\n : [];\n\n await this.cache.insert(cacheKey, JSON.stringify(data), PLANS_CACHE_TTL);\n\n return {\n data,\n total: response.total,\n success: true,\n } satisfies PaginatedSuccessResult<Plan>;\n }\n\n async findById(idPlan: number | string): Promise<SuccessResult<Plan>> {\n const { id_wl, id_account } = await getUserContext();\n const cacheKey = this.buildCacheKey(`plan-${idPlan}`, {\n id_wl,\n id_account: String(id_account),\n });\n\n const cachedData = await this.cache.select(cacheKey);\n\n if (cachedData.status == 1 && \"data\" in cachedData && cachedData.data) {\n const data = JSON.parse(cachedData.data) as Plan;\n return { data, success: true };\n }\n\n const query = buildQueryParams({ type: \"client\", id_account });\n\n const response = await api.apps.get<ApiPaginatedActionResult<Plan>>(\n `/plans/${idPlan}?${query}`,\n );\n\n if (response.status === 0) {\n throw new ApiError(\n response.message || \"Erro ao buscar plano\",\n \"FIND_PLAN_FAILED\",\n 400,\n );\n }\n\n if (!response.data?.length) {\n throw new ApiError(\"Plano não encontrado\", \"PLAN_NOT_FOUND\", 404);\n }\n\n const plan = PlanSchema.parse(response.data[0]);\n\n await this.cache.insert(cacheKey, JSON.stringify(plan), PLAN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AU,KAAK,UAAU,IAAI,GAAG,eAAe;AAEvE,WAAO;AAAA,MACL,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAEO,MAAM,eAAe,IAAI,aAAa;","names":["data"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/plans/types/plan.type.ts"],"sourcesContent":["import z from 'zod';\nimport type { BillingPeriod } from '../../subscriptions/types/billing-period.type';\n\nexport const PlanItemSchema = z.object({\n id_addon: z.number(),\n quantity: z.number(),\n value: z.number(),\n});\n\nexport type PlanItem = z.infer<typeof PlanItemSchema>;\n\nexport const PlanSchema = z.object({\n id: z.number(),\n id_plan: z.number().optional(),\n name: z.string(),\n value: z.number().default(0),\n type: z.string().optional(),\n discount_semester: z.number().default(0),\n discount_annual: z.number().default(0),\n items: z.array(PlanItemSchema).optional().default([]),\n});\n\nexport type Plan = z.infer<typeof PlanSchema>;\n\n// ── UI Plan types (used by list-plans action and consumers) ──\n\nexport type PlanFeature = {\n icon: 'check' | 'x';\n text: string;\n disabled?: boolean;\n tooltip?: keyof PlanTooltips;\n};\n\nexport type PlanMainFeatures = {\n pages: string;\n domains: string;\n users: string;\n};\n\n/** Preços mensais equivalentes por período de cobrança (já com desconto aplicado). */\nexport type PlanPricingByPeriod = {\n monthly: number;\n semiannual: number;\n annual: number;\n};\n\nexport type UiPlan = {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/types/plan.type.ts"],"sourcesContent":["import z from 'zod';\nimport type { BillingPeriod } from '../../subscriptions/types/billing-period.type';\n\nexport const PlanItemSchema = z.object({\n id_addon: z.number(),\n quantity: z.number(),\n value: z.number(),\n});\n\nexport type PlanItem = z.infer<typeof PlanItemSchema>;\n\nexport const PlanSchema = z.object({\n id: z.number(),\n id_plan: z.number().optional(),\n name: z.string(),\n value: z.number().default(0),\n type: z.string().optional(),\n discount_semester: z.number().default(0),\n discount_annual: z.number().default(0),\n items: z.array(PlanItemSchema).optional().default([]),\n});\n\nexport type Plan = z.infer<typeof PlanSchema>;\n\n// ── UI Plan types (used by list-plans action and consumers) ──\n\nexport type PlanFeature = {\n icon: 'check' | 'x';\n text: string;\n disabled?: boolean;\n tooltip?: keyof PlanTooltips;\n};\n\nexport type PlanMainFeatures = {\n pages: string;\n domains: string;\n users: string;\n};\n\n/** Preços mensais equivalentes por período de cobrança (já com desconto aplicado). */\nexport type PlanPricingByPeriod = {\n monthly: number;\n semiannual: number;\n annual: number;\n};\n\nexport type UiPlan = {\n planId: number;\n name: string;\n isPopular?: boolean;\n isCurrentPlan?: boolean;\n currentPeriodicity?: BillingPeriod | null;\n mainFeatures: PlanMainFeatures;\n features: PlanFeature[];\n originalPrice: string;\n price: string;\n pricingByPeriod?: PlanPricingByPeriod;\n buttonVariant?: 'brand' | 'default';\n items: PlanItem[];\n};\n\nexport type PlanTooltips = {\n domains: string;\n users: string;\n sharePages: string;\n projectManagement: string;\n};\n"],"mappings":"AAAA,OAAO,OAAO;AAGP,MAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,UAAU,EAAE,OAAO;AAAA,EACnB,UAAU,EAAE,OAAO;AAAA,EACnB,OAAO,EAAE,OAAO;AAClB,CAAC;AAIM,MAAM,aAAa,EAAE,OAAO;AAAA,EACjC,IAAI,EAAE,OAAO;AAAA,EACb,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,MAAM,EAAE,OAAO;AAAA,EACf,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC;AAAA,EAC3B,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,mBAAmB,EAAE,OAAO,EAAE,QAAQ,CAAC;AAAA,EACvC,iBAAiB,EAAE,OAAO,EAAE,QAAQ,CAAC;AAAA,EACrC,OAAO,EAAE,MAAM,cAAc,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC;","names":[]}
|
|
@@ -28,28 +28,38 @@ function computePricingByPeriod(apiPlan) {
|
|
|
28
28
|
annual: round2(monthly * (1 - apiPlan.discount_annual / 100))
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function mapApiPlanToUiPlan(
|
|
32
|
-
const
|
|
33
|
-
const
|
|
31
|
+
function mapApiPlanToUiPlan(plan) {
|
|
32
|
+
const popular = plan.id === 2 || plan.id_plan === 2;
|
|
33
|
+
const buttonVariant = popular ? "brand" : "default";
|
|
34
|
+
const pricingByPeriod = computePricingByPeriod(plan);
|
|
34
35
|
const monthlyFinal = pricingByPeriod.monthly;
|
|
35
|
-
const lowerName =
|
|
36
|
+
const lowerName = plan.name.toLowerCase();
|
|
36
37
|
const hasProjectAndOnboarding = lowerName.includes("ag\xEAncia") || lowerName.includes("agencia");
|
|
37
38
|
const features = [
|
|
38
39
|
...BASE_FEATURES,
|
|
39
40
|
hasProjectAndOnboarding ? { icon: "check", text: "Reuni\xE3o de Onboarding" } : { icon: "x", text: "Reuni\xE3o de Onboarding", disabled: true },
|
|
40
|
-
hasProjectAndOnboarding ? {
|
|
41
|
+
hasProjectAndOnboarding ? {
|
|
42
|
+
icon: "check",
|
|
43
|
+
text: "Gest\xE3o de projetos",
|
|
44
|
+
tooltip: "projectManagement"
|
|
45
|
+
} : {
|
|
46
|
+
icon: "x",
|
|
47
|
+
text: "Gest\xE3o de projetos",
|
|
48
|
+
disabled: true,
|
|
49
|
+
tooltip: "projectManagement"
|
|
50
|
+
}
|
|
41
51
|
];
|
|
42
52
|
return {
|
|
43
|
-
|
|
44
|
-
name:
|
|
45
|
-
isPopular,
|
|
53
|
+
planId: plan.id,
|
|
54
|
+
name: plan.name,
|
|
55
|
+
isPopular: popular,
|
|
46
56
|
buttonVariant,
|
|
47
|
-
mainFeatures: buildMainFeaturesFromItems(
|
|
57
|
+
mainFeatures: buildMainFeaturesFromItems(plan.items),
|
|
48
58
|
features,
|
|
49
59
|
originalPrice: formatCurrencyNumber(monthlyFinal),
|
|
50
60
|
price: formatCurrencyNumber(monthlyFinal),
|
|
51
61
|
pricingByPeriod,
|
|
52
|
-
items:
|
|
62
|
+
items: plan.items
|
|
53
63
|
};
|
|
54
64
|
}
|
|
55
65
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/plans/utils/map-api-plan-to-ui.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/plans/utils/map-api-plan-to-ui.ts"],"sourcesContent":["import type {\n Plan,\n PlanFeature,\n PlanMainFeatures,\n PlanPricingByPeriod,\n UiPlan,\n} from \"../types/plan.type\";\nimport { ADDON_IDS } from \"../../subscriptions/constants/addons.constants\";\nimport { formatCurrencyNumber } from \"../../../utils/format/currency\";\n\nexport type PlanBillingPeriod = \"monthly\" | \"semiannual\" | \"annual\";\n\nconst BASE_FEATURES: PlanFeature[] = [\n { icon: \"check\", text: \"Visitas ilimitadas\" },\n { icon: \"check\", text: \"Leads ilimitadas\" },\n { icon: \"check\", text: \"Compartilhar páginas\", tooltip: \"sharePages\" },\n { icon: \"check\", text: \"Hospedagem inclusa\" },\n { icon: \"check\", text: \"SSL (HTTPS) + CDN\" },\n { icon: \"check\", text: \"Templates Free\" },\n];\n\nfunction buildMainFeaturesFromItems(items: Plan[\"items\"]): PlanMainFeatures {\n const pagesItem = items.find((i) => i.id_addon === ADDON_IDS.PAGES);\n const domainsItem = items.find((i) => i.id_addon === ADDON_IDS.DOMAINS);\n\n const pagesQty = pagesItem?.quantity ?? 0;\n const domainsQty = domainsItem?.quantity ?? 1;\n\n return {\n pages:\n pagesQty === 0\n ? \"Páginas ilimitadas\"\n : pagesQty === 1\n ? \"1 página\"\n : `${pagesQty} páginas`,\n domains:\n domainsQty >= 999\n ? \"Domínios ilimitados\"\n : domainsQty === 1\n ? \"1 domínio externo\"\n : `${domainsQty} domínios externos`,\n users: \"Usuários ilimitados\",\n };\n}\n\nfunction computePricingByPeriod(apiPlan: Plan): PlanPricingByPeriod {\n const monthly = apiPlan.value;\n const round2 = (n: number) => Math.round(n * 100) / 100;\n return {\n monthly,\n semiannual: round2(monthly * (1 - apiPlan.discount_semester / 100)),\n annual: round2(monthly * (1 - apiPlan.discount_annual / 100)),\n };\n}\n\nexport function mapApiPlanToUiPlan(plan: Plan): UiPlan {\n const popular = plan.id === 2 || plan.id_plan === 2;\n const buttonVariant = popular ? \"brand\" : \"default\";\n\n const pricingByPeriod = computePricingByPeriod(plan);\n const monthlyFinal = pricingByPeriod.monthly;\n\n const lowerName = plan.name.toLowerCase();\n const hasProjectAndOnboarding =\n lowerName.includes(\"agência\") || lowerName.includes(\"agencia\");\n\n const features: PlanFeature[] = [\n ...BASE_FEATURES,\n hasProjectAndOnboarding\n ? { icon: \"check\", text: \"Reunião de Onboarding\" }\n : { icon: \"x\", text: \"Reunião de Onboarding\", disabled: true },\n hasProjectAndOnboarding\n ? {\n icon: \"check\",\n text: \"Gestão de projetos\",\n tooltip: \"projectManagement\",\n }\n : {\n icon: \"x\",\n text: \"Gestão de projetos\",\n disabled: true,\n tooltip: \"projectManagement\",\n },\n ];\n\n return {\n planId: plan.id,\n name: plan.name,\n isPopular: popular,\n buttonVariant,\n mainFeatures: buildMainFeaturesFromItems(plan.items),\n features,\n originalPrice: formatCurrencyNumber(monthlyFinal),\n price: formatCurrencyNumber(monthlyFinal),\n pricingByPeriod,\n items: plan.items,\n };\n}\n"],"mappings":"AAOA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AAIrC,MAAM,gBAA+B;AAAA,EACnC,EAAE,MAAM,SAAS,MAAM,qBAAqB;AAAA,EAC5C,EAAE,MAAM,SAAS,MAAM,mBAAmB;AAAA,EAC1C,EAAE,MAAM,SAAS,MAAM,2BAAwB,SAAS,aAAa;AAAA,EACrE,EAAE,MAAM,SAAS,MAAM,qBAAqB;AAAA,EAC5C,EAAE,MAAM,SAAS,MAAM,oBAAoB;AAAA,EAC3C,EAAE,MAAM,SAAS,MAAM,iBAAiB;AAC1C;AAEA,SAAS,2BAA2B,OAAwC;AAC1E,QAAM,YAAY,MAAM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AAAA,IACb,MAAM,KAAK;AAAA,IACX,WAAW;AAAA,IACX;AAAA,IACA,cAAc,2BAA2B,KAAK,KAAK;AAAA,IACnD;AAAA,IACA,eAAe,qBAAqB,YAAY;AAAA,IAChD,OAAO,qBAAqB,YAAY;AAAA,IACxC;AAAA,IACA,OAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { projectsService } from "../services/projects.service";
|
|
4
|
+
async function createProjectAction(data) {
|
|
5
|
+
return safeServerAction(() => projectsService.create(data));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
createProjectAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=create-project.action.mjs.map
|
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { projectsService } from "../services/projects.service";
|
|
4
|
+
async function deleteProjectAction(projectId, moveToProjectId) {
|
|
5
|
+
return safeServerAction(() => projectsService.delete(projectId, moveToProjectId));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
deleteProjectAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=delete-project.action.mjs.map
|
|
@@ -0,0 +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":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { projectsService } from "../services/projects.service";
|
|
4
|
+
async function findProjectAction(projectId) {
|
|
5
|
+
return safeServerAction(() => projectsService.findById(projectId));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
findProjectAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=find-project.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/actions/find-project.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectsService } from '../services/projects.service';\n\nexport async function findProjectAction(projectId: number) {\n return safeServerAction(() => projectsService.findById(projectId));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEhC,eAAsB,kBAAkB,WAAmB;AACzD,SAAO,iBAAiB,MAAM,gBAAgB,SAAS,SAAS,CAAC;AACnE;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { projectsService } from "../services/projects.service";
|
|
4
|
+
async function listProjectsAction(params) {
|
|
5
|
+
return safeServerAction(() => projectsService.list(params));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
listProjectsAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=list-projects.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/actions/list-projects.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { projectsService } from '../services/projects.service';\n\nexport interface ListProjectsActionParams {\n page?: number;\n limit?: number;\n sort?: string;\n search?: string;\n deleted?: number;\n}\n\nexport async function listProjectsAction(params?: ListProjectsActionParams) {\n return safeServerAction(() => projectsService.list(params));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAUhC,eAAsB,mBAAmB,QAAmC;AAC1E,SAAO,iBAAiB,MAAM,gBAAgB,KAAK,MAAM,CAAC;AAC5D;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
+
import { projectsService } from "../services/projects.service";
|
|
4
|
+
async function updateProjectAction(projectId, data) {
|
|
5
|
+
return safeServerAction(() => projectsService.update(projectId, data));
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
updateProjectAction
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=update-project.action.mjs.map
|
|
@@ -0,0 +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":[]}
|
|
@@ -3,21 +3,24 @@ import { useQueryClient, useMutation } from "@tanstack/react-query";
|
|
|
3
3
|
import { addProjectUserAction } from "../actions/add-project-user.action";
|
|
4
4
|
import { LIST_PROJECT_USERS_BASE_KEY } from "./list-project-users.hook";
|
|
5
5
|
import { LIST_ALL_ACCOUNT_USERS_BASE_KEY } from "./list-all-account-users.hook";
|
|
6
|
+
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
6
7
|
function useAddProjectUser(projectId) {
|
|
7
8
|
const queryClient = useQueryClient();
|
|
9
|
+
const allAccountUsersKey = useAuthQueryKey([...LIST_ALL_ACCOUNT_USERS_BASE_KEY()]);
|
|
10
|
+
const projectUsersKey = useAuthQueryKey([...LIST_PROJECT_USERS_BASE_KEY(projectId)]);
|
|
8
11
|
return useMutation({
|
|
9
|
-
mutationFn: (
|
|
10
|
-
onMutate: async (
|
|
11
|
-
await queryClient.cancelQueries({ queryKey:
|
|
12
|
-
await queryClient.cancelQueries({ queryKey:
|
|
12
|
+
mutationFn: (targetUserId) => addProjectUserAction({ projectId, users: [targetUserId] }),
|
|
13
|
+
onMutate: async (targetUserId) => {
|
|
14
|
+
await queryClient.cancelQueries({ queryKey: allAccountUsersKey });
|
|
15
|
+
await queryClient.cancelQueries({ queryKey: projectUsersKey });
|
|
13
16
|
const prevAccountUsers = queryClient.getQueriesData({
|
|
14
|
-
queryKey:
|
|
17
|
+
queryKey: allAccountUsersKey
|
|
15
18
|
});
|
|
16
19
|
const prevProjectUsers = queryClient.getQueriesData({
|
|
17
|
-
queryKey:
|
|
20
|
+
queryKey: projectUsersKey
|
|
18
21
|
});
|
|
19
22
|
queryClient.setQueriesData(
|
|
20
|
-
{ queryKey:
|
|
23
|
+
{ queryKey: allAccountUsersKey, exact: false },
|
|
21
24
|
(old) => {
|
|
22
25
|
if (!old) return old;
|
|
23
26
|
return {
|
|
@@ -25,14 +28,14 @@ function useAddProjectUser(projectId) {
|
|
|
25
28
|
pages: old.pages.map((page) => ({
|
|
26
29
|
...page,
|
|
27
30
|
data: page.data.map(
|
|
28
|
-
(u) => u.id ===
|
|
31
|
+
(u) => u.id === targetUserId ? { ...u, in_project: true } : u
|
|
29
32
|
)
|
|
30
33
|
}))
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
);
|
|
34
37
|
queryClient.setQueriesData(
|
|
35
|
-
{ queryKey:
|
|
38
|
+
{ queryKey: projectUsersKey, exact: false },
|
|
36
39
|
(old) => {
|
|
37
40
|
if (!old?.pages.length) return old;
|
|
38
41
|
return {
|
|
@@ -45,13 +48,13 @@ function useAddProjectUser(projectId) {
|
|
|
45
48
|
);
|
|
46
49
|
return { prevAccountUsers, prevProjectUsers };
|
|
47
50
|
},
|
|
48
|
-
onError: (_err,
|
|
51
|
+
onError: (_err, _targetUserId, ctx) => {
|
|
49
52
|
ctx?.prevAccountUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));
|
|
50
53
|
ctx?.prevProjectUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));
|
|
51
54
|
},
|
|
52
55
|
onSettled: () => {
|
|
53
|
-
queryClient.invalidateQueries({ queryKey:
|
|
54
|
-
queryClient.invalidateQueries({ queryKey:
|
|
56
|
+
queryClient.invalidateQueries({ queryKey: projectUsersKey });
|
|
57
|
+
queryClient.invalidateQueries({ queryKey: allAccountUsersKey });
|
|
55
58
|
}
|
|
56
59
|
});
|
|
57
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/projects/hooks/add-project-user.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQueryClient, useMutation, InfiniteData } from '@tanstack/react-query';\nimport { addProjectUserAction } from '../actions/add-project-user.action';\nimport { LIST_PROJECT_USERS_BASE_KEY } from './list-project-users.hook';\nimport { LIST_ALL_ACCOUNT_USERS_BASE_KEY } from './list-all-account-users.hook';\nimport type { UsersPage, AccountUser, ProjectUser } from '../types';\n\nexport function useAddProjectUser(projectId: number) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/projects/hooks/add-project-user.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQueryClient, useMutation, InfiniteData } from '@tanstack/react-query';\nimport { addProjectUserAction } from '../actions/add-project-user.action';\nimport { LIST_PROJECT_USERS_BASE_KEY } from './list-project-users.hook';\nimport { LIST_ALL_ACCOUNT_USERS_BASE_KEY } from './list-all-account-users.hook';\nimport type { UsersPage, AccountUser, ProjectUser } from '../types';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\n\nexport function useAddProjectUser(projectId: number) {\n const queryClient = useQueryClient();\n const allAccountUsersKey = useAuthQueryKey([...LIST_ALL_ACCOUNT_USERS_BASE_KEY()]);\n const projectUsersKey = useAuthQueryKey([...LIST_PROJECT_USERS_BASE_KEY(projectId)]);\n\n return useMutation({\n mutationFn: (targetUserId: number) =>\n addProjectUserAction({ projectId, users: [targetUserId] }),\n\n onMutate: async (targetUserId) => {\n await queryClient.cancelQueries({ queryKey: allAccountUsersKey });\n await queryClient.cancelQueries({ queryKey: projectUsersKey });\n\n const prevAccountUsers = queryClient.getQueriesData<InfiniteData<UsersPage<AccountUser>>>({\n queryKey: allAccountUsersKey,\n });\n const prevProjectUsers = queryClient.getQueriesData<InfiniteData<UsersPage<ProjectUser>>>({\n queryKey: projectUsersKey,\n });\n\n queryClient.setQueriesData<InfiniteData<UsersPage<AccountUser>>>(\n { queryKey: allAccountUsersKey, exact: false },\n (old) => {\n if (!old) return old;\n return {\n ...old,\n pages: old.pages.map((page) => ({\n ...page,\n data: page.data.map((u) =>\n u.id === targetUserId ? { ...u, in_project: true } : u\n ),\n })),\n };\n }\n );\n\n queryClient.setQueriesData<InfiniteData<UsersPage<ProjectUser>>>(\n { queryKey: projectUsersKey, exact: false },\n (old) => {\n if (!old?.pages.length) return old;\n return {\n ...old,\n pages: old.pages.map((page, i) =>\n i === 0 ? { ...page, total: page.total + 1 } : page\n ),\n };\n }\n );\n\n return { prevAccountUsers, prevProjectUsers };\n },\n\n onError: (_err, _targetUserId, ctx) => {\n ctx?.prevAccountUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));\n ctx?.prevProjectUsers.forEach(([key, data]) => queryClient.setQueryData(key, data));\n },\n\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey: projectUsersKey });\n queryClient.invalidateQueries({ queryKey: allAccountUsersKey });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB,mBAAiC;AAC1D,SAAS,4BAA4B;AACrC,SAAS,mCAAmC;AAC5C,SAAS,uCAAuC;AAEhD,SAAS,uBAAuB;AAEzB,SAAS,kBAAkB,WAAmB;AACnD,QAAM,cAAc,eAAe;AACnC,QAAM,qBAAqB,gBAAgB,CAAC,GAAG,gCAAgC,CAAC,CAAC;AACjF,QAAM,kBAAkB,gBAAgB,CAAC,GAAG,4BAA4B,SAAS,CAAC,CAAC;AAEnF,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,iBACX,qBAAqB,EAAE,WAAW,OAAO,CAAC,YAAY,EAAE,CAAC;AAAA,IAE3D,UAAU,OAAO,iBAAiB;AAChC,YAAM,YAAY,cAAc,EAAE,UAAU,mBAAmB,CAAC;AAChE,YAAM,YAAY,cAAc,EAAE,UAAU,gBAAgB,CAAC;AAE7D,YAAM,mBAAmB,YAAY,eAAqD;AAAA,QACxF,UAAU;AAAA,MACZ,CAAC;AACD,YAAM,mBAAmB,YAAY,eAAqD;AAAA,QACxF,UAAU;AAAA,MACZ,CAAC;AAED,kBAAY;AAAA,QACV,EAAE,UAAU,oBAAoB,OAAO,MAAM;AAAA,QAC7C,CAAC,QAAQ;AACP,cAAI,CAAC,IAAK,QAAO;AACjB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,OAAO,IAAI,MAAM,IAAI,CAAC,UAAU;AAAA,cAC9B,GAAG;AAAA,cACH,MAAM,KAAK,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