@burdenoff/microfe-coolandlovely 2026.1101.8 → 2026.1102.2
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/README.md +15 -0
- package/dist/coolandlovely/CoolAndLovelyRoot.d.ts.map +1 -1
- package/dist/coolandlovely/CoolAndLovelyRoot.js +8 -0
- package/dist/coolandlovely/CoolAndLovelyRoot.js.map +1 -1
- package/dist/coolandlovely/CoolAndLovelyRoutes.d.ts.map +1 -1
- package/dist/coolandlovely/CoolAndLovelyRoutes.js +20 -16
- package/dist/coolandlovely/CoolAndLovelyRoutes.js.map +1 -1
- package/dist/coolandlovely/components/WardrobeItemCard.d.ts +2 -1
- package/dist/coolandlovely/components/WardrobeItemCard.d.ts.map +1 -1
- package/dist/coolandlovely/components/WardrobeItemCard.js +4 -3
- package/dist/coolandlovely/components/WardrobeItemCard.js.map +1 -1
- package/dist/coolandlovely/components/prices/BestPriceBadge.d.ts +7 -0
- package/dist/coolandlovely/components/prices/BestPriceBadge.d.ts.map +1 -0
- package/dist/coolandlovely/components/prices/BestPriceBadge.js +22 -0
- package/dist/coolandlovely/components/prices/BestPriceBadge.js.map +1 -0
- package/dist/coolandlovely/components/prices/LookbookPriceBoard.d.ts +10 -0
- package/dist/coolandlovely/components/prices/LookbookPriceBoard.d.ts.map +1 -0
- package/dist/coolandlovely/components/prices/LookbookPriceBoard.js +120 -0
- package/dist/coolandlovely/components/prices/LookbookPriceBoard.js.map +1 -0
- package/dist/coolandlovely/components/prices/PriceComparison.d.ts +5 -0
- package/dist/coolandlovely/components/prices/PriceComparison.d.ts.map +1 -0
- package/dist/coolandlovely/components/prices/PriceComparison.js +95 -0
- package/dist/coolandlovely/components/prices/PriceComparison.js.map +1 -0
- package/dist/coolandlovely/components/prices/PriceCurrencySelect.d.ts +6 -0
- package/dist/coolandlovely/components/prices/PriceCurrencySelect.d.ts.map +1 -0
- package/dist/coolandlovely/components/prices/PriceCurrencySelect.js +38 -0
- package/dist/coolandlovely/components/prices/PriceCurrencySelect.js.map +1 -0
- package/dist/coolandlovely/components/prices/PricePanel.d.ts +6 -0
- package/dist/coolandlovely/components/prices/PricePanel.d.ts.map +1 -0
- package/dist/coolandlovely/components/prices/PricePanel.js +105 -0
- package/dist/coolandlovely/components/prices/PricePanel.js.map +1 -0
- package/dist/coolandlovely/components/prices/PriceWatchDisclosure.d.ts +2 -0
- package/dist/coolandlovely/components/prices/PriceWatchDisclosure.d.ts.map +1 -0
- package/dist/coolandlovely/components/prices/PriceWatchDisclosure.js +28 -0
- package/dist/coolandlovely/components/prices/PriceWatchDisclosure.js.map +1 -0
- package/dist/coolandlovely/components/prices/PriceWatchForm.d.ts +5 -0
- package/dist/coolandlovely/components/prices/PriceWatchForm.d.ts.map +1 -0
- package/dist/coolandlovely/components/prices/PriceWatchForm.js +89 -0
- package/dist/coolandlovely/components/prices/PriceWatchForm.js.map +1 -0
- package/dist/coolandlovely/components/prices/PriceWatches.d.ts +3 -0
- package/dist/coolandlovely/components/prices/PriceWatches.d.ts.map +1 -0
- package/dist/coolandlovely/components/prices/PriceWatches.js +189 -0
- package/dist/coolandlovely/components/prices/PriceWatches.js.map +1 -0
- package/dist/coolandlovely/components/prices/RetailerOfferLink.d.ts +6 -0
- package/dist/coolandlovely/components/prices/RetailerOfferLink.d.ts.map +1 -0
- package/dist/coolandlovely/components/prices/RetailerOfferLink.js +28 -0
- package/dist/coolandlovely/components/prices/RetailerOfferLink.js.map +1 -0
- package/dist/coolandlovely/components/prices/money.d.ts +6 -0
- package/dist/coolandlovely/components/prices/money.d.ts.map +1 -0
- package/dist/coolandlovely/components/prices/money.js +42 -0
- package/dist/coolandlovely/components/prices/money.js.map +1 -0
- package/dist/coolandlovely/hooks/useContextNavigation.d.ts +3 -0
- package/dist/coolandlovely/hooks/useContextNavigation.d.ts.map +1 -0
- package/dist/coolandlovely/hooks/useContextNavigation.js +31 -0
- package/dist/coolandlovely/hooks/useContextNavigation.js.map +1 -0
- package/dist/coolandlovely/hooks/useCoolAndLovelyApi.d.ts.map +1 -1
- package/dist/coolandlovely/hooks/useCoolAndLovelyApi.js +1 -1
- package/dist/coolandlovely/hooks/useCoolAndLovelyApi.js.map +1 -1
- package/dist/coolandlovely/hooks/useCreatorMarketplace.d.ts +118 -0
- package/dist/coolandlovely/hooks/useCreatorMarketplace.d.ts.map +1 -0
- package/dist/coolandlovely/hooks/useCreatorMarketplace.js +120 -0
- package/dist/coolandlovely/hooks/useCreatorMarketplace.js.map +1 -0
- package/dist/coolandlovely/hooks/usePriceApi.d.ts +57 -0
- package/dist/coolandlovely/hooks/usePriceApi.d.ts.map +1 -0
- package/dist/coolandlovely/hooks/usePriceApi.js +111 -0
- package/dist/coolandlovely/hooks/usePriceApi.js.map +1 -0
- package/dist/coolandlovely/pages/collaborations/CollaborationDetailPage.d.ts.map +1 -1
- package/dist/coolandlovely/pages/collaborations/CollaborationDetailPage.js +139 -121
- package/dist/coolandlovely/pages/collaborations/CollaborationDetailPage.js.map +1 -1
- package/dist/coolandlovely/pages/collaborations/CollaborationFormPage.d.ts.map +1 -1
- package/dist/coolandlovely/pages/collaborations/CollaborationFormPage.js +140 -137
- package/dist/coolandlovely/pages/collaborations/CollaborationFormPage.js.map +1 -1
- package/dist/coolandlovely/pages/collaborations/CollaborationsListPage.d.ts.map +1 -1
- package/dist/coolandlovely/pages/collaborations/CollaborationsListPage.js +104 -95
- package/dist/coolandlovely/pages/collaborations/CollaborationsListPage.js.map +1 -1
- package/dist/coolandlovely/pages/commerce/CreatorEarningsPage.d.ts.map +1 -1
- package/dist/coolandlovely/pages/commerce/CreatorEarningsPage.js +49 -40
- package/dist/coolandlovely/pages/commerce/CreatorEarningsPage.js.map +1 -1
- package/dist/coolandlovely/pages/items/StoreListedPieceView.d.ts.map +1 -1
- package/dist/coolandlovely/pages/items/StoreListedPieceView.js +130 -123
- package/dist/coolandlovely/pages/items/StoreListedPieceView.js.map +1 -1
- package/dist/coolandlovely/pages/items/StyleItemDetailPage.d.ts.map +1 -1
- package/dist/coolandlovely/pages/items/StyleItemDetailPage.js +241 -230
- package/dist/coolandlovely/pages/items/StyleItemDetailPage.js.map +1 -1
- package/dist/coolandlovely/pages/lookbooks/LookbookDetailPage.d.ts.map +1 -1
- package/dist/coolandlovely/pages/lookbooks/LookbookDetailPage.js +64 -119
- package/dist/coolandlovely/pages/lookbooks/LookbookDetailPage.js.map +1 -1
- package/dist/coolandlovely/pages/marketplace/CreatorMarketplacePage.d.ts +2 -0
- package/dist/coolandlovely/pages/marketplace/CreatorMarketplacePage.d.ts.map +1 -0
- package/dist/coolandlovely/pages/marketplace/CreatorMarketplacePage.js +714 -0
- package/dist/coolandlovely/pages/marketplace/CreatorMarketplacePage.js.map +1 -0
- package/dist/coolandlovely/pages/profile/StyleProfilePage.d.ts.map +1 -1
- package/dist/coolandlovely/pages/profile/StyleProfilePage.js +214 -209
- package/dist/coolandlovely/pages/profile/StyleProfilePage.js.map +1 -1
- package/dist/coolandlovely/pages/wardrobe/WardrobeListPage.d.ts.map +1 -1
- package/dist/coolandlovely/pages/wardrobe/WardrobeListPage.js +83 -49
- package/dist/coolandlovely/pages/wardrobe/WardrobeListPage.js.map +1 -1
- package/dist/coolandlovely/types/index.d.ts +5 -0
- package/dist/coolandlovely/types/index.d.ts.map +1 -1
- package/dist/generated/wspace-operations.d.ts +931 -2
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +221 -1
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +539 -1
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.js +14 -0
- package/dist/generated/wspace-types.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreatorMarketplace.js","names":[],"sources":["../../../src/coolandlovely/hooks/useCreatorMarketplace.ts"],"sourcesContent":["import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { print } from 'graphql';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { clearGraphqlFetchResponseCache } from '@burdenoff/fe-libs/shared/graphql/fetch';\n\nimport { useCoolAndLovely } from '../context';\nimport {\n CooMarketplaceMyOffersDocument,\n CooMarketplacePublishedOffersDocument,\n CooMarketplaceOfferDocument,\n CooMarketplaceProposalBrandsDocument,\n CooMarketplaceInboxDocument,\n CooMarketplaceCreateOfferDocument,\n CooMarketplaceUpdateOfferDocument,\n CooMarketplacePublishOfferDocument,\n CooMarketplaceArchiveOfferDocument,\n CooMarketplaceProposeOfferDocument,\n CooMarketplaceRespondDocument,\n type CooMarketplaceMyOffersQuery,\n type CooMarketplacePublishedOffersQuery,\n type CooMarketplaceOfferQuery,\n type CooMarketplaceProposalBrandsQuery,\n type CooMarketplaceInboxQuery,\n type CooMarketplaceCreateOfferMutation,\n type CooMarketplaceCreateOfferMutationVariables,\n type CooMarketplaceUpdateOfferMutation,\n type CooMarketplaceUpdateOfferMutationVariables,\n type CooMarketplacePublishOfferMutation,\n type CooMarketplacePublishOfferMutationVariables,\n type CooMarketplaceArchiveOfferMutation,\n type CooMarketplaceArchiveOfferMutationVariables,\n type CooMarketplaceProposeOfferMutation,\n type CooMarketplaceProposeOfferMutationVariables,\n type CooMarketplaceRespondMutation,\n type CooMarketplaceRespondMutationVariables,\n} from '../../generated/wspace-operations';\nimport type { CooProposalDirection } from '../../generated/wspace-types';\n\nexport type {\n CooMarketplaceRateCardFragment as CreatorOffer,\n CooMarketplaceProposalFragment as CreatorProposal,\n} from '../../generated/wspace-operations';\nconst KEY = ['coolandlovely', 'creator-marketplace'] as const;\nexport const MARKETPLACE_PAGE_SIZE = 20;\n\nfunction useRequest() {\n const { apiGatewayUrl, workspaceId, organizationId, tenantId, currentUser } = useCoolAndLovely();\n const ready = Boolean(workspaceId && currentUser?.id);\n const request = async <T>(\n query: string,\n variables: Record<string, unknown>,\n signal?: AbortSignal\n ): Promise<T> => {\n const result = await graphqlFetch<T>({\n gateway: 'workspace',\n baseUrl: apiGatewayUrl,\n workspaceToken: true,\n workspaceId: workspaceId ?? undefined,\n organizationId: organizationId ?? undefined,\n tenantId: tenantId ?? undefined,\n query,\n variables,\n signal,\n }).catch((error: unknown) => {\n if (error instanceof Error && 'errors' in error && Array.isArray(error.errors)) {\n throw Object.assign(error, { graphQLErrors: error.errors });\n }\n throw error;\n });\n if (result.errors?.length) {\n throw Object.assign(\n new Error(result.errors[0]?.message ?? 'The request could not be completed.'),\n { graphQLErrors: result.errors }\n );\n }\n if (!result.data) throw new Error('The request did not return data.');\n return result.data;\n };\n return { request, ready };\n}\n\nexport function useCreatorOffers(mode: 'mine' | 'published', page: number, enabled = true) {\n const { request, ready } = useRequest();\n return useQuery({\n queryKey: [...KEY, mode, page],\n enabled: enabled && ready,\n staleTime: 0,\n queryFn: async ({ signal }) => {\n const variables = { limit: MARKETPLACE_PAGE_SIZE, offset: page * MARKETPLACE_PAGE_SIZE };\n return mode === 'mine'\n ? (\n await request<CooMarketplaceMyOffersQuery>(\n print(CooMarketplaceMyOffersDocument),\n variables,\n signal\n )\n ).cooMyCreatorRateCards\n : (\n await request<CooMarketplacePublishedOffersQuery>(\n print(CooMarketplacePublishedOffersDocument),\n variables,\n signal\n )\n ).cooPublishedCreatorRateCards;\n },\n });\n}\nexport function useCreatorOffer(id: string | undefined, enabled = false) {\n const { request, ready } = useRequest();\n return useQuery({\n queryKey: [...KEY, 'offer', id],\n enabled: enabled && ready && Boolean(id),\n staleTime: 0,\n queryFn: async ({ signal }) => {\n if (!id) throw new Error('Choose an offer.');\n return (\n await request<CooMarketplaceOfferQuery>(print(CooMarketplaceOfferDocument), { id }, signal)\n ).cooCreatorRateCard;\n },\n });\n}\nexport function useProposalBrands(page: number, enabled: boolean) {\n const { request, ready } = useRequest();\n return useQuery({\n queryKey: [...KEY, 'brands', page],\n enabled: enabled && ready,\n staleTime: 0,\n queryFn: async ({ signal }) =>\n (\n await request<CooMarketplaceProposalBrandsQuery>(\n print(CooMarketplaceProposalBrandsDocument),\n { limit: MARKETPLACE_PAGE_SIZE, offset: page * MARKETPLACE_PAGE_SIZE },\n signal\n )\n ).cooMyProposalBrands,\n });\n}\nexport function useCreatorInbox(direction: CooProposalDirection, page: number, enabled: boolean) {\n const { request, ready } = useRequest();\n return useQuery({\n queryKey: [...KEY, 'inbox', direction, page],\n enabled: enabled && ready,\n staleTime: 0,\n queryFn: async ({ signal }) =>\n (\n await request<CooMarketplaceInboxQuery>(\n print(CooMarketplaceInboxDocument),\n { direction, limit: MARKETPLACE_PAGE_SIZE, offset: page * MARKETPLACE_PAGE_SIZE },\n signal\n )\n ).cooMyProposalInbox,\n });\n}\n\nfunction useAction<TData, TVariables extends Record<string, unknown>>(query: string) {\n const { request } = useRequest();\n const client = useQueryClient();\n return useMutation({\n mutationFn: (variables: TVariables) => request<TData>(query, variables),\n onSuccess: async () => {\n clearGraphqlFetchResponseCache();\n await Promise.all([\n client.invalidateQueries({ queryKey: KEY }),\n client.invalidateQueries({ queryKey: ['coolandlovely', 'collaborations'] }),\n client.invalidateQueries({ queryKey: ['coolandlovely', 'collaboration'] }),\n ]);\n },\n });\n}\nexport const useCreateCreatorOffer = () =>\n useAction<CooMarketplaceCreateOfferMutation, CooMarketplaceCreateOfferMutationVariables>(\n print(CooMarketplaceCreateOfferDocument)\n );\nexport const useUpdateCreatorOffer = () =>\n useAction<CooMarketplaceUpdateOfferMutation, CooMarketplaceUpdateOfferMutationVariables>(\n print(CooMarketplaceUpdateOfferDocument)\n );\nexport const usePublishCreatorOffer = () =>\n useAction<CooMarketplacePublishOfferMutation, CooMarketplacePublishOfferMutationVariables>(\n print(CooMarketplacePublishOfferDocument)\n );\nexport const useArchiveCreatorOffer = () =>\n useAction<CooMarketplaceArchiveOfferMutation, CooMarketplaceArchiveOfferMutationVariables>(\n print(CooMarketplaceArchiveOfferDocument)\n );\nexport const useProposeCreatorOffer = () =>\n useAction<CooMarketplaceProposeOfferMutation, CooMarketplaceProposeOfferMutationVariables>(\n print(CooMarketplaceProposeOfferDocument)\n );\nexport const useRespondToCreatorProposal = () =>\n useAction<CooMarketplaceRespondMutation, CooMarketplaceRespondMutationVariables>(\n print(CooMarketplaceRespondDocument)\n );\n"],"mappings":";;;;;;;;AA0CA,IAAM,IAAM,CAAC,iBAAiB,qBAAqB;AAGnD,SAAS,IAAa;CACpB,IAAM,EAAE,kBAAe,gBAAa,mBAAgB,aAAU,mBAAgB,EAAiB;CAgC/F,OAAO;EAAE,gBA7BP,GACA,GACA,MACe;GACf,IAAM,IAAS,MAAM,EAAgB;IACnC,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,aAAa,KAAe,KAAA;IAC5B,gBAAgB,KAAkB,KAAA;IAClC,UAAU,KAAY,KAAA;IACtB;IACA;IACA;GACF,CAAC,CAAC,CAAC,OAAO,MAAmB;IAI3B,MAHI,aAAiB,SAAS,YAAY,KAAS,MAAM,QAAQ,EAAM,MAAM,IACrE,OAAO,OAAO,GAAO,EAAE,eAAe,EAAM,OAAO,CAAC,IAEtD;GACR,CAAC;GACD,IAAI,EAAO,QAAQ,QACjB,MAAM,OAAO,OACP,MAAM,EAAO,OAAO,EAAE,EAAE,WAAW,qCAAqC,GAC5E,EAAE,eAAe,EAAO,OAAO,CACjC;GAEF,IAAI,CAAC,EAAO,MAAM,MAAU,MAAM,kCAAkC;GACpE,OAAO,EAAO;EAChB;EACkB,QA/BJ,EAAQ,KAAe,GAAa;CA+B1B;AAC1B;AAEA,SAAgB,EAAiB,GAA4B,GAAc,IAAU,IAAM;CACzF,IAAM,EAAE,YAAS,aAAU,EAAW;CACtC,OAAO,EAAS;EACd,UAAU;GAAC,GAAG;GAAK;GAAM;EAAI;EAC7B,SAAS,KAAW;EACpB,WAAW;EACX,SAAS,OAAO,EAAE,gBAAa;GAC7B,IAAM,IAAY;IAAE,OAAA;IAA8B,QAAQ,IAAA;GAA6B;GACvF,OAAO,MAAS,UAEV,MAAM,EACJ,EAAM,CAA8B,GACpC,GACA,CACF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AC/B,MAAM,QAAQ,IAAI;IAChB,EAAO,kBAAkB,EAAE,UAAU,EAAI,CAAC;IAC1C,EAAO,kBAAkB,EAAE,UAAU,CAAC,iBAAiB,gBAAgB,EAAE,CAAC;IAC1E,EAAO,kBAAkB,EAAE,UAAU,CAAC,iBAAiB,eAAe,EAAE,CAAC;GAC3E,CAAC;EACH;CACF,CAAC;AACH;AACA,IAAa,UACX,EACE,EAAM,CAAiC,CACzC,GACW,UACX,EACE,EAAM,CAAiC,CACzC,GACW,UACX,EACE,EAAM,CAAkC,CAC1C,GACW,UACX,EACE,EAAM,CAAkC,CAC1C,GACW,UACX,EACE,EAAM,CAAkC,CAC1C,GACW,UACX,EACE,EAAM,CAA6B,CACrC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CooPriceDetailQuery } from '../../generated/wspace-operations';
|
|
2
|
+
import { CooPriceAlertInput } from '../../generated/wspace-types';
|
|
3
|
+
|
|
4
|
+
/** One request for the current card page; linked IDs only, never a per-card request burst. */
|
|
5
|
+
export declare function useBestPrices(styleItemIds: string[], currency: string): import('@tanstack/react-query').UseQueryResult<{
|
|
6
|
+
__typename?: "CooBestPriceSummary";
|
|
7
|
+
styleItemId: string;
|
|
8
|
+
currency: string;
|
|
9
|
+
lowestPriceMinor?: number | null;
|
|
10
|
+
offerCount: number;
|
|
11
|
+
}[], Error>;
|
|
12
|
+
/** History and full merchant details are loaded only when the shopper asks to compare. */
|
|
13
|
+
export declare function usePriceDetail(styleItemId: string, currency: string, start: string, end: string, enabled: boolean): import('@tanstack/react-query').UseQueryResult<CooPriceDetailQuery, Error>;
|
|
14
|
+
export declare function usePriceWatches(offset: number): import('@tanstack/react-query').UseQueryResult<{
|
|
15
|
+
__typename?: "CooPriceAlertConnection";
|
|
16
|
+
items: Array<{
|
|
17
|
+
__typename?: "CooPriceAlert";
|
|
18
|
+
id: string;
|
|
19
|
+
styleItemId: string;
|
|
20
|
+
kind: import('../../generated/wspace-types').CooPriceAlertKind;
|
|
21
|
+
currency: string;
|
|
22
|
+
targetPriceMinor?: number | null;
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
lastEvaluatedAt?: string | null;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
}>;
|
|
27
|
+
pageInfo: {
|
|
28
|
+
__typename?: "CooPageInfo";
|
|
29
|
+
hasMore: boolean;
|
|
30
|
+
cursor?: string | null;
|
|
31
|
+
};
|
|
32
|
+
}, Error>;
|
|
33
|
+
export declare function usePriceWatchDeliveries(alertId: string, offset: number, enabled: boolean): import('@tanstack/react-query').UseQueryResult<{
|
|
34
|
+
__typename?: "CooPriceAlertDeliveryConnection";
|
|
35
|
+
items: Array<{
|
|
36
|
+
__typename?: "CooPriceAlertDelivery";
|
|
37
|
+
id: string;
|
|
38
|
+
status: string;
|
|
39
|
+
notificationId?: string | null;
|
|
40
|
+
lastErrorCode?: string | null;
|
|
41
|
+
createdAt: string;
|
|
42
|
+
deliveredAt?: string | null;
|
|
43
|
+
}>;
|
|
44
|
+
pageInfo: {
|
|
45
|
+
__typename?: "CooPageInfo";
|
|
46
|
+
hasMore: boolean;
|
|
47
|
+
cursor?: string | null;
|
|
48
|
+
};
|
|
49
|
+
}, Error>;
|
|
50
|
+
export declare function usePriceWatchAction(): import('@tanstack/react-query').UseMutationResult<void, Error, {
|
|
51
|
+
kind: "save";
|
|
52
|
+
input: CooPriceAlertInput;
|
|
53
|
+
} | {
|
|
54
|
+
kind: "remove";
|
|
55
|
+
id: string;
|
|
56
|
+
}, unknown>;
|
|
57
|
+
//# sourceMappingURL=usePriceApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePriceApi.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/hooks/usePriceApi.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAIV,mBAAmB,EAGpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAqBvE,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM;;;;;;YAiBrE;AAED,0FAA0F;AAC1F,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,8EAejB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM;;;kBAgEs2L,CAAC;;;;;wBAAqH,CAAC;;uBAAkD,CAAC;;;;kBAA6D,CAAC;;cAAyC,CAAC;;UAjDrqM;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;;;kBA+C27M,CAAC;;;sBAAqE,CAAC;qBAA8B,CAAC;;mBAA+C,CAAC;;;kBAA0C,CAAC;;cAAyC,CAAC;;UAhC9vN;AAED,wBAAgB,mBAAmB;UAKb,MAAM;WAAS,kBAAkB;;UAAa,QAAQ;QAAM,MAAM;YAwBvF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useCoolAndLovely as e } from "../context/CoolAndLovelyContext.js";
|
|
2
|
+
import "../context/index.js";
|
|
3
|
+
import { coolQuery as t } from "./useCoolAndLovelyApi.js";
|
|
4
|
+
import { CooBestPricesDocument as n, CooMyPriceWatchDeliveriesDocument as r, CooMyPriceWatchesDocument as i, CooPriceDetailDocument as a, CooRemovePriceWatchDocument as o, CooSavePriceWatchDocument as s } from "../../generated/wspace-operations.js";
|
|
5
|
+
import { useMutation as c, useQuery as l, useQueryClient as u } from "@tanstack/react-query";
|
|
6
|
+
import { print as d } from "graphql";
|
|
7
|
+
//#region src/coolandlovely/hooks/usePriceApi.ts
|
|
8
|
+
function f() {
|
|
9
|
+
let { apiGatewayUrl: t, tenantId: n, organizationId: r, workspaceId: i, currentUser: a } = e();
|
|
10
|
+
return {
|
|
11
|
+
apiGatewayUrl: t,
|
|
12
|
+
key: [
|
|
13
|
+
"coolandlovely",
|
|
14
|
+
"prices",
|
|
15
|
+
t,
|
|
16
|
+
n,
|
|
17
|
+
r,
|
|
18
|
+
i,
|
|
19
|
+
a?.id
|
|
20
|
+
],
|
|
21
|
+
ready: !!(i && a?.id)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function p(e, r) {
|
|
25
|
+
let i = f(), a = [...new Set(e)].sort();
|
|
26
|
+
return l({
|
|
27
|
+
queryKey: [
|
|
28
|
+
...i.key,
|
|
29
|
+
"best",
|
|
30
|
+
r,
|
|
31
|
+
a
|
|
32
|
+
],
|
|
33
|
+
enabled: i.ready && a.length > 0 && a.length <= 100,
|
|
34
|
+
staleTime: 3e4,
|
|
35
|
+
queryFn: async ({ signal: e }) => (await t(d(n), {
|
|
36
|
+
styleItemIds: a,
|
|
37
|
+
currency: r
|
|
38
|
+
}, i.apiGatewayUrl, e)).cooBestPrices
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function m(e, n, r, i, o) {
|
|
42
|
+
let s = f();
|
|
43
|
+
return l({
|
|
44
|
+
queryKey: [
|
|
45
|
+
...s.key,
|
|
46
|
+
"detail",
|
|
47
|
+
e,
|
|
48
|
+
n,
|
|
49
|
+
r,
|
|
50
|
+
i
|
|
51
|
+
],
|
|
52
|
+
enabled: s.ready && !!e && o,
|
|
53
|
+
staleTime: 3e4,
|
|
54
|
+
queryFn: ({ signal: o }) => t(d(a), {
|
|
55
|
+
styleItemId: e,
|
|
56
|
+
currency: n,
|
|
57
|
+
start: r,
|
|
58
|
+
end: i
|
|
59
|
+
}, s.apiGatewayUrl, o)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function h(e) {
|
|
63
|
+
let n = f();
|
|
64
|
+
return l({
|
|
65
|
+
queryKey: [
|
|
66
|
+
...n.key,
|
|
67
|
+
"watches",
|
|
68
|
+
e
|
|
69
|
+
],
|
|
70
|
+
enabled: n.ready,
|
|
71
|
+
queryFn: async ({ signal: r }) => (await t(d(i), { pagination: {
|
|
72
|
+
offset: e,
|
|
73
|
+
limit: 20
|
|
74
|
+
} }, n.apiGatewayUrl, r)).cooMyPriceAlerts
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function g(e, n, i) {
|
|
78
|
+
let a = f();
|
|
79
|
+
return l({
|
|
80
|
+
queryKey: [
|
|
81
|
+
...a.key,
|
|
82
|
+
"receipts",
|
|
83
|
+
e,
|
|
84
|
+
n
|
|
85
|
+
],
|
|
86
|
+
enabled: a.ready && !!e && i,
|
|
87
|
+
queryFn: async ({ signal: i }) => (await t(d(r), {
|
|
88
|
+
alertId: e,
|
|
89
|
+
pagination: {
|
|
90
|
+
offset: n,
|
|
91
|
+
limit: 20
|
|
92
|
+
}
|
|
93
|
+
}, a.apiGatewayUrl, i)).cooMyPriceAlertDeliveries
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function _() {
|
|
97
|
+
let e = f(), n = u();
|
|
98
|
+
return c({
|
|
99
|
+
mutationFn: async (n) => {
|
|
100
|
+
if (n.kind === "save") await t(d(s), { input: n.input }, e.apiGatewayUrl);
|
|
101
|
+
else if (!(await t(d(o), { id: n.id }, e.apiGatewayUrl)).cooDeletePriceAlert) throw Error("The price watch was not removed.");
|
|
102
|
+
},
|
|
103
|
+
onSuccess: async () => {
|
|
104
|
+
await Promise.all([n.invalidateQueries({ queryKey: [...e.key, "watches"] }), n.invalidateQueries({ queryKey: [...e.key, "receipts"] })]);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { p as useBestPrices, m as usePriceDetail, _ as usePriceWatchAction, g as usePriceWatchDeliveries, h as usePriceWatches };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=usePriceApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePriceApi.js","names":[],"sources":["../../../src/coolandlovely/hooks/usePriceApi.ts"],"sourcesContent":["import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { print } from 'graphql';\n\nimport {\n CooBestPricesDocument,\n CooMyPriceWatchesDocument,\n CooMyPriceWatchDeliveriesDocument,\n CooPriceDetailDocument,\n CooRemovePriceWatchDocument,\n CooSavePriceWatchDocument,\n} from '../../generated/wspace-operations';\nimport type {\n CooBestPricesQuery,\n CooMyPriceWatchesQuery,\n CooMyPriceWatchDeliveriesQuery,\n CooPriceDetailQuery,\n CooRemovePriceWatchMutation,\n CooSavePriceWatchMutation,\n} from '../../generated/wspace-operations';\nimport type { CooPriceAlertInput } from '../../generated/wspace-types';\nimport { useCoolAndLovely } from '../context';\nimport { coolQuery } from './useCoolAndLovelyApi';\n\nfunction usePriceScope() {\n const { apiGatewayUrl, tenantId, organizationId, workspaceId, currentUser } = useCoolAndLovely();\n return {\n apiGatewayUrl,\n key: [\n 'coolandlovely',\n 'prices',\n apiGatewayUrl,\n tenantId,\n organizationId,\n workspaceId,\n currentUser?.id,\n ],\n ready: Boolean(workspaceId && currentUser?.id),\n };\n}\n\n/** One request for the current card page; linked IDs only, never a per-card request burst. */\nexport function useBestPrices(styleItemIds: string[], currency: string) {\n const scope = usePriceScope();\n const ids = [...new Set(styleItemIds)].sort();\n return useQuery({\n queryKey: [...scope.key, 'best', currency, ids],\n enabled: scope.ready && ids.length > 0 && ids.length <= 100,\n staleTime: 30_000,\n queryFn: async ({ signal }) =>\n (\n await coolQuery<CooBestPricesQuery>(\n print(CooBestPricesDocument),\n { styleItemIds: ids, currency },\n scope.apiGatewayUrl,\n signal\n )\n ).cooBestPrices,\n });\n}\n\n/** History and full merchant details are loaded only when the shopper asks to compare. */\nexport function usePriceDetail(\n styleItemId: string,\n currency: string,\n start: string,\n end: string,\n enabled: boolean\n) {\n const scope = usePriceScope();\n return useQuery({\n queryKey: [...scope.key, 'detail', styleItemId, currency, start, end],\n enabled: scope.ready && Boolean(styleItemId) && enabled,\n staleTime: 30_000,\n queryFn: ({ signal }) =>\n coolQuery<CooPriceDetailQuery>(\n print(CooPriceDetailDocument),\n { styleItemId, currency, start, end },\n scope.apiGatewayUrl,\n signal\n ),\n });\n}\n\nexport function usePriceWatches(offset: number) {\n const scope = usePriceScope();\n return useQuery({\n queryKey: [...scope.key, 'watches', offset],\n enabled: scope.ready,\n queryFn: async ({ signal }) =>\n (\n await coolQuery<CooMyPriceWatchesQuery>(\n print(CooMyPriceWatchesDocument),\n { pagination: { offset, limit: 20 } },\n scope.apiGatewayUrl,\n signal\n )\n ).cooMyPriceAlerts,\n });\n}\n\nexport function usePriceWatchDeliveries(alertId: string, offset: number, enabled: boolean) {\n const scope = usePriceScope();\n return useQuery({\n queryKey: [...scope.key, 'receipts', alertId, offset],\n enabled: scope.ready && Boolean(alertId) && enabled,\n queryFn: async ({ signal }) =>\n (\n await coolQuery<CooMyPriceWatchDeliveriesQuery>(\n print(CooMyPriceWatchDeliveriesDocument),\n { alertId, pagination: { offset, limit: 20 } },\n scope.apiGatewayUrl,\n signal\n )\n ).cooMyPriceAlertDeliveries,\n });\n}\n\nexport function usePriceWatchAction() {\n const scope = usePriceScope();\n const client = useQueryClient();\n return useMutation({\n mutationFn: async (\n action: { kind: 'save'; input: CooPriceAlertInput } | { kind: 'remove'; id: string }\n ) => {\n if (action.kind === 'save') {\n await coolQuery<CooSavePriceWatchMutation>(\n print(CooSavePriceWatchDocument),\n { input: action.input },\n scope.apiGatewayUrl\n );\n } else {\n const result = await coolQuery<CooRemovePriceWatchMutation>(\n print(CooRemovePriceWatchDocument),\n { id: action.id },\n scope.apiGatewayUrl\n );\n if (!result.cooDeletePriceAlert) throw new Error('The price watch was not removed.');\n }\n },\n onSuccess: async () => {\n await Promise.all([\n client.invalidateQueries({ queryKey: [...scope.key, 'watches'] }),\n client.invalidateQueries({ queryKey: [...scope.key, 'receipts'] }),\n ]);\n },\n });\n}\n"],"mappings":";;;;;;;AAuBA,SAAS,IAAgB;CACvB,IAAM,EAAE,kBAAe,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;CAC5B,OAAO,EAAS;EACd,UAAU;GAAC,GAAG,EAAM;GAAK;GAAY;GAAS;EAAM;EACpD,SAAS,EAAM,SAAS,EAAQ,KAAY;EAC5C,SAAS,OAAO,EAAE,iBAEd,MAAM,EACJ,EAAM,CAAiC,GACvC;GAAE;GAAS,YAAY;IAAE;IAAQ,OAAO;GAAG;EAAE,GAC7C,EAAM,eACN,CACF,EAAA,CACA;CACN,CAAC;AACH;AAEA,SAAgB,IAAsB;CACpC,IAAM,IAAQ,EAAc,GACtB,IAAS,EAAe;CAC9B,OAAO,EAAY;EACjB,YAAY,OACV,MACG;GACH,IAAI,EAAO,SAAS,QAClB,MAAM,EACJ,EAAM,CAAyB,GAC/B,EAAE,OAAO,EAAO,MAAM,GACtB,EAAM,aACR;QAOA,IAAI,EAAC,MALgB,EACnB,EAAM,CAA2B,GACjC,EAAE,IAAI,EAAO,GAAG,GAChB,EAAM,aACR,EAAA,CACY,qBAAqB,MAAU,MAAM,kCAAkC;EAEvF;EACA,WAAW,YAAY;GACrB,MAAM,QAAQ,IAAI,CAChB,EAAO,kBAAkB,EAAE,UAAU,CAAC,GAAG,EAAM,KAAK,SAAS,EAAE,CAAC,GAChE,EAAO,kBAAkB,EAAE,UAAU,CAAC,GAAG,EAAM,KAAK,UAAU,EAAE,CAAC,CACnE,CAAC;EACH;CACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollaborationDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/coolandlovely/pages/collaborations/CollaborationDetailPage.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"CollaborationDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/coolandlovely/pages/collaborations/CollaborationDetailPage.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA4CH,wBAAgB,uBAAuB,gCA+QtC"}
|