@greatapps/common 1.1.523 → 1.1.525
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 +4 -10
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +1 -3
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/sections/ChangeEmailModal.mjs +1 -3
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -1
- package/dist/components/account/sections/ChangePhoneModal.mjs +1 -3
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -1
- package/dist/components/account/sections/MyProfileSection.mjs +1 -2
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
- package/dist/components/embeds/EmbedWidgets.mjs +1 -3
- package/dist/components/embeds/EmbedWidgets.mjs.map +1 -1
- package/dist/components/layouts/AppMobileNavBar.mjs +1 -3
- package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -1
- package/dist/components/layouts/AppNavBar.mjs +8 -4
- package/dist/components/layouts/AppNavBar.mjs.map +1 -1
- package/dist/components/layouts/NavBar.mjs +9 -10
- package/dist/components/layouts/NavBar.mjs.map +1 -1
- package/dist/components/layouts/NotificationsPopover.mjs +2 -5
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -1
- package/dist/components/layouts/ProfilePopover.mjs +2 -4
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -1
- package/dist/components/layouts/SideBarNavigation.mjs +1 -4
- package/dist/components/layouts/SideBarNavigation.mjs.map +1 -1
- package/dist/components/modals/BuyCreditsModal.mjs +9 -26
- package/dist/components/modals/BuyCreditsModal.mjs.map +1 -1
- package/dist/components/modals/cards/AddCardModal.mjs +1 -3
- 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 +6 -7
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +19 -39
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -1
- package/dist/components/navigation/types.mjs +1 -0
- package/dist/components/navigation/types.mjs.map +1 -0
- package/dist/components/pages/NotFoundPage.mjs +2 -2
- package/dist/components/pages/NotFoundPage.mjs.map +1 -1
- package/dist/components/ui/buttons/Button.mjs +2 -7
- 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 +2 -4
- package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -1
- package/dist/components/ui/data-display/UserAvatar.mjs +2 -6
- package/dist/components/ui/data-display/UserAvatar.mjs.map +1 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs +1 -4
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -1
- package/dist/components/ui/feedback/Toast.mjs +2 -7
- 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 +6 -8
- package/dist/components/ui/overlay/Sheet.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageUpload.mjs +1 -2
- package/dist/components/widgets/ImageUpload/ImageUpload.mjs.map +1 -1
- package/dist/components/widgets/notifications/NotificationCard.mjs +1 -4
- package/dist/components/widgets/notifications/NotificationCard.mjs.map +1 -1
- package/dist/enums/AccountSectionType.mjs +0 -1
- package/dist/enums/AccountSectionType.mjs.map +1 -1
- package/dist/index.mjs +8 -90
- package/dist/index.mjs.map +1 -1
- package/dist/modules/accounts/hooks/current-account.hook.mjs +2 -5
- package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useAccountManagement.mjs +9 -19
- package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useCurrencies.mjs +1 -3
- package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useTimezones.mjs +1 -3
- package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -1
- package/dist/modules/auth/hooks/useUserQuery.mjs +6 -15
- package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -1
- package/dist/modules/cards/hooks/cards.hook.mjs +3 -11
- package/dist/modules/cards/hooks/cards.hook.mjs.map +1 -1
- package/dist/modules/cards/hooks/create-card.hook.mjs +2 -13
- package/dist/modules/cards/hooks/create-card.hook.mjs.map +1 -1
- package/dist/modules/cards/services/cards.service.mjs +4 -45
- package/dist/modules/cards/services/cards.service.mjs.map +1 -1
- package/dist/modules/cards/types.mjs +3 -11
- package/dist/modules/cards/types.mjs.map +1 -1
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +1 -3
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -1
- package/dist/modules/plans/hooks/list-plans.hook.mjs +1 -3
- package/dist/modules/plans/hooks/list-plans.hook.mjs.map +1 -1
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs +2 -4
- package/dist/modules/plans/hooks/use-plan-by-id.hook.mjs.map +1 -1
- package/dist/modules/plans/services/plans.service.mjs +2 -4
- 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 +10 -20
- package/dist/modules/plans/utils/map-api-plan-to-ui.mjs.map +1 -1
- package/dist/modules/projects/hooks/add-project-user.hook.mjs +12 -15
- package/dist/modules/projects/hooks/add-project-user.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs +1 -3
- package/dist/modules/projects/hooks/list-all-account-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs +1 -3
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-project-users.hook.mjs +1 -3
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs +12 -15
- package/dist/modules/projects/hooks/remove-project-user.hook.mjs.map +1 -1
- package/dist/modules/projects/types.mjs +4 -19
- package/dist/modules/projects/types.mjs.map +1 -1
- package/dist/modules/subscriptions/constants/query-keys.constants.mjs +0 -2
- package/dist/modules/subscriptions/constants/query-keys.constants.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +2 -5
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +1 -3
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs +3 -6
- package/dist/modules/subscriptions/hooks/update-subscription-plan.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/types/calculate-subscription.type.mjs +2 -29
- package/dist/modules/subscriptions/types/calculate-subscription.type.mjs.map +1 -1
- package/dist/modules/subscriptions/utils/periodicity.mjs +0 -7
- package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -1
- package/dist/modules/users/action/list-messages.action.mjs +2 -14
- package/dist/modules/users/action/list-messages.action.mjs.map +1 -1
- package/dist/modules/users/hooks/messages.hook.mjs +4 -9
- 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 +4 -6
- 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 +0 -5
- package/dist/providers/whitelabel.provider.mjs.map +1 -1
- package/dist/server.mjs +0 -14
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/widgets/ImageUpload/ImageCropModal.tsx +10 -37
- package/dist/components/account/sections/TokenSection.mjs +0 -72
- package/dist/components/account/sections/TokenSection.mjs.map +0 -1
- package/dist/components/embeds/ClarityEmbed.mjs +0 -55
- package/dist/components/embeds/ClarityEmbed.mjs.map +0 -1
- package/dist/hooks/useAuthQueryKey.mjs +0 -23
- package/dist/hooks/useAuthQueryKey.mjs.map +0 -1
- package/dist/infra/utils/array.mjs +0 -34
- package/dist/infra/utils/array.mjs.map +0 -1
- package/dist/modules/accounts/actions/get-account-token.action.mjs +0 -10
- package/dist/modules/accounts/actions/get-account-token.action.mjs.map +0 -1
- package/dist/modules/accounts/hooks/use-account-token.hook.mjs +0 -15
- package/dist/modules/accounts/hooks/use-account-token.hook.mjs.map +0 -1
- package/dist/modules/accounts/services/account-token.service.mjs +0 -32
- package/dist/modules/accounts/services/account-token.service.mjs.map +0 -1
- package/dist/modules/cards/actions/delete-card.action.mjs +0 -10
- package/dist/modules/cards/actions/delete-card.action.mjs.map +0 -1
- package/dist/modules/cards/actions/find-card-by-id.action.mjs +0 -10
- package/dist/modules/cards/actions/find-card-by-id.action.mjs.map +0 -1
- package/dist/modules/cards/actions/set-default-card.action.mjs +0 -10
- package/dist/modules/cards/actions/set-default-card.action.mjs.map +0 -1
- package/dist/modules/cards/hooks/card-by-id.hook.mjs +0 -22
- package/dist/modules/cards/hooks/card-by-id.hook.mjs.map +0 -1
- package/dist/modules/cards/hooks/delete-card.hook.mjs +0 -50
- package/dist/modules/cards/hooks/delete-card.hook.mjs.map +0 -1
- package/dist/modules/cards/hooks/set-default-card.hook.mjs +0 -51
- package/dist/modules/cards/hooks/set-default-card.hook.mjs.map +0 -1
- package/dist/modules/projects/actions/create-project.action.mjs +0 -10
- package/dist/modules/projects/actions/create-project.action.mjs.map +0 -1
- package/dist/modules/projects/actions/delete-project.action.mjs +0 -10
- package/dist/modules/projects/actions/delete-project.action.mjs.map +0 -1
- package/dist/modules/projects/actions/find-project.action.mjs +0 -10
- package/dist/modules/projects/actions/find-project.action.mjs.map +0 -1
- package/dist/modules/projects/actions/list-projects.action.mjs +0 -10
- package/dist/modules/projects/actions/list-projects.action.mjs.map +0 -1
- package/dist/modules/projects/actions/update-project.action.mjs +0 -10
- package/dist/modules/projects/actions/update-project.action.mjs.map +0 -1
- package/dist/modules/projects/hooks/create-project.hook.mjs +0 -71
- package/dist/modules/projects/hooks/create-project.hook.mjs.map +0 -1
- package/dist/modules/projects/hooks/delete-project.hook.mjs +0 -53
- package/dist/modules/projects/hooks/delete-project.hook.mjs.map +0 -1
- package/dist/modules/projects/hooks/find-project.hook.mjs +0 -19
- package/dist/modules/projects/hooks/find-project.hook.mjs.map +0 -1
- package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs +0 -39
- package/dist/modules/projects/hooks/list-infinite-projects.hook.mjs.map +0 -1
- package/dist/modules/projects/hooks/list-projects.hook.mjs +0 -22
- package/dist/modules/projects/hooks/list-projects.hook.mjs.map +0 -1
- package/dist/modules/projects/hooks/update-project.hook.mjs +0 -70
- package/dist/modules/projects/hooks/update-project.hook.mjs.map +0 -1
- package/dist/modules/projects/services/projects.service.mjs +0 -99
- package/dist/modules/projects/services/projects.service.mjs.map +0 -1
|
@@ -1,32 +0,0 @@
|
|
|
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 AccountTokenService {
|
|
6
|
-
async getOrCreateToken() {
|
|
7
|
-
const { id_account } = await getUserContext();
|
|
8
|
-
const listResponse = await api.apps.get(
|
|
9
|
-
`/accounts/${id_account}/tokens?active=true&id_product=1&limit=1`
|
|
10
|
-
);
|
|
11
|
-
if (listResponse.status === 1 && listResponse.data?.length) {
|
|
12
|
-
return listResponse.data[0].token;
|
|
13
|
-
}
|
|
14
|
-
const createResponse = await api.apps.post(
|
|
15
|
-
`/accounts/${id_account}/tokens`,
|
|
16
|
-
{ name: "GreatPages", active: true, id_product: 1 }
|
|
17
|
-
);
|
|
18
|
-
if (createResponse.status === 0 || !createResponse.data?.length) {
|
|
19
|
-
throw new ApiError(
|
|
20
|
-
createResponse.message || "Erro ao criar token da conta",
|
|
21
|
-
"CREATE_TOKEN_FAILED",
|
|
22
|
-
400
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
return createResponse.data[0].token;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const accountTokenService = new AccountTokenService();
|
|
29
|
-
export {
|
|
30
|
-
accountTokenService
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=account-token.service.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/accounts/services/account-token.service.ts"],"sourcesContent":["import 'server-only';\n\nimport { api } from '../../../infra/api/client';\nimport { ApiError } from '../../../infra/api/types';\nimport { getUserContext } from '../../auth/utils/get-user-context';\n\ninterface AccountToken {\n token: string;\n}\n\ninterface ListTokensResponse {\n status: 0 | 1;\n message?: string;\n data?: AccountToken[];\n}\n\ninterface CreateTokenResponse {\n status: 0 | 1;\n message?: string;\n data?: AccountToken[];\n}\n\nclass AccountTokenService {\n async getOrCreateToken(): Promise<string> {\n const { id_account } = await getUserContext();\n\n const listResponse = await api.apps.get<ListTokensResponse>(\n `/accounts/${id_account}/tokens?active=true&id_product=1&limit=1`\n );\n\n if (listResponse.status === 1 && listResponse.data?.length) {\n return listResponse.data[0].token;\n }\n\n const createResponse = await api.apps.post<CreateTokenResponse>(\n `/accounts/${id_account}/tokens`,\n { name: 'GreatPages', active: true, id_product: 1 }\n );\n\n if (createResponse.status === 0 || !createResponse.data?.length) {\n throw new ApiError(\n createResponse.message || 'Erro ao criar token da conta',\n 'CREATE_TOKEN_FAILED',\n 400\n );\n }\n\n return createResponse.data[0].token;\n }\n}\n\nexport const accountTokenService = new AccountTokenService();\n"],"mappings":"AAAA,OAAO;AAEP,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAkB/B,MAAM,oBAAoB;AAAA,EACxB,MAAM,mBAAoC;AACxC,UAAM,EAAE,WAAW,IAAI,MAAM,eAAe;AAE5C,UAAM,eAAe,MAAM,IAAI,KAAK;AAAA,MAClC,aAAa,UAAU;AAAA,IACzB;AAEA,QAAI,aAAa,WAAW,KAAK,aAAa,MAAM,QAAQ;AAC1D,aAAO,aAAa,KAAK,CAAC,EAAE;AAAA,IAC9B;AAEA,UAAM,iBAAiB,MAAM,IAAI,KAAK;AAAA,MACpC,aAAa,UAAU;AAAA,MACvB,EAAE,MAAM,cAAc,QAAQ,MAAM,YAAY,EAAE;AAAA,IACpD;AAEA,QAAI,eAAe,WAAW,KAAK,CAAC,eAAe,MAAM,QAAQ;AAC/D,YAAM,IAAI;AAAA,QACR,eAAe,WAAW;AAAA,QAC1B;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,eAAe,KAAK,CAAC,EAAE;AAAA,EAChC;AACF;AAEO,MAAM,sBAAsB,IAAI,oBAAoB;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
-
import { cardsService } from "../services/cards.service";
|
|
4
|
-
async function deleteCardAction(id) {
|
|
5
|
-
return safeServerAction(() => cardsService.deleteCard(id));
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
deleteCardAction
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=delete-card.action.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/cards/actions/delete-card.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { cardsService } from '../services/cards.service';\n\nexport async function deleteCardAction(id: string) {\n return safeServerAction(() => cardsService.deleteCard(id));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,iBAAiB,IAAY;AACjD,SAAO,iBAAiB,MAAM,aAAa,WAAW,EAAE,CAAC;AAC3D;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
-
import { cardsService } from "../services/cards.service";
|
|
4
|
-
async function findCardByIdAction(id) {
|
|
5
|
-
return safeServerAction(() => cardsService.findCardById(id));
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
findCardByIdAction
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=find-card-by-id.action.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/cards/actions/find-card-by-id.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { cardsService } from '../services/cards.service';\n\nexport async function findCardByIdAction(id: number) {\n return safeServerAction(() => cardsService.findCardById(id));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,mBAAmB,IAAY;AACnD,SAAO,iBAAiB,MAAM,aAAa,aAAa,EAAE,CAAC;AAC7D;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use server";
|
|
2
|
-
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
|
-
import { cardsService } from "../services/cards.service";
|
|
4
|
-
async function setDefaultCardAction(cardId) {
|
|
5
|
-
return safeServerAction(() => cardsService.setDefaultCard(cardId));
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
setDefaultCardAction
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=set-default-card.action.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/cards/actions/set-default-card.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { cardsService } from '../services/cards.service';\n\nexport async function setDefaultCardAction(cardId: string) {\n return safeServerAction(() => cardsService.setDefaultCard(cardId));\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,oBAAoB;AAE7B,eAAsB,qBAAqB,QAAgB;AACzD,SAAO,iBAAiB,MAAM,aAAa,eAAe,MAAM,CAAC;AACnE;","names":[]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { withAction } from "../../../utils/withAction";
|
|
4
|
-
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
5
|
-
import { useAuth } from "../../../providers/auth.provider";
|
|
6
|
-
function useCardById(id) {
|
|
7
|
-
const { account } = useAuth();
|
|
8
|
-
const isVindi = account?.gateway === "vindi";
|
|
9
|
-
const cardKey = useAuthQueryKey(["card", id]);
|
|
10
|
-
return useQuery({
|
|
11
|
-
queryKey: cardKey,
|
|
12
|
-
queryFn: async () => {
|
|
13
|
-
const { findCardByIdAction } = await import("../actions/find-card-by-id.action");
|
|
14
|
-
return withAction(findCardByIdAction)(id);
|
|
15
|
-
},
|
|
16
|
-
enabled: id != null && !isVindi
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
useCardById
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=card-by-id.hook.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/cards/hooks/card-by-id.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { useAuth } from '../../../providers/auth.provider';\n\nexport function useCardById(id: number | undefined) {\n const { account } = useAuth();\n const isVindi = account?.gateway === 'vindi';\n const cardKey = useAuthQueryKey(['card', id]);\n\n return useQuery({\n queryKey: cardKey,\n queryFn: async () => {\n const { findCardByIdAction } = await import('../actions/find-card-by-id.action');\n return withAction(findCardByIdAction)(id!);\n },\n enabled: id != null && !isVindi,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,eAAe;AAEjB,SAAS,YAAY,IAAwB;AAClD,QAAM,EAAE,QAAQ,IAAI,QAAQ;AAC5B,QAAM,UAAU,SAAS,YAAY;AACrC,QAAM,UAAU,gBAAgB,CAAC,QAAQ,EAAE,CAAC;AAE5C,SAAO,SAAS;AAAA,IACd,UAAU;AAAA,IACV,SAAS,YAAY;AACnB,YAAM,EAAE,mBAAmB,IAAI,MAAM,OAAO,mCAAmC;AAC/E,aAAO,WAAW,kBAAkB,EAAE,EAAG;AAAA,IAC3C;AAAA,IACA,SAAS,MAAM,QAAQ,CAAC;AAAA,EAC1B,CAAC;AACH;","names":[]}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
-
import { withAction } from "../../../utils/withAction";
|
|
4
|
-
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
5
|
-
import { CARDS_QUERY_KEY } from "./cards.hook";
|
|
6
|
-
function useDeleteCard() {
|
|
7
|
-
const queryClient = useQueryClient();
|
|
8
|
-
const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);
|
|
9
|
-
const cardKey = useAuthQueryKey(["card"]);
|
|
10
|
-
return useMutation({
|
|
11
|
-
mutationFn: async (id) => {
|
|
12
|
-
const { deleteCardAction } = await import("../actions/delete-card.action");
|
|
13
|
-
return withAction(deleteCardAction)(id);
|
|
14
|
-
},
|
|
15
|
-
onMutate: async (id) => {
|
|
16
|
-
await queryClient.cancelQueries({ queryKey: cardsKey });
|
|
17
|
-
const previousQueries = queryClient.getQueriesData({
|
|
18
|
-
queryKey: cardsKey
|
|
19
|
-
});
|
|
20
|
-
queryClient.setQueriesData(
|
|
21
|
-
{ queryKey: cardsKey },
|
|
22
|
-
(old) => {
|
|
23
|
-
if (!old?.data) return old;
|
|
24
|
-
return {
|
|
25
|
-
...old,
|
|
26
|
-
data: old.data.map(
|
|
27
|
-
(card) => card.id.toString() === id ? { ...card, deleted: true } : card
|
|
28
|
-
)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
return { previousQueries };
|
|
33
|
-
},
|
|
34
|
-
onError: (_err, _id, context) => {
|
|
35
|
-
if (context?.previousQueries) {
|
|
36
|
-
for (const [queryKey, data] of context.previousQueries) {
|
|
37
|
-
queryClient.setQueryData(queryKey, data);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
onSettled: () => {
|
|
42
|
-
queryClient.invalidateQueries({ queryKey: cardsKey });
|
|
43
|
-
queryClient.invalidateQueries({ queryKey: cardKey });
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
useDeleteCard
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=delete-card.hook.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/cards/hooks/delete-card.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { CARDS_QUERY_KEY } from './cards.hook';\nimport type { PaginatedSuccessResult } from '../../../infra/api/types';\nimport type { Card } from '../types';\n\nexport function useDeleteCard() {\n const queryClient = useQueryClient();\n const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);\n const cardKey = useAuthQueryKey(['card']);\n\n return useMutation({\n mutationFn: async (id: string) => {\n const { deleteCardAction } = await import('../actions/delete-card.action');\n return withAction(deleteCardAction)(id);\n },\n onMutate: async (id: string) => {\n await queryClient.cancelQueries({ queryKey: cardsKey });\n\n const previousQueries = queryClient.getQueriesData<PaginatedSuccessResult<Card>>({\n queryKey: cardsKey,\n });\n\n queryClient.setQueriesData<PaginatedSuccessResult<Card>>(\n { queryKey: cardsKey },\n (old) => {\n if (!old?.data) return old;\n return {\n ...old,\n data: old.data.map((card) =>\n card.id.toString() === id ? { ...card, deleted: true } : card\n ),\n };\n }\n );\n\n return { previousQueries };\n },\n onError: (_err, _id, context) => {\n if (context?.previousQueries) {\n for (const [queryKey, data] of context.previousQueries) {\n queryClient.setQueryData(queryKey, data);\n }\n }\n },\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey: cardsKey });\n queryClient.invalidateQueries({ queryKey: cardKey });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAAsB;AAC5C,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAIzB,SAAS,gBAAgB;AAC9B,QAAM,cAAc,eAAe;AACnC,QAAM,WAAW,gBAAgB,CAAC,GAAG,eAAe,CAAC;AACrD,QAAM,UAAU,gBAAgB,CAAC,MAAM,CAAC;AAExC,SAAO,YAAY;AAAA,IACjB,YAAY,OAAO,OAAe;AAChC,YAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,+BAA+B;AACzE,aAAO,WAAW,gBAAgB,EAAE,EAAE;AAAA,IACxC;AAAA,IACA,UAAU,OAAO,OAAe;AAC9B,YAAM,YAAY,cAAc,EAAE,UAAU,SAAS,CAAC;AAEtD,YAAM,kBAAkB,YAAY,eAA6C;AAAA,QAC/E,UAAU;AAAA,MACZ,CAAC;AAED,kBAAY;AAAA,QACV,EAAE,UAAU,SAAS;AAAA,QACrB,CAAC,QAAQ;AACP,cAAI,CAAC,KAAK,KAAM,QAAO;AACvB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,MAAM,IAAI,KAAK;AAAA,cAAI,CAAC,SAClB,KAAK,GAAG,SAAS,MAAM,KAAK,EAAE,GAAG,MAAM,SAAS,KAAK,IAAI;AAAA,YAC3D;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,aAAO,EAAE,gBAAgB;AAAA,IAC3B;AAAA,IACA,SAAS,CAAC,MAAM,KAAK,YAAY;AAC/B,UAAI,SAAS,iBAAiB;AAC5B,mBAAW,CAAC,UAAU,IAAI,KAAK,QAAQ,iBAAiB;AACtD,sBAAY,aAAa,UAAU,IAAI;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA,IACA,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,SAAS,CAAC;AACpD,kBAAY,kBAAkB,EAAE,UAAU,QAAQ,CAAC;AAAA,IACrD;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
-
import { withAction } from "../../../utils/withAction";
|
|
4
|
-
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
5
|
-
import { CARDS_QUERY_KEY } from "./cards.hook";
|
|
6
|
-
function useSetDefaultCard() {
|
|
7
|
-
const queryClient = useQueryClient();
|
|
8
|
-
const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);
|
|
9
|
-
const cardKey = useAuthQueryKey(["card"]);
|
|
10
|
-
return useMutation({
|
|
11
|
-
mutationFn: async (cardId) => {
|
|
12
|
-
const { setDefaultCardAction } = await import("../actions/set-default-card.action");
|
|
13
|
-
return withAction(setDefaultCardAction)(cardId);
|
|
14
|
-
},
|
|
15
|
-
onMutate: async (cardId) => {
|
|
16
|
-
await queryClient.cancelQueries({ queryKey: cardsKey });
|
|
17
|
-
const previousQueries = queryClient.getQueriesData({
|
|
18
|
-
queryKey: cardsKey
|
|
19
|
-
});
|
|
20
|
-
queryClient.setQueriesData(
|
|
21
|
-
{ queryKey: cardsKey },
|
|
22
|
-
(old) => {
|
|
23
|
-
if (!old?.data) return old;
|
|
24
|
-
return {
|
|
25
|
-
...old,
|
|
26
|
-
data: old.data.map((card) => ({
|
|
27
|
-
...card,
|
|
28
|
-
is_default: card.id.toString() === cardId
|
|
29
|
-
}))
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
return { previousQueries };
|
|
34
|
-
},
|
|
35
|
-
onError: (_err, _cardId, context) => {
|
|
36
|
-
if (context?.previousQueries) {
|
|
37
|
-
for (const [queryKey, data] of context.previousQueries) {
|
|
38
|
-
queryClient.setQueryData(queryKey, data);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
onSettled: () => {
|
|
43
|
-
queryClient.invalidateQueries({ queryKey: cardsKey });
|
|
44
|
-
queryClient.invalidateQueries({ queryKey: cardKey });
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
export {
|
|
49
|
-
useSetDefaultCard
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=set-default-card.hook.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/cards/hooks/set-default-card.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { CARDS_QUERY_KEY } from './cards.hook';\nimport type { PaginatedSuccessResult } from '../../../infra/api/types';\nimport type { Card } from '../types';\n\nexport function useSetDefaultCard() {\n const queryClient = useQueryClient();\n const cardsKey = useAuthQueryKey([...CARDS_QUERY_KEY]);\n const cardKey = useAuthQueryKey(['card']);\n\n return useMutation({\n mutationFn: async (cardId: string) => {\n const { setDefaultCardAction } = await import('../actions/set-default-card.action');\n return withAction(setDefaultCardAction)(cardId);\n },\n onMutate: async (cardId: string) => {\n await queryClient.cancelQueries({ queryKey: cardsKey });\n\n const previousQueries = queryClient.getQueriesData<PaginatedSuccessResult<Card>>({\n queryKey: cardsKey,\n });\n\n queryClient.setQueriesData<PaginatedSuccessResult<Card>>(\n { queryKey: cardsKey },\n (old) => {\n if (!old?.data) return old;\n return {\n ...old,\n data: old.data.map((card) => ({\n ...card,\n is_default: card.id.toString() === cardId,\n })),\n };\n }\n );\n\n return { previousQueries };\n },\n onError: (_err, _cardId, context) => {\n if (context?.previousQueries) {\n for (const [queryKey, data] of context.previousQueries) {\n queryClient.setQueryData(queryKey, data);\n }\n }\n },\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey: cardsKey });\n queryClient.invalidateQueries({ queryKey: cardKey });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAAsB;AAC5C,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAIzB,SAAS,oBAAoB;AAClC,QAAM,cAAc,eAAe;AACnC,QAAM,WAAW,gBAAgB,CAAC,GAAG,eAAe,CAAC;AACrD,QAAM,UAAU,gBAAgB,CAAC,MAAM,CAAC;AAExC,SAAO,YAAY;AAAA,IACjB,YAAY,OAAO,WAAmB;AACpC,YAAM,EAAE,qBAAqB,IAAI,MAAM,OAAO,oCAAoC;AAClF,aAAO,WAAW,oBAAoB,EAAE,MAAM;AAAA,IAChD;AAAA,IACA,UAAU,OAAO,WAAmB;AAClC,YAAM,YAAY,cAAc,EAAE,UAAU,SAAS,CAAC;AAEtD,YAAM,kBAAkB,YAAY,eAA6C;AAAA,QAC/E,UAAU;AAAA,MACZ,CAAC;AAED,kBAAY;AAAA,QACV,EAAE,UAAU,SAAS;AAAA,QACrB,CAAC,QAAQ;AACP,cAAI,CAAC,KAAK,KAAM,QAAO;AACvB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,MAAM,IAAI,KAAK,IAAI,CAAC,UAAU;AAAA,cAC5B,GAAG;AAAA,cACH,YAAY,KAAK,GAAG,SAAS,MAAM;AAAA,YACrC,EAAE;AAAA,UACJ;AAAA,QACF;AAAA,MACF;AAEA,aAAO,EAAE,gBAAgB;AAAA,IAC3B;AAAA,IACA,SAAS,CAAC,MAAM,SAAS,YAAY;AACnC,UAAI,SAAS,iBAAiB;AAC5B,mBAAW,CAAC,UAAU,IAAI,KAAK,QAAQ,iBAAiB;AACtD,sBAAY,aAAa,UAAU,IAAI;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAAA,IACA,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,SAAS,CAAC;AACpD,kBAAY,kBAAkB,EAAE,UAAU,QAAQ,CAAC;AAAA,IACrD;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,71 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
-
import { createProjectAction } from "../actions/create-project.action";
|
|
4
|
-
import { withAction } from "../../../utils/withAction";
|
|
5
|
-
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
6
|
-
import { PROJECTS_BASE_KEY } from "./list-projects.hook";
|
|
7
|
-
import { insertSorted, buildCompareFn } from "../../../infra/utils/array";
|
|
8
|
-
function extractSort(query) {
|
|
9
|
-
const key = query.queryKey;
|
|
10
|
-
for (let i = key.length - 1; i >= 0; i--) {
|
|
11
|
-
const segment = key[i];
|
|
12
|
-
if (segment && typeof segment === "object" && "sort" in segment) {
|
|
13
|
-
return segment.sort;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return void 0;
|
|
17
|
-
}
|
|
18
|
-
function useCreateProject() {
|
|
19
|
-
const queryClient = useQueryClient();
|
|
20
|
-
const projectsKey = useAuthQueryKey([...PROJECTS_BASE_KEY]);
|
|
21
|
-
return useMutation({
|
|
22
|
-
mutationFn: (data) => withAction(createProjectAction)(data),
|
|
23
|
-
onSuccess: (newProject) => {
|
|
24
|
-
const cache = queryClient.getQueryCache();
|
|
25
|
-
const queries = cache.findAll({ queryKey: projectsKey });
|
|
26
|
-
for (const query of queries) {
|
|
27
|
-
const sort = extractSort(query);
|
|
28
|
-
const isInfinite = query.queryKey.includes("infinite");
|
|
29
|
-
if (isInfinite) {
|
|
30
|
-
queryClient.setQueryData(
|
|
31
|
-
query.queryKey,
|
|
32
|
-
(old) => {
|
|
33
|
-
if (!old?.pages.length) return old;
|
|
34
|
-
const pageSize = old.pages[0].data.length || 20;
|
|
35
|
-
const allItems = old.pages.flatMap((page) => page.data);
|
|
36
|
-
const withNew = sort ? insertSorted(allItems, newProject, buildCompareFn(sort)) : [newProject, ...allItems];
|
|
37
|
-
const newTotal = (old.pages[0].total ?? 0) + 1;
|
|
38
|
-
return {
|
|
39
|
-
...old,
|
|
40
|
-
pages: old.pages.map((page, i) => ({
|
|
41
|
-
...page,
|
|
42
|
-
data: withNew.slice(i * pageSize, (i + 1) * pageSize),
|
|
43
|
-
total: newTotal
|
|
44
|
-
}))
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
} else {
|
|
49
|
-
queryClient.setQueryData(
|
|
50
|
-
query.queryKey,
|
|
51
|
-
(old) => {
|
|
52
|
-
if (!old) return old;
|
|
53
|
-
const pageSize = old.data.length || 20;
|
|
54
|
-
const withNew = sort ? insertSorted(old.data, newProject, buildCompareFn(sort)) : [newProject, ...old.data];
|
|
55
|
-
return {
|
|
56
|
-
...old,
|
|
57
|
-
data: withNew.slice(0, pageSize),
|
|
58
|
-
total: old.total + 1
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
queryClient.invalidateQueries({ queryKey: projectsKey });
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
export {
|
|
69
|
-
useCreateProject
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=create-project.hook.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/projects/hooks/create-project.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient, InfiniteData, Query } from '@tanstack/react-query';\nimport { createProjectAction } from '../actions/create-project.action';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { PROJECTS_BASE_KEY } from './list-projects.hook';\nimport { insertSorted, buildCompareFn } from '../../../infra/utils/array';\nimport type { CreateProjectRequest, Project, ProjectsPage } from '../types';\n\nfunction extractSort(query: Query): string | undefined {\n const key = query.queryKey;\n for (let i = key.length - 1; i >= 0; i--) {\n const segment = key[i];\n if (segment && typeof segment === 'object' && 'sort' in segment) {\n return (segment as Record<string, unknown>).sort as string | undefined;\n }\n }\n return undefined;\n}\n\nexport function useCreateProject() {\n const queryClient = useQueryClient();\n const projectsKey = useAuthQueryKey([...PROJECTS_BASE_KEY]);\n\n return useMutation({\n mutationFn: (data: CreateProjectRequest) =>\n withAction(createProjectAction)(data),\n\n onSuccess: (newProject: Project) => {\n const cache = queryClient.getQueryCache();\n const queries = cache.findAll({ queryKey: projectsKey });\n\n for (const query of queries) {\n const sort = extractSort(query);\n const isInfinite = query.queryKey.includes('infinite');\n\n if (isInfinite) {\n queryClient.setQueryData<InfiniteData<ProjectsPage>>(\n query.queryKey,\n (old) => {\n if (!old?.pages.length) return old;\n\n const pageSize = old.pages[0].data.length || 20;\n const allItems = old.pages.flatMap((page) => page.data);\n\n const withNew = sort\n ? insertSorted(allItems, newProject, buildCompareFn<Project>(sort))\n : [newProject, ...allItems];\n\n const newTotal = (old.pages[0].total ?? 0) + 1;\n\n return {\n ...old,\n pages: old.pages.map((page, i) => ({\n ...page,\n data: withNew.slice(i * pageSize, (i + 1) * pageSize),\n total: newTotal,\n })),\n };\n },\n );\n } else {\n queryClient.setQueryData<ProjectsPage>(\n query.queryKey,\n (old) => {\n if (!old) return old;\n\n const pageSize = old.data.length || 20;\n\n const withNew = sort\n ? insertSorted(old.data, newProject, buildCompareFn<Project>(sort))\n : [newProject, ...old.data];\n\n return {\n ...old,\n data: withNew.slice(0, pageSize),\n total: old.total + 1,\n };\n },\n );\n }\n }\n\n queryClient.invalidateQueries({ queryKey: projectsKey });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAA2C;AACjE,SAAS,2BAA2B;AACpC,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,cAAc,sBAAsB;AAG7C,SAAS,YAAY,OAAkC;AACrD,QAAM,MAAM,MAAM;AAClB,WAAS,IAAI,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK;AACxC,UAAM,UAAU,IAAI,CAAC;AACrB,QAAI,WAAW,OAAO,YAAY,YAAY,UAAU,SAAS;AAC/D,aAAQ,QAAoC;AAAA,IAC9C;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,mBAAmB;AACjC,QAAM,cAAc,eAAe;AACnC,QAAM,cAAc,gBAAgB,CAAC,GAAG,iBAAiB,CAAC;AAE1D,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,SACX,WAAW,mBAAmB,EAAE,IAAI;AAAA,IAEtC,WAAW,CAAC,eAAwB;AAClC,YAAM,QAAQ,YAAY,cAAc;AACxC,YAAM,UAAU,MAAM,QAAQ,EAAE,UAAU,YAAY,CAAC;AAEvD,iBAAW,SAAS,SAAS;AAC3B,cAAM,OAAO,YAAY,KAAK;AAC9B,cAAM,aAAa,MAAM,SAAS,SAAS,UAAU;AAErD,YAAI,YAAY;AACd,sBAAY;AAAA,YACV,MAAM;AAAA,YACN,CAAC,QAAQ;AACP,kBAAI,CAAC,KAAK,MAAM,OAAQ,QAAO;AAE/B,oBAAM,WAAW,IAAI,MAAM,CAAC,EAAE,KAAK,UAAU;AAC7C,oBAAM,WAAW,IAAI,MAAM,QAAQ,CAAC,SAAS,KAAK,IAAI;AAEtD,oBAAM,UAAU,OACZ,aAAa,UAAU,YAAY,eAAwB,IAAI,CAAC,IAChE,CAAC,YAAY,GAAG,QAAQ;AAE5B,oBAAM,YAAY,IAAI,MAAM,CAAC,EAAE,SAAS,KAAK;AAE7C,qBAAO;AAAA,gBACL,GAAG;AAAA,gBACH,OAAO,IAAI,MAAM,IAAI,CAAC,MAAM,OAAO;AAAA,kBACjC,GAAG;AAAA,kBACH,MAAM,QAAQ,MAAM,IAAI,WAAW,IAAI,KAAK,QAAQ;AAAA,kBACpD,OAAO;AAAA,gBACT,EAAE;AAAA,cACJ;AAAA,YACF;AAAA,UACF;AAAA,QACF,OAAO;AACL,sBAAY;AAAA,YACV,MAAM;AAAA,YACN,CAAC,QAAQ;AACP,kBAAI,CAAC,IAAK,QAAO;AAEjB,oBAAM,WAAW,IAAI,KAAK,UAAU;AAEpC,oBAAM,UAAU,OACZ,aAAa,IAAI,MAAM,YAAY,eAAwB,IAAI,CAAC,IAChE,CAAC,YAAY,GAAG,IAAI,IAAI;AAE5B,qBAAO;AAAA,gBACL,GAAG;AAAA,gBACH,MAAM,QAAQ,MAAM,GAAG,QAAQ;AAAA,gBAC/B,OAAO,IAAI,QAAQ;AAAA,cACrB;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,kBAAY,kBAAkB,EAAE,UAAU,YAAY,CAAC;AAAA,IACzD;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
-
import { deleteProjectAction } from "../actions/delete-project.action";
|
|
4
|
-
import { withAction } from "../../../utils/withAction";
|
|
5
|
-
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
6
|
-
import { PROJECTS_BASE_KEY } from "./list-projects.hook";
|
|
7
|
-
function useDeleteProject() {
|
|
8
|
-
const queryClient = useQueryClient();
|
|
9
|
-
const projectsKey = useAuthQueryKey([...PROJECTS_BASE_KEY]);
|
|
10
|
-
return useMutation({
|
|
11
|
-
mutationFn: ({ projectId, moveToProjectId }) => withAction(deleteProjectAction)(projectId, moveToProjectId),
|
|
12
|
-
onSuccess: (_, { projectId }) => {
|
|
13
|
-
const cache = queryClient.getQueryCache();
|
|
14
|
-
const queries = cache.findAll({ queryKey: projectsKey });
|
|
15
|
-
for (const query of queries) {
|
|
16
|
-
const isInfinite = query.queryKey.includes("infinite");
|
|
17
|
-
if (isInfinite) {
|
|
18
|
-
queryClient.setQueryData(
|
|
19
|
-
query.queryKey,
|
|
20
|
-
(old) => {
|
|
21
|
-
if (!old?.pages.length) return old;
|
|
22
|
-
return {
|
|
23
|
-
...old,
|
|
24
|
-
pages: old.pages.map((page) => ({
|
|
25
|
-
...page,
|
|
26
|
-
data: page.data.filter((p) => p.id !== projectId),
|
|
27
|
-
total: page.total - 1
|
|
28
|
-
}))
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
} else {
|
|
33
|
-
queryClient.setQueryData(
|
|
34
|
-
query.queryKey,
|
|
35
|
-
(old) => {
|
|
36
|
-
if (!old) return old;
|
|
37
|
-
return {
|
|
38
|
-
...old,
|
|
39
|
-
data: old.data.filter((p) => p.id !== projectId),
|
|
40
|
-
total: old.total - 1
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
queryClient.invalidateQueries({ queryKey: projectsKey });
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
export {
|
|
51
|
-
useDeleteProject
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=delete-project.hook.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/projects/hooks/delete-project.hook.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient, InfiniteData } from '@tanstack/react-query';\nimport { deleteProjectAction } from '../actions/delete-project.action';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { PROJECTS_BASE_KEY } from './list-projects.hook';\nimport type { ProjectsPage } from '../types';\n\nexport function useDeleteProject() {\n const queryClient = useQueryClient();\n const projectsKey = useAuthQueryKey([...PROJECTS_BASE_KEY]);\n\n return useMutation({\n mutationFn: ({ projectId, moveToProjectId }: { projectId: number; moveToProjectId: number }) =>\n withAction(deleteProjectAction)(projectId, moveToProjectId),\n\n onSuccess: (_, { projectId }) => {\n const cache = queryClient.getQueryCache();\n const queries = cache.findAll({ queryKey: projectsKey });\n\n for (const query of queries) {\n const isInfinite = query.queryKey.includes('infinite');\n\n if (isInfinite) {\n queryClient.setQueryData<InfiniteData<ProjectsPage>>(\n query.queryKey,\n (old) => {\n if (!old?.pages.length) return old;\n return {\n ...old,\n pages: old.pages.map((page) => ({\n ...page,\n data: page.data.filter((p) => p.id !== projectId),\n total: page.total - 1,\n })),\n };\n },\n );\n } else {\n queryClient.setQueryData<ProjectsPage>(\n query.queryKey,\n (old) => {\n if (!old) return old;\n return {\n ...old,\n data: old.data.filter((p) => p.id !== projectId),\n total: old.total - 1,\n };\n },\n );\n }\n }\n\n queryClient.invalidateQueries({ queryKey: projectsKey });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAAoC;AAC1D,SAAS,2BAA2B;AACpC,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAG3B,SAAS,mBAAmB;AACjC,QAAM,cAAc,eAAe;AACnC,QAAM,cAAc,gBAAgB,CAAC,GAAG,iBAAiB,CAAC;AAE1D,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,EAAE,WAAW,gBAAgB,MACxC,WAAW,mBAAmB,EAAE,WAAW,eAAe;AAAA,IAE5D,WAAW,CAAC,GAAG,EAAE,UAAU,MAAM;AAC/B,YAAM,QAAQ,YAAY,cAAc;AACxC,YAAM,UAAU,MAAM,QAAQ,EAAE,UAAU,YAAY,CAAC;AAEvD,iBAAW,SAAS,SAAS;AAC3B,cAAM,aAAa,MAAM,SAAS,SAAS,UAAU;AAErD,YAAI,YAAY;AACd,sBAAY;AAAA,YACV,MAAM;AAAA,YACN,CAAC,QAAQ;AACP,kBAAI,CAAC,KAAK,MAAM,OAAQ,QAAO;AAC/B,qBAAO;AAAA,gBACL,GAAG;AAAA,gBACH,OAAO,IAAI,MAAM,IAAI,CAAC,UAAU;AAAA,kBAC9B,GAAG;AAAA,kBACH,MAAM,KAAK,KAAK,OAAO,CAAC,MAAM,EAAE,OAAO,SAAS;AAAA,kBAChD,OAAO,KAAK,QAAQ;AAAA,gBACtB,EAAE;AAAA,cACJ;AAAA,YACF;AAAA,UACF;AAAA,QACF,OAAO;AACL,sBAAY;AAAA,YACV,MAAM;AAAA,YACN,CAAC,QAAQ;AACP,kBAAI,CAAC,IAAK,QAAO;AACjB,qBAAO;AAAA,gBACL,GAAG;AAAA,gBACH,MAAM,IAAI,KAAK,OAAO,CAAC,MAAM,EAAE,OAAO,SAAS;AAAA,gBAC/C,OAAO,IAAI,QAAQ;AAAA,cACrB;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,kBAAY,kBAAkB,EAAE,UAAU,YAAY,CAAC;AAAA,IACzD;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useQuery } from "@tanstack/react-query";
|
|
3
|
-
import { findProjectAction } from "../actions/find-project.action";
|
|
4
|
-
import { withAction } from "../../../utils/withAction";
|
|
5
|
-
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
6
|
-
import { PROJECTS_BASE_KEY } from "./list-projects.hook";
|
|
7
|
-
function useProject(projectId) {
|
|
8
|
-
const queryKey = useAuthQueryKey([...PROJECTS_BASE_KEY, projectId]);
|
|
9
|
-
return useQuery({
|
|
10
|
-
queryKey,
|
|
11
|
-
queryFn: () => withAction(() => findProjectAction(projectId))(),
|
|
12
|
-
enabled: projectId != null && projectId > 0,
|
|
13
|
-
staleTime: 3e4
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
export {
|
|
17
|
-
useProject
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=find-project.hook.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/projects/hooks/find-project.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { findProjectAction } from '../actions/find-project.action';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\nimport { PROJECTS_BASE_KEY } from './list-projects.hook';\n\nexport function useProject(projectId: number | null) {\n const queryKey = useAuthQueryKey([...PROJECTS_BASE_KEY, projectId]);\n\n return useQuery({\n queryKey,\n queryFn: () => withAction(() => findProjectAction(projectId!))(),\n enabled: projectId != null && projectId > 0,\n staleTime: 30_000,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAE3B,SAAS,WAAW,WAA0B;AACnD,QAAM,WAAW,gBAAgB,CAAC,GAAG,mBAAmB,SAAS,CAAC;AAElE,SAAO,SAAS;AAAA,IACd;AAAA,IACA,SAAS,MAAM,WAAW,MAAM,kBAAkB,SAAU,CAAC,EAAE;AAAA,IAC/D,SAAS,aAAa,QAAQ,YAAY;AAAA,IAC1C,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
3
|
-
import { listProjectsAction } from "../actions/list-projects.action";
|
|
4
|
-
import { withAction } from "../../../utils/withAction";
|
|
5
|
-
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
6
|
-
import { PROJECTS_BASE_KEY } from "./list-projects.hook";
|
|
7
|
-
const PAGE_SIZE = 20;
|
|
8
|
-
const INFINITE_PROJECTS_QUERY_KEY = (params) => [...PROJECTS_BASE_KEY, "infinite", params];
|
|
9
|
-
function useInfiniteProjects({
|
|
10
|
-
limit = PAGE_SIZE,
|
|
11
|
-
...params
|
|
12
|
-
}) {
|
|
13
|
-
const queryKey = useAuthQueryKey([...INFINITE_PROJECTS_QUERY_KEY(params)]);
|
|
14
|
-
return useInfiniteQuery({
|
|
15
|
-
queryKey,
|
|
16
|
-
queryFn: ({ pageParam }) => withAction(
|
|
17
|
-
() => listProjectsAction({
|
|
18
|
-
...params,
|
|
19
|
-
page: pageParam,
|
|
20
|
-
limit
|
|
21
|
-
})
|
|
22
|
-
)(),
|
|
23
|
-
initialPageParam: 1,
|
|
24
|
-
getNextPageParam: (lastPage, allPages) => {
|
|
25
|
-
const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);
|
|
26
|
-
return loaded < lastPage.total ? allPages.length + 1 : void 0;
|
|
27
|
-
},
|
|
28
|
-
placeholderData: (prev) => prev,
|
|
29
|
-
staleTime: 3e4,
|
|
30
|
-
refetchOnMount: true,
|
|
31
|
-
refetchOnWindowFocus: true,
|
|
32
|
-
refetchOnReconnect: true
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
export {
|
|
36
|
-
INFINITE_PROJECTS_QUERY_KEY,
|
|
37
|
-
useInfiniteProjects
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=list-infinite-projects.hook.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/projects/hooks/list-infinite-projects.hook.ts"],"sourcesContent":["\"use client\";\n\nimport { useInfiniteQuery } from \"@tanstack/react-query\";\nimport { listProjectsAction } from \"../actions/list-projects.action\";\nimport type { ListProjectsActionParams } from \"../actions/list-projects.action\";\nimport { withAction } from \"../../../utils/withAction\";\nimport { useAuthQueryKey } from \"../../../hooks/useAuthQueryKey\";\nimport { PROJECTS_BASE_KEY } from \"./list-projects.hook\";\n\nconst PAGE_SIZE = 20;\n\nexport const INFINITE_PROJECTS_QUERY_KEY = (\n params?: Omit<ListProjectsActionParams, \"page\">,\n) => [...PROJECTS_BASE_KEY, \"infinite\", params] as const;\n\nexport function useInfiniteProjects({\n limit = PAGE_SIZE,\n ...params\n}: Omit<ListProjectsActionParams, \"page\">) {\n const queryKey = useAuthQueryKey([...INFINITE_PROJECTS_QUERY_KEY(params)]);\n\n return useInfiniteQuery({\n queryKey,\n queryFn: ({ pageParam }) =>\n withAction(() =>\n listProjectsAction({\n ...params,\n page: pageParam as number,\n limit,\n }),\n )(),\n initialPageParam: 1,\n getNextPageParam: (lastPage, allPages) => {\n const loaded = allPages.reduce((sum, p) => sum + p.data.length, 0);\n return loaded < lastPage.total ? allPages.length + 1 : undefined;\n },\n placeholderData: (prev) => prev,\n staleTime: 30_000,\n refetchOnMount: true,\n refetchOnWindowFocus: true,\n refetchOnReconnect: true,\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AAEnC,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAElC,MAAM,YAAY;AAEX,MAAM,8BAA8B,CACzC,WACG,CAAC,GAAG,mBAAmB,YAAY,MAAM;AAEvC,SAAS,oBAAoB;AAAA,EAClC,QAAQ;AAAA,EACR,GAAG;AACL,GAA2C;AACzC,QAAM,WAAW,gBAAgB,CAAC,GAAG,4BAA4B,MAAM,CAAC,CAAC;AAEzE,SAAO,iBAAiB;AAAA,IACtB;AAAA,IACA,SAAS,CAAC,EAAE,UAAU,MACpB;AAAA,MAAW,MACT,mBAAmB;AAAA,QACjB,GAAG;AAAA,QACH,MAAM;AAAA,QACN;AAAA,MACF,CAAC;AAAA,IACH,EAAE;AAAA,IACJ,kBAAkB;AAAA,IAClB,kBAAkB,CAAC,UAAU,aAAa;AACxC,YAAM,SAAS,SAAS,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,KAAK,QAAQ,CAAC;AACjE,aAAO,SAAS,SAAS,QAAQ,SAAS,SAAS,IAAI;AAAA,IACzD;AAAA,IACA,iBAAiB,CAAC,SAAS;AAAA,IAC3B,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,sBAAsB;AAAA,IACtB,oBAAoB;AAAA,EACtB,CAAC;AACH;","names":[]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useQuery, keepPreviousData } from "@tanstack/react-query";
|
|
3
|
-
import { listProjectsAction } from "../actions/list-projects.action";
|
|
4
|
-
import { withAction } from "../../../utils/withAction";
|
|
5
|
-
import { useAuthQueryKey } from "../../../hooks/useAuthQueryKey";
|
|
6
|
-
const PROJECTS_BASE_KEY = ["projects"];
|
|
7
|
-
const PROJECTS_QUERY_KEY = (params) => [...PROJECTS_BASE_KEY, params];
|
|
8
|
-
function useProjects(params) {
|
|
9
|
-
const queryKey = useAuthQueryKey([...PROJECTS_QUERY_KEY(params)]);
|
|
10
|
-
return useQuery({
|
|
11
|
-
queryKey,
|
|
12
|
-
queryFn: withAction(() => listProjectsAction(params)),
|
|
13
|
-
staleTime: 3e4,
|
|
14
|
-
placeholderData: keepPreviousData
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
PROJECTS_BASE_KEY,
|
|
19
|
-
PROJECTS_QUERY_KEY,
|
|
20
|
-
useProjects
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=list-projects.hook.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/projects/hooks/list-projects.hook.ts"],"sourcesContent":["'use client';\n\nimport { useQuery, keepPreviousData } from '@tanstack/react-query';\nimport { listProjectsAction } from '../actions/list-projects.action';\nimport type { ListProjectsActionParams } from '../actions/list-projects.action';\nimport { withAction } from '../../../utils/withAction';\nimport { useAuthQueryKey } from '../../../hooks/useAuthQueryKey';\n\nexport const PROJECTS_BASE_KEY = ['projects'] as const;\n\nexport const PROJECTS_QUERY_KEY = (params?: ListProjectsActionParams) =>\n [...PROJECTS_BASE_KEY, params] as const;\n\nexport function useProjects(params?: ListProjectsActionParams) {\n const queryKey = useAuthQueryKey([...PROJECTS_QUERY_KEY(params)]);\n\n return useQuery({\n queryKey,\n queryFn: withAction(() => listProjectsAction(params)),\n staleTime: 30_000,\n placeholderData: keepPreviousData,\n });\n}\n"],"mappings":";AAEA,SAAS,UAAU,wBAAwB;AAC3C,SAAS,0BAA0B;AAEnC,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAEzB,MAAM,oBAAoB,CAAC,UAAU;AAErC,MAAM,qBAAqB,CAAC,WACjC,CAAC,GAAG,mBAAmB,MAAM;AAExB,SAAS,YAAY,QAAmC;AAC7D,QAAM,WAAW,gBAAgB,CAAC,GAAG,mBAAmB,MAAM,CAAC,CAAC;AAEhE,SAAO,SAAS;AAAA,IACd;AAAA,IACA,SAAS,WAAW,MAAM,mBAAmB,MAAM,CAAC;AAAA,IACpD,WAAW;AAAA,IACX,iBAAiB;AAAA,EACnB,CAAC;AACH;","names":[]}
|