@burdenoff/microfe-coolandlovely 2026.1024.4 → 2026.1027.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/coolandlovely/CoolAndLovelyRoutes.d.ts.map +1 -1
  2. package/dist/coolandlovely/CoolAndLovelyRoutes.js +20 -12
  3. package/dist/coolandlovely/CoolAndLovelyRoutes.js.map +1 -1
  4. package/dist/coolandlovely/components/FulfilmentTimeline.d.ts +7 -0
  5. package/dist/coolandlovely/components/FulfilmentTimeline.d.ts.map +1 -0
  6. package/dist/coolandlovely/components/FulfilmentTimeline.js +77 -0
  7. package/dist/coolandlovely/components/FulfilmentTimeline.js.map +1 -0
  8. package/dist/coolandlovely/components/RefundPanel.d.ts +8 -0
  9. package/dist/coolandlovely/components/RefundPanel.d.ts.map +1 -0
  10. package/dist/coolandlovely/components/RefundPanel.js +113 -0
  11. package/dist/coolandlovely/components/RefundPanel.js.map +1 -0
  12. package/dist/coolandlovely/components/StatusBadge.d.ts.map +1 -1
  13. package/dist/coolandlovely/components/StatusBadge.js +17 -1
  14. package/dist/coolandlovely/components/StatusBadge.js.map +1 -1
  15. package/dist/coolandlovely/hooks/useBrandOrdersApi.d.ts +12 -0
  16. package/dist/coolandlovely/hooks/useBrandOrdersApi.d.ts.map +1 -0
  17. package/dist/coolandlovely/hooks/useBrandOrdersApi.js +124 -0
  18. package/dist/coolandlovely/hooks/useBrandOrdersApi.js.map +1 -0
  19. package/dist/coolandlovely/hooks/useCommerceApi.d.ts +4 -0
  20. package/dist/coolandlovely/hooks/useCommerceApi.d.ts.map +1 -1
  21. package/dist/coolandlovely/hooks/useCommerceApi.js +28 -23
  22. package/dist/coolandlovely/hooks/useCommerceApi.js.map +1 -1
  23. package/dist/coolandlovely/pages/brands/BrandDetailPage.d.ts.map +1 -1
  24. package/dist/coolandlovely/pages/brands/BrandDetailPage.js +157 -148
  25. package/dist/coolandlovely/pages/brands/BrandDetailPage.js.map +1 -1
  26. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.d.ts +14 -0
  27. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.d.ts.map +1 -0
  28. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.js +362 -0
  29. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.js.map +1 -0
  30. package/dist/coolandlovely/pages/commerce/CartPage.js +4 -4
  31. package/dist/coolandlovely/pages/commerce/CreatorEarningsPage.d.ts.map +1 -1
  32. package/dist/coolandlovely/pages/commerce/CreatorEarningsPage.js +108 -106
  33. package/dist/coolandlovely/pages/commerce/CreatorEarningsPage.js.map +1 -1
  34. package/dist/coolandlovely/pages/commerce/OrdersPage.d.ts +2 -1
  35. package/dist/coolandlovely/pages/commerce/OrdersPage.d.ts.map +1 -1
  36. package/dist/coolandlovely/pages/commerce/OrdersPage.js +206 -123
  37. package/dist/coolandlovely/pages/commerce/OrdersPage.js.map +1 -1
  38. package/dist/coolandlovely/types/commerce.d.ts +98 -1
  39. package/dist/coolandlovely/types/commerce.d.ts.map +1 -1
  40. package/package.json +1 -1
@@ -0,0 +1,124 @@
1
+ import { useCoolAndLovely as e } from "../context/CoolAndLovelyContext.js";
2
+ import "../context/index.js";
3
+ import { coolQuery as t } from "./useCoolAndLovelyApi.js";
4
+ import { FULFILMENT_FIELDS as n, REFUND_FIELDS as r } from "./useCommerceApi.js";
5
+ import { useMutation as i, useQuery as a, useQueryClient as o } from "@tanstack/react-query";
6
+ //#region src/coolandlovely/hooks/useBrandOrdersApi.ts
7
+ var s = "coolandlovely", c = `
8
+ id orderNumber status brandId currency brandSubtotal itemCount
9
+ shippingName shippingAddress buyerNote paidAt createdAt
10
+ items {
11
+ id styleItemId brandId name sku image { id } size colour unitPrice quantity lineTotal
12
+ lookId isCreatorAttributed
13
+ }
14
+ fulfilment { ${n} }
15
+ refund { ${r} }
16
+ `, l = (n, r) => {
17
+ let { apiGatewayUrl: i } = e();
18
+ return a({
19
+ queryKey: [
20
+ s,
21
+ "brand-orders",
22
+ n,
23
+ r ?? "ALL"
24
+ ],
25
+ enabled: !!n,
26
+ queryFn: async () => (await t(`query CooBrandOrders($brandId: ID!, $fulfilmentStatus: CooFulfilmentStatus, $pagination: PaginationInput) {
27
+ cooBrandOrders(brandId: $brandId, fulfilmentStatus: $fulfilmentStatus, pagination: $pagination) {
28
+ items { ${c} }
29
+ pageInfo { cursor hasMore }
30
+ }
31
+ }`, {
32
+ brandId: n,
33
+ fulfilmentStatus: r,
34
+ pagination: {
35
+ limit: 50,
36
+ offset: 0
37
+ }
38
+ }, i)).cooBrandOrders
39
+ });
40
+ }, u = (n) => {
41
+ let { apiGatewayUrl: r } = e();
42
+ return a({
43
+ queryKey: [
44
+ s,
45
+ "brand-order-summary",
46
+ n
47
+ ],
48
+ enabled: !!n,
49
+ queryFn: async () => (await t("query CooBrandOrderSummary($brandId: ID!) {\n cooBrandOrderSummary(brandId: $brandId) {\n brandId unfulfilled confirmed shipped delivered refunded total\n }\n }", { brandId: n }, r)).cooBrandOrderSummary
50
+ });
51
+ }, d = (n, r) => {
52
+ let { apiGatewayUrl: i } = e();
53
+ return a({
54
+ queryKey: [
55
+ s,
56
+ "brand-order",
57
+ n,
58
+ r
59
+ ],
60
+ enabled: !!n && !!r,
61
+ queryFn: async () => (await t(`query CooBrandOrder($brandId: ID!, $id: ID!) { cooBrandOrder(brandId: $brandId, id: $id) { ${c} } }`, {
62
+ brandId: n,
63
+ id: r
64
+ }, i)).cooBrandOrder
65
+ });
66
+ }, f = () => {
67
+ let { apiGatewayUrl: n } = e(), r = o();
68
+ return i({
69
+ mutationFn: async (e) => (await t(`mutation CooUpdateOrderFulfilment($input: CooUpdateOrderFulfilmentInput!) {
70
+ cooUpdateOrderFulfilment(input: $input) { ${c} }
71
+ }`, { input: e }, n)).cooUpdateOrderFulfilment,
72
+ onSuccess: (e) => {
73
+ r.setQueryData([
74
+ s,
75
+ "brand-order",
76
+ e.brandId,
77
+ e.id
78
+ ], e), r.invalidateQueries({ queryKey: [
79
+ s,
80
+ "brand-orders",
81
+ e.brandId
82
+ ] }), r.invalidateQueries({ queryKey: [
83
+ s,
84
+ "brand-order-summary",
85
+ e.brandId
86
+ ] });
87
+ }
88
+ });
89
+ }, p = () => {
90
+ let { apiGatewayUrl: n } = e(), r = o();
91
+ return i({
92
+ mutationFn: async (e) => (await t(`mutation CooRefundBrandOrder($input: CooRefundBrandOrderInput!) {
93
+ cooRefundBrandOrder(input: $input) { ${c} }
94
+ }`, { input: e }, n)).cooRefundBrandOrder,
95
+ onSuccess: (e) => {
96
+ r.setQueryData([
97
+ s,
98
+ "brand-order",
99
+ e.brandId,
100
+ e.id
101
+ ], e), r.invalidateQueries({ queryKey: [
102
+ s,
103
+ "brand-orders",
104
+ e.brandId
105
+ ] }), r.invalidateQueries({ queryKey: [
106
+ s,
107
+ "brand-order-summary",
108
+ e.brandId
109
+ ] });
110
+ },
111
+ onError: (e, t) => {
112
+ r.invalidateQueries({ queryKey: [
113
+ s,
114
+ "brand-order",
115
+ t.brandId,
116
+ t.orderId
117
+ ] });
118
+ }
119
+ });
120
+ };
121
+ //#endregion
122
+ export { d as useBrandOrder, u as useBrandOrderSummary, l as useBrandOrders, p as useRefundBrandOrder, f as useUpdateOrderFulfilment };
123
+
124
+ //# sourceMappingURL=useBrandOrdersApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBrandOrdersApi.js","names":[],"sources":["../../../src/coolandlovely/hooks/useBrandOrdersApi.ts"],"sourcesContent":["/**\n * Brand order hooks (BOFF-9636)\n * @module coolandlovely/hooks\n *\n * React Query layer over the brand-side order fields of `wspace-coolandlovely-svc`: the paid\n * orders that contain a brand's pieces (only that brand's lines), counts per fulfilment state,\n * and the fulfilment mutation (confirm, ship with tracking, mark delivered).\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport { useCoolAndLovely } from '../context';\nimport type {\n CooBrandOrder,\n CooBrandOrderConnection,\n CooBrandOrderSummary,\n CooFulfilmentStatus,\n CooRefundBrandOrderInput,\n CooUpdateOrderFulfilmentInput,\n} from '../types';\nimport { FULFILMENT_FIELDS, REFUND_FIELDS } from './useCommerceApi';\nimport { coolQuery } from './useCoolAndLovelyApi';\n\nconst QK = 'coolandlovely';\n\nconst BRAND_ORDER_FIELDS = `\n id orderNumber status brandId currency brandSubtotal itemCount\n shippingName shippingAddress buyerNote paidAt createdAt\n items {\n id styleItemId brandId name sku image { id } size colour unitPrice quantity lineTotal\n lookId isCreatorAttributed\n }\n fulfilment { ${FULFILMENT_FIELDS} }\n refund { ${REFUND_FIELDS} }\n`;\n\nexport const useBrandOrders = (\n brandId: string | undefined,\n fulfilmentStatus?: CooFulfilmentStatus\n) => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'brand-orders', brandId, fulfilmentStatus ?? 'ALL'],\n enabled: !!brandId,\n queryFn: async () => {\n const data = await coolQuery<{ cooBrandOrders: CooBrandOrderConnection }>(\n `query CooBrandOrders($brandId: ID!, $fulfilmentStatus: CooFulfilmentStatus, $pagination: PaginationInput) {\n cooBrandOrders(brandId: $brandId, fulfilmentStatus: $fulfilmentStatus, pagination: $pagination) {\n items { ${BRAND_ORDER_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { brandId, fulfilmentStatus, pagination: { limit: 50, offset: 0 } },\n apiGatewayUrl\n );\n return data.cooBrandOrders;\n },\n });\n};\n\nexport const useBrandOrderSummary = (brandId: string | undefined) => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'brand-order-summary', brandId],\n enabled: !!brandId,\n queryFn: async () => {\n const data = await coolQuery<{ cooBrandOrderSummary: CooBrandOrderSummary }>(\n `query CooBrandOrderSummary($brandId: ID!) {\n cooBrandOrderSummary(brandId: $brandId) {\n brandId unfulfilled confirmed shipped delivered refunded total\n }\n }`,\n { brandId },\n apiGatewayUrl\n );\n return data.cooBrandOrderSummary;\n },\n });\n};\n\nexport const useBrandOrder = (brandId: string | undefined, id: string | undefined) => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'brand-order', brandId, id],\n enabled: !!brandId && !!id,\n queryFn: async () => {\n const data = await coolQuery<{ cooBrandOrder: CooBrandOrder | null }>(\n `query CooBrandOrder($brandId: ID!, $id: ID!) { cooBrandOrder(brandId: $brandId, id: $id) { ${BRAND_ORDER_FIELDS} } }`,\n { brandId, id },\n apiGatewayUrl\n );\n return data.cooBrandOrder;\n },\n });\n};\n\nexport const useUpdateOrderFulfilment = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: CooUpdateOrderFulfilmentInput) => {\n const data = await coolQuery<{ cooUpdateOrderFulfilment: CooBrandOrder }>(\n `mutation CooUpdateOrderFulfilment($input: CooUpdateOrderFulfilmentInput!) {\n cooUpdateOrderFulfilment(input: $input) { ${BRAND_ORDER_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.cooUpdateOrderFulfilment;\n },\n onSuccess: (order) => {\n queryClient.setQueryData([QK, 'brand-order', order.brandId, order.id], order);\n void queryClient.invalidateQueries({ queryKey: [QK, 'brand-orders', order.brandId] });\n void queryClient.invalidateQueries({ queryKey: [QK, 'brand-order-summary', order.brandId] });\n },\n });\n};\n\n/**\n * Refund the brand's pieces of an order (BOFF-9702). global-billing returns the money to the\n * shopper, and the creator commissions on the refunded lines are reversed.\n */\nexport const useRefundBrandOrder = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: CooRefundBrandOrderInput) => {\n const data = await coolQuery<{ cooRefundBrandOrder: CooBrandOrder }>(\n `mutation CooRefundBrandOrder($input: CooRefundBrandOrderInput!) {\n cooRefundBrandOrder(input: $input) { ${BRAND_ORDER_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.cooRefundBrandOrder;\n },\n onSuccess: (order) => {\n queryClient.setQueryData([QK, 'brand-order', order.brandId, order.id], order);\n void queryClient.invalidateQueries({ queryKey: [QK, 'brand-orders', order.brandId] });\n void queryClient.invalidateQueries({ queryKey: [QK, 'brand-order-summary', order.brandId] });\n },\n // A failed refund is recorded on the order; refetch so the page shows why.\n onError: (_error, input) => {\n void queryClient.invalidateQueries({\n queryKey: [QK, 'brand-order', input.brandId, input.orderId],\n });\n },\n });\n};\n"],"mappings":";;;;;;AAuBA,IAAM,IAAK,iBAEL,IAAqB;;;;;;;iBAOV,EAAkB;aACtB,EAAc;GAGd,KACX,GACA,MACG;CACH,IAAM,EAAE,qBAAkB,GAAkB;AAC5C,QAAO,EAAS;EACd,UAAU;GAAC;GAAI;GAAgB;GAAS,KAAoB;GAAM;EAClE,SAAS,CAAC,CAAC;EACX,SAAS,aACM,MAAM,EACjB;;sBAEc,EAAmB;;;YAIjC;GAAE;GAAS;GAAkB,YAAY;IAAE,OAAO;IAAI,QAAQ;IAAG;GAAE,EACnE,EACD,EACW;EAEf,CAAC;GAGS,KAAwB,MAAgC;CACnE,IAAM,EAAE,qBAAkB,GAAkB;AAC5C,QAAO,EAAS;EACd,UAAU;GAAC;GAAI;GAAuB;GAAQ;EAC9C,SAAS,CAAC,CAAC;EACX,SAAS,aACM,MAAM,EACjB,wMAKA,EAAE,YAAS,EACX,EACD,EACW;EAEf,CAAC;GAGS,KAAiB,GAA6B,MAA2B;CACpF,IAAM,EAAE,qBAAkB,GAAkB;AAC5C,QAAO,EAAS;EACd,UAAU;GAAC;GAAI;GAAe;GAAS;GAAG;EAC1C,SAAS,CAAC,CAAC,KAAW,CAAC,CAAC;EACxB,SAAS,aACM,MAAM,EACjB,8FAA8F,EAAmB,OACjH;GAAE;GAAS;GAAI,EACf,EACD,EACW;EAEf,CAAC;GAGS,UAAiC;CAC5C,IAAM,EAAE,qBAAkB,GAAkB,EACtC,IAAc,GAAgB;AACpC,QAAO,EAAY;EACjB,YAAY,OAAO,OACJ,MAAM,EACjB;sDAC8C,EAAmB;YAEjE,EAAE,UAAO,EACT,EACD,EACW;EAEd,YAAY,MAAU;AAGf,GAFL,EAAY,aAAa;IAAC;IAAI;IAAe,EAAM;IAAS,EAAM;IAAG,EAAE,EAAM,EACxE,EAAY,kBAAkB,EAAE,UAAU;IAAC;IAAI;IAAgB,EAAM;IAAQ,EAAE,CAAC,EAChF,EAAY,kBAAkB,EAAE,UAAU;IAAC;IAAI;IAAuB,EAAM;IAAQ,EAAE,CAAC;;EAE/F,CAAC;GAOS,UAA4B;CACvC,IAAM,EAAE,qBAAkB,GAAkB,EACtC,IAAc,GAAgB;AACpC,QAAO,EAAY;EACjB,YAAY,OAAO,OACJ,MAAM,EACjB;iDACyC,EAAmB;YAE5D,EAAE,UAAO,EACT,EACD,EACW;EAEd,YAAY,MAAU;AAGf,GAFL,EAAY,aAAa;IAAC;IAAI;IAAe,EAAM;IAAS,EAAM;IAAG,EAAE,EAAM,EACxE,EAAY,kBAAkB,EAAE,UAAU;IAAC;IAAI;IAAgB,EAAM;IAAQ,EAAE,CAAC,EAChF,EAAY,kBAAkB,EAAE,UAAU;IAAC;IAAI;IAAuB,EAAM;IAAQ,EAAE,CAAC;;EAG9F,UAAU,GAAQ,MAAU;AACrB,KAAY,kBAAkB,EACjC,UAAU;IAAC;IAAI;IAAe,EAAM;IAAS,EAAM;IAAQ,EAC5D,CAAC;;EAEL,CAAC"}
@@ -1,5 +1,9 @@
1
1
  import { CooAddToCartInput, CooCart, CooCheckoutInput, CooCreatorEarningConnection, CooCreatorEarningsSummary, CooCreatorPayout, CooOrder, CooOrderCheckout, CooOrderConnection, CooOrderStatus } from '../types';
2
2
 
3
+ /** Per-brand fulfilment (BOFF-9636): shared by the shopper's order detail and the brand view. */
4
+ export declare const FULFILMENT_FIELDS = "\n id orderId brandId brandName status refunded carrier trackingNumber trackingUrl note\n confirmedAt shippedAt deliveredAt updatedAt\n";
5
+ /** A brand's refund of its pieces (BOFF-9702): the shopper's order detail and the brand view. */
6
+ export declare const REFUND_FIELDS = "\n id orderId brandId brandName amount currency reason status failureReason refundedAt createdAt\n";
3
7
  export declare const useMyCart: () => import('@tanstack/react-query').UseQueryResult<NoInfer<CooCart>, Error>;
4
8
  export declare const useAddToCart: () => import('@tanstack/react-query').UseMutationResult<CooCart, Error, {
5
9
  input: CooAddToCartInput;
@@ -1 +1 @@
1
- {"version":3,"file":"useCommerceApi.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/hooks/useCommerceApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EACV,iBAAiB,EACjB,OAAO,EACP,gBAAgB,EAChB,2BAA2B,EAC3B,yBAAyB,EACzB,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACf,MAAM,UAAU,CAAC;AA+BlB,eAAO,MAAM,SAAS,+EAarB,CAAC;AAuBF,eAAO,MAAM,YAAY;WACE,iBAAiB;WAGzC,CAAC;AAEJ,eAAO,MAAM,iBAAiB;QACN,MAAM;cAAY,MAAM;WAK7C,CAAC;AAEJ,eAAO,MAAM,iBAAiB;QACN,MAAM;WAG3B,CAAC;AAMJ,eAAO,MAAM,WAAW,GAAI,SAAS,cAAc,uFAkBlD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,IAAI,MAAM,GAAG,SAAS,oFAchD,CAAC;AAWF,eAAO,MAAM,WAAW,6GAcvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,mGAcjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,2FAc/B,CAAC;AAEF,eAAO,MAAM,cAAc,2FAc1B,CAAC;AAMF,eAAO,MAAM,oBAAoB,mGAqBhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,iGAkBvC,CAAC;AAEF,eAAO,MAAM,uBAAuB;YAII,MAAM;cAAY,MAAM;YAAU,MAAM,GAAG,IAAI;WActF,CAAC"}
1
+ {"version":3,"file":"useCommerceApi.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/hooks/useCommerceApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EACV,iBAAiB,EACjB,OAAO,EACP,gBAAgB,EAChB,2BAA2B,EAC3B,yBAAyB,EACzB,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACf,MAAM,UAAU,CAAC;AAuBlB,iGAAiG;AACjG,eAAO,MAAM,iBAAiB,8IAG7B,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,aAAa,wGAEzB,CAAC;AAkBF,eAAO,MAAM,SAAS,+EAarB,CAAC;AAuBF,eAAO,MAAM,YAAY;WACE,iBAAiB;WAGzC,CAAC;AAEJ,eAAO,MAAM,iBAAiB;QACN,MAAM;cAAY,MAAM;WAK7C,CAAC;AAEJ,eAAO,MAAM,iBAAiB;QACN,MAAM;WAG3B,CAAC;AAMJ,eAAO,MAAM,WAAW,GAAI,SAAS,cAAc,uFAkBlD,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,IAAI,MAAM,GAAG,SAAS,oFAchD,CAAC;AAWF,eAAO,MAAM,WAAW,6GAcvB,CAAC;AAEF,eAAO,MAAM,qBAAqB,mGAcjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,2FAc/B,CAAC;AAEF,eAAO,MAAM,cAAc,2FAc1B,CAAC;AAMF,eAAO,MAAM,oBAAoB,mGAqBhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,iGAkBvC,CAAC;AAEF,eAAO,MAAM,uBAAuB;YAII,MAAM;cAAY,MAAM;YAAU,MAAM,GAAG,IAAI;WActF,CAAC"}
@@ -3,16 +3,21 @@ import "../context/index.js";
3
3
  import { coolQuery as t } from "./useCoolAndLovelyApi.js";
4
4
  import { useMutation as n, useQuery as r, useQueryClient as i } from "@tanstack/react-query";
5
5
  //#region src/coolandlovely/hooks/useCommerceApi.ts
6
- var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colour lookId unitPrice currency lineTotal isPurchasable\n styleItem { id name status image { id } brand { id name } }\n }\n itemCount subtotal currency canCheckout blockedReason\n", s = "\n id orderNumber status currency subtotal taxAmount total itemCount\n shippingName shippingAddress buyerNote paymentProvider paidAt cancelledAt createdAt updatedAt\n items {\n id styleItemId brandId name sku image { id } size colour unitPrice quantity lineTotal\n lookId isCreatorAttributed\n }\n", c = `
6
+ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colour lookId unitPrice currency lineTotal isPurchasable\n styleItem { id name status image { id } brand { id name } }\n }\n itemCount subtotal currency canCheckout blockedReason\n", s = "\n id orderNumber status currency subtotal taxAmount total itemCount\n shippingName shippingAddress buyerNote paymentProvider paidAt cancelledAt refundedAmount refundedAt\n createdAt updatedAt\n items {\n id styleItemId brandId name sku image { id } size colour unitPrice quantity lineTotal\n lookId isCreatorAttributed\n }\n", c = "\n id orderId brandId brandName status refunded carrier trackingNumber trackingUrl note\n confirmedAt shippedAt deliveredAt updatedAt\n", l = "\n id orderId brandId brandName amount currency reason status failureReason refundedAt createdAt\n", u = `
7
+ ${s}
8
+ fulfilmentStatus
9
+ fulfilments { ${c} }
10
+ refunds { ${l} }
11
+ `, d = `
7
12
  order { ${s} }
8
13
  provider providerOrderId razorpayKeyId clientSecret stripePublishableKey subtotal taxAmount total currency
9
- `, l = () => {
14
+ `, f = () => {
10
15
  let { apiGatewayUrl: n } = e();
11
16
  return r({
12
17
  queryKey: [a, "cart"],
13
18
  queryFn: async () => (await t(`query CooMyCart { cooMyCart { ${o} } }`, {}, n)).cooMyCart
14
19
  });
15
- }, u = (r, o) => {
20
+ }, p = (r, o) => {
16
21
  let { apiGatewayUrl: s } = e(), c = i();
17
22
  return n({
18
23
  mutationFn: async (e) => {
@@ -24,9 +29,9 @@ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colo
24
29
  c.setQueryData([a, "cart"], e);
25
30
  }
26
31
  });
27
- }, d = () => u(`mutation CooAddToCart($input: CooAddToCartInput!) { cooAddToCart(input: $input) { ${o} } }`, "cooAddToCart"), f = () => u(`mutation CooUpdateCartItem($id: ID!, $quantity: Int!) {
32
+ }, m = () => p(`mutation CooAddToCart($input: CooAddToCartInput!) { cooAddToCart(input: $input) { ${o} } }`, "cooAddToCart"), h = () => p(`mutation CooUpdateCartItem($id: ID!, $quantity: Int!) {
28
33
  cooUpdateCartItem(id: $id, quantity: $quantity) { ${o} }
29
- }`, "cooUpdateCartItem"), p = () => u(`mutation CooRemoveCartItem($id: ID!) { cooRemoveCartItem(id: $id) { ${o} } }`, "cooRemoveCartItem"), m = (n) => {
34
+ }`, "cooUpdateCartItem"), g = () => p(`mutation CooRemoveCartItem($id: ID!) { cooRemoveCartItem(id: $id) { ${o} } }`, "cooRemoveCartItem"), _ = (n) => {
30
35
  let { apiGatewayUrl: i } = e();
31
36
  return r({
32
37
  queryKey: [
@@ -47,7 +52,7 @@ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colo
47
52
  }
48
53
  }, i)).cooMyOrders
49
54
  });
50
- }, h = (n) => {
55
+ }, v = (n) => {
51
56
  let { apiGatewayUrl: i } = e();
52
57
  return r({
53
58
  queryKey: [
@@ -56,9 +61,9 @@ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colo
56
61
  n
57
62
  ],
58
63
  enabled: !!n,
59
- queryFn: async () => (await t(`query CooMyOrder($id: ID!) { cooMyOrder(id: $id) { ${s} } }`, { id: n }, i)).cooMyOrder
64
+ queryFn: async () => (await t(`query CooMyOrder($id: ID!) { cooMyOrder(id: $id) { ${u} } }`, { id: n }, i)).cooMyOrder
60
65
  });
61
- }, g = () => {
66
+ }, y = () => {
62
67
  let e = i();
63
68
  return (t) => {
64
69
  e.setQueryData([
@@ -67,46 +72,46 @@ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colo
67
72
  t.id
68
73
  ], t), e.invalidateQueries({ queryKey: [a, "orders"] }), e.invalidateQueries({ queryKey: [a, "cart"] });
69
74
  };
70
- }, _ = () => {
71
- let { apiGatewayUrl: r } = e(), i = g();
75
+ }, b = () => {
76
+ let { apiGatewayUrl: r } = e(), i = y();
72
77
  return n({
73
- mutationFn: async (e) => (await t(`mutation CooCheckout($input: CooCheckoutInput!) { cooCheckout(input: $input) { ${c} } }`, { input: e }, r)).cooCheckout,
78
+ mutationFn: async (e) => (await t(`mutation CooCheckout($input: CooCheckoutInput!) { cooCheckout(input: $input) { ${d} } }`, { input: e }, r)).cooCheckout,
74
79
  onSuccess: (e) => i(e.order)
75
80
  });
76
- }, v = () => {
77
- let { apiGatewayUrl: r } = e(), i = g();
81
+ }, x = () => {
82
+ let { apiGatewayUrl: r } = e(), i = y();
78
83
  return n({
79
- mutationFn: async (e) => (await t(`mutation CooResumeOrderPayment($id: ID!) { cooResumeOrderPayment(id: $id) { ${c} } }`, { id: e }, r)).cooResumeOrderPayment,
84
+ mutationFn: async (e) => (await t(`mutation CooResumeOrderPayment($id: ID!) { cooResumeOrderPayment(id: $id) { ${d} } }`, { id: e }, r)).cooResumeOrderPayment,
80
85
  onSuccess: (e) => i(e.order)
81
86
  });
82
- }, y = () => {
87
+ }, S = () => {
83
88
  let { apiGatewayUrl: r } = e();
84
89
  return n({
85
90
  mutationFn: async (e) => (await t(`mutation CooSyncOrderPayment($id: ID!) { cooSyncOrderPayment(id: $id) { ${s} } }`, { id: e }, r)).cooSyncOrderPayment,
86
- onSuccess: g()
91
+ onSuccess: y()
87
92
  });
88
- }, b = () => {
93
+ }, C = () => {
89
94
  let { apiGatewayUrl: r } = e();
90
95
  return n({
91
96
  mutationFn: async (e) => (await t(`mutation CooCancelOrder($id: ID!) { cooCancelOrder(id: $id) { ${s} } }`, { id: e }, r)).cooCancelOrder,
92
- onSuccess: g()
97
+ onSuccess: y()
93
98
  });
94
- }, x = () => {
99
+ }, w = () => {
95
100
  let { apiGatewayUrl: n } = e();
96
101
  return r({
97
102
  queryKey: [a, "creator-earnings"],
98
- queryFn: async () => (await t("query CooMyCreatorEarnings($pagination: PaginationInput) {\n cooMyCreatorEarnings(pagination: $pagination) {\n items {\n id orderId orderNumber lookId collaborationId commissionRate saleAmount amount currency\n availableAt billingSyncStatus createdAt\n }\n pageInfo { cursor hasMore }\n }\n }", { pagination: {
103
+ queryFn: async () => (await t("query CooMyCreatorEarnings($pagination: PaginationInput) {\n cooMyCreatorEarnings(pagination: $pagination) {\n items {\n id orderId orderNumber lookId collaborationId commissionRate saleAmount amount currency\n availableAt billingSyncStatus reversalStatus reversedAt createdAt\n }\n pageInfo { cursor hasMore }\n }\n }", { pagination: {
99
104
  limit: 50,
100
105
  offset: 0
101
106
  } }, n)).cooMyCreatorEarnings
102
107
  });
103
- }, S = () => {
108
+ }, T = () => {
104
109
  let { apiGatewayUrl: n } = e();
105
110
  return r({
106
111
  queryKey: [a, "creator-earnings-summary"],
107
112
  queryFn: async () => (await t("query CooMyCreatorEarningsSummary {\n cooMyCreatorEarningsSummary {\n commissionRate holdDays currency totalLifetimeAmount availableAmount pendingAmount\n reservedAmount paidAmount pendingPayoutCount unsyncedCount billingAvailable\n }\n }", {}, n)).cooMyCreatorEarningsSummary
108
113
  });
109
- }, C = () => {
114
+ }, E = () => {
110
115
  let { apiGatewayUrl: r } = e(), o = i();
111
116
  return n({
112
117
  mutationFn: async (e) => (await t("mutation CooRequestCreatorPayout($input: CooRequestCreatorPayoutInput!) {\n cooRequestCreatorPayout(input: $input) { id status requestedAmount currency createdAt }\n }", { input: e }, r)).cooRequestCreatorPayout,
@@ -116,6 +121,6 @@ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colo
116
121
  });
117
122
  };
118
123
  //#endregion
119
- export { d as useAddToCart, b as useCancelOrder, _ as useCheckout, l as useMyCart, x as useMyCreatorEarnings, S as useMyCreatorEarningsSummary, h as useMyOrder, m as useMyOrders, p as useRemoveCartItem, C as useRequestCreatorPayout, v as useResumeOrderPayment, y as useSyncOrderPayment, f as useUpdateCartItem };
124
+ export { c as FULFILMENT_FIELDS, l as REFUND_FIELDS, m as useAddToCart, C as useCancelOrder, b as useCheckout, f as useMyCart, w as useMyCreatorEarnings, T as useMyCreatorEarningsSummary, v as useMyOrder, _ as useMyOrders, g as useRemoveCartItem, E as useRequestCreatorPayout, x as useResumeOrderPayment, S as useSyncOrderPayment, h as useUpdateCartItem };
120
125
 
121
126
  //# sourceMappingURL=useCommerceApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCommerceApi.js","names":[],"sources":["../../../src/coolandlovely/hooks/useCommerceApi.ts"],"sourcesContent":["/**\n * Commerce API hooks (BOFF-3370)\n * @module coolandlovely/hooks\n *\n * React Query layer over the self-scoped commerce fields of `wspace-coolandlovely-svc`:\n * the shopper's cart, checkout and orders, and the creator's look commissions + payouts.\n * The client never decides that an order is paid — it opens the provider's checkout that\n * global-billing prepared and then asks the backend to settle against billing's record.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport { useCoolAndLovely } from '../context';\nimport type {\n CooAddToCartInput,\n CooCart,\n CooCheckoutInput,\n CooCreatorEarningConnection,\n CooCreatorEarningsSummary,\n CooCreatorPayout,\n CooOrder,\n CooOrderCheckout,\n CooOrderConnection,\n CooOrderStatus,\n} from '../types';\nimport { coolQuery } from './useCoolAndLovelyApi';\n\nconst QK = 'coolandlovely';\n\nconst CART_FIELDS = `\n items {\n id styleItemId quantity size colour lookId unitPrice currency lineTotal isPurchasable\n styleItem { id name status image { id } brand { id name } }\n }\n itemCount subtotal currency canCheckout blockedReason\n`;\n\nconst ORDER_FIELDS = `\n id orderNumber status currency subtotal taxAmount total itemCount\n shippingName shippingAddress buyerNote paymentProvider paidAt cancelledAt createdAt updatedAt\n items {\n id styleItemId brandId name sku image { id } size colour unitPrice quantity lineTotal\n lookId isCreatorAttributed\n }\n`;\n\nconst CHECKOUT_FIELDS = `\n order { ${ORDER_FIELDS} }\n provider providerOrderId razorpayKeyId clientSecret stripePublishableKey subtotal taxAmount total currency\n`;\n\n// ---------------------------------------------------------------------------\n// Cart\n// ---------------------------------------------------------------------------\n\nexport const useMyCart = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'cart'],\n queryFn: async () => {\n const data = await coolQuery<{ cooMyCart: CooCart }>(\n `query CooMyCart { cooMyCart { ${CART_FIELDS} } }`,\n {},\n apiGatewayUrl\n );\n return data.cooMyCart;\n },\n });\n};\n\n/** Every cart mutation answers with the fresh cart, which is written straight into the cache. */\nconst useCartMutation = <TVars>(document: string, field: string) => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (variables: TVars) => {\n const data = await coolQuery<Record<string, CooCart>>(\n document,\n variables as Record<string, unknown>,\n apiGatewayUrl\n );\n const cart = data[field];\n if (!cart) throw new Error('The cart could not be updated');\n return cart;\n },\n onSuccess: (cart) => {\n queryClient.setQueryData([QK, 'cart'], cart);\n },\n });\n};\n\nexport const useAddToCart = () =>\n useCartMutation<{ input: CooAddToCartInput }>(\n `mutation CooAddToCart($input: CooAddToCartInput!) { cooAddToCart(input: $input) { ${CART_FIELDS} } }`,\n 'cooAddToCart'\n );\n\nexport const useUpdateCartItem = () =>\n useCartMutation<{ id: string; quantity: number }>(\n `mutation CooUpdateCartItem($id: ID!, $quantity: Int!) {\n cooUpdateCartItem(id: $id, quantity: $quantity) { ${CART_FIELDS} }\n }`,\n 'cooUpdateCartItem'\n );\n\nexport const useRemoveCartItem = () =>\n useCartMutation<{ id: string }>(\n `mutation CooRemoveCartItem($id: ID!) { cooRemoveCartItem(id: $id) { ${CART_FIELDS} } }`,\n 'cooRemoveCartItem'\n );\n\n// ---------------------------------------------------------------------------\n// Orders + checkout\n// ---------------------------------------------------------------------------\n\nexport const useMyOrders = (status?: CooOrderStatus) => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'orders', status ?? 'ALL'],\n queryFn: async () => {\n const data = await coolQuery<{ cooMyOrders: CooOrderConnection }>(\n `query CooMyOrders($status: CooOrderStatus, $pagination: PaginationInput) {\n cooMyOrders(status: $status, pagination: $pagination) {\n items { ${ORDER_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { status, pagination: { limit: 50, offset: 0 } },\n apiGatewayUrl\n );\n return data.cooMyOrders;\n },\n });\n};\n\nexport const useMyOrder = (id: string | undefined) => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'order', id],\n enabled: !!id,\n queryFn: async () => {\n const data = await coolQuery<{ cooMyOrder: CooOrder | null }>(\n `query CooMyOrder($id: ID!) { cooMyOrder(id: $id) { ${ORDER_FIELDS} } }`,\n { id },\n apiGatewayUrl\n );\n return data.cooMyOrder;\n },\n });\n};\n\nconst useOrderInvalidation = () => {\n const queryClient = useQueryClient();\n return (order: CooOrder) => {\n queryClient.setQueryData([QK, 'order', order.id], order);\n void queryClient.invalidateQueries({ queryKey: [QK, 'orders'] });\n void queryClient.invalidateQueries({ queryKey: [QK, 'cart'] });\n };\n};\n\nexport const useCheckout = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const settle = useOrderInvalidation();\n return useMutation({\n mutationFn: async (input: CooCheckoutInput) => {\n const data = await coolQuery<{ cooCheckout: CooOrderCheckout }>(\n `mutation CooCheckout($input: CooCheckoutInput!) { cooCheckout(input: $input) { ${CHECKOUT_FIELDS} } }`,\n { input },\n apiGatewayUrl\n );\n return data.cooCheckout;\n },\n onSuccess: (checkout) => settle(checkout.order),\n });\n};\n\nexport const useResumeOrderPayment = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const settle = useOrderInvalidation();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await coolQuery<{ cooResumeOrderPayment: CooOrderCheckout }>(\n `mutation CooResumeOrderPayment($id: ID!) { cooResumeOrderPayment(id: $id) { ${CHECKOUT_FIELDS} } }`,\n { id },\n apiGatewayUrl\n );\n return data.cooResumeOrderPayment;\n },\n onSuccess: (checkout) => settle(checkout.order),\n });\n};\n\nexport const useSyncOrderPayment = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const settle = useOrderInvalidation();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await coolQuery<{ cooSyncOrderPayment: CooOrder }>(\n `mutation CooSyncOrderPayment($id: ID!) { cooSyncOrderPayment(id: $id) { ${ORDER_FIELDS} } }`,\n { id },\n apiGatewayUrl\n );\n return data.cooSyncOrderPayment;\n },\n onSuccess: settle,\n });\n};\n\nexport const useCancelOrder = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const settle = useOrderInvalidation();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await coolQuery<{ cooCancelOrder: CooOrder }>(\n `mutation CooCancelOrder($id: ID!) { cooCancelOrder(id: $id) { ${ORDER_FIELDS} } }`,\n { id },\n apiGatewayUrl\n );\n return data.cooCancelOrder;\n },\n onSuccess: settle,\n });\n};\n\n// ---------------------------------------------------------------------------\n// Creator earnings + payouts\n// ---------------------------------------------------------------------------\n\nexport const useMyCreatorEarnings = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'creator-earnings'],\n queryFn: async () => {\n const data = await coolQuery<{ cooMyCreatorEarnings: CooCreatorEarningConnection }>(\n `query CooMyCreatorEarnings($pagination: PaginationInput) {\n cooMyCreatorEarnings(pagination: $pagination) {\n items {\n id orderId orderNumber lookId collaborationId commissionRate saleAmount amount currency\n availableAt billingSyncStatus createdAt\n }\n pageInfo { cursor hasMore }\n }\n }`,\n { pagination: { limit: 50, offset: 0 } },\n apiGatewayUrl\n );\n return data.cooMyCreatorEarnings;\n },\n });\n};\n\nexport const useMyCreatorEarningsSummary = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'creator-earnings-summary'],\n queryFn: async () => {\n const data = await coolQuery<{ cooMyCreatorEarningsSummary: CooCreatorEarningsSummary }>(\n `query CooMyCreatorEarningsSummary {\n cooMyCreatorEarningsSummary {\n commissionRate holdDays currency totalLifetimeAmount availableAmount pendingAmount\n reservedAmount paidAmount pendingPayoutCount unsyncedCount billingAvailable\n }\n }`,\n {},\n apiGatewayUrl\n );\n return data.cooMyCreatorEarningsSummary;\n },\n });\n};\n\nexport const useRequestCreatorPayout = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: { amount: number; currency: string; notes?: string | null }) => {\n const data = await coolQuery<{ cooRequestCreatorPayout: CooCreatorPayout }>(\n `mutation CooRequestCreatorPayout($input: CooRequestCreatorPayoutInput!) {\n cooRequestCreatorPayout(input: $input) { id status requestedAmount currency createdAt }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.cooRequestCreatorPayout;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: [QK, 'creator-earnings-summary'] });\n },\n });\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"useCommerceApi.js","names":[],"sources":["../../../src/coolandlovely/hooks/useCommerceApi.ts"],"sourcesContent":["/**\n * Commerce API hooks (BOFF-3370)\n * @module coolandlovely/hooks\n *\n * React Query layer over the self-scoped commerce fields of `wspace-coolandlovely-svc`:\n * the shopper's cart, checkout and orders, and the creator's look commissions + payouts.\n * The client never decides that an order is paid — it opens the provider's checkout that\n * global-billing prepared and then asks the backend to settle against billing's record.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport { useCoolAndLovely } from '../context';\nimport type {\n CooAddToCartInput,\n CooCart,\n CooCheckoutInput,\n CooCreatorEarningConnection,\n CooCreatorEarningsSummary,\n CooCreatorPayout,\n CooOrder,\n CooOrderCheckout,\n CooOrderConnection,\n CooOrderStatus,\n} from '../types';\nimport { coolQuery } from './useCoolAndLovelyApi';\n\nconst QK = 'coolandlovely';\n\nconst CART_FIELDS = `\n items {\n id styleItemId quantity size colour lookId unitPrice currency lineTotal isPurchasable\n styleItem { id name status image { id } brand { id name } }\n }\n itemCount subtotal currency canCheckout blockedReason\n`;\n\nconst ORDER_FIELDS = `\n id orderNumber status currency subtotal taxAmount total itemCount\n shippingName shippingAddress buyerNote paymentProvider paidAt cancelledAt refundedAmount refundedAt\n createdAt updatedAt\n items {\n id styleItemId brandId name sku image { id } size colour unitPrice quantity lineTotal\n lookId isCreatorAttributed\n }\n`;\n\n/** Per-brand fulfilment (BOFF-9636): shared by the shopper's order detail and the brand view. */\nexport const FULFILMENT_FIELDS = `\n id orderId brandId brandName status refunded carrier trackingNumber trackingUrl note\n confirmedAt shippedAt deliveredAt updatedAt\n`;\n\n/** A brand's refund of its pieces (BOFF-9702): the shopper's order detail and the brand view. */\nexport const REFUND_FIELDS = `\n id orderId brandId brandName amount currency reason status failureReason refundedAt createdAt\n`;\n\nconst ORDER_DETAIL_FIELDS = `\n ${ORDER_FIELDS}\n fulfilmentStatus\n fulfilments { ${FULFILMENT_FIELDS} }\n refunds { ${REFUND_FIELDS} }\n`;\n\nconst CHECKOUT_FIELDS = `\n order { ${ORDER_FIELDS} }\n provider providerOrderId razorpayKeyId clientSecret stripePublishableKey subtotal taxAmount total currency\n`;\n\n// ---------------------------------------------------------------------------\n// Cart\n// ---------------------------------------------------------------------------\n\nexport const useMyCart = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'cart'],\n queryFn: async () => {\n const data = await coolQuery<{ cooMyCart: CooCart }>(\n `query CooMyCart { cooMyCart { ${CART_FIELDS} } }`,\n {},\n apiGatewayUrl\n );\n return data.cooMyCart;\n },\n });\n};\n\n/** Every cart mutation answers with the fresh cart, which is written straight into the cache. */\nconst useCartMutation = <TVars>(document: string, field: string) => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (variables: TVars) => {\n const data = await coolQuery<Record<string, CooCart>>(\n document,\n variables as Record<string, unknown>,\n apiGatewayUrl\n );\n const cart = data[field];\n if (!cart) throw new Error('The cart could not be updated');\n return cart;\n },\n onSuccess: (cart) => {\n queryClient.setQueryData([QK, 'cart'], cart);\n },\n });\n};\n\nexport const useAddToCart = () =>\n useCartMutation<{ input: CooAddToCartInput }>(\n `mutation CooAddToCart($input: CooAddToCartInput!) { cooAddToCart(input: $input) { ${CART_FIELDS} } }`,\n 'cooAddToCart'\n );\n\nexport const useUpdateCartItem = () =>\n useCartMutation<{ id: string; quantity: number }>(\n `mutation CooUpdateCartItem($id: ID!, $quantity: Int!) {\n cooUpdateCartItem(id: $id, quantity: $quantity) { ${CART_FIELDS} }\n }`,\n 'cooUpdateCartItem'\n );\n\nexport const useRemoveCartItem = () =>\n useCartMutation<{ id: string }>(\n `mutation CooRemoveCartItem($id: ID!) { cooRemoveCartItem(id: $id) { ${CART_FIELDS} } }`,\n 'cooRemoveCartItem'\n );\n\n// ---------------------------------------------------------------------------\n// Orders + checkout\n// ---------------------------------------------------------------------------\n\nexport const useMyOrders = (status?: CooOrderStatus) => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'orders', status ?? 'ALL'],\n queryFn: async () => {\n const data = await coolQuery<{ cooMyOrders: CooOrderConnection }>(\n `query CooMyOrders($status: CooOrderStatus, $pagination: PaginationInput) {\n cooMyOrders(status: $status, pagination: $pagination) {\n items { ${ORDER_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { status, pagination: { limit: 50, offset: 0 } },\n apiGatewayUrl\n );\n return data.cooMyOrders;\n },\n });\n};\n\nexport const useMyOrder = (id: string | undefined) => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'order', id],\n enabled: !!id,\n queryFn: async () => {\n const data = await coolQuery<{ cooMyOrder: CooOrder | null }>(\n `query CooMyOrder($id: ID!) { cooMyOrder(id: $id) { ${ORDER_DETAIL_FIELDS} } }`,\n { id },\n apiGatewayUrl\n );\n return data.cooMyOrder;\n },\n });\n};\n\nconst useOrderInvalidation = () => {\n const queryClient = useQueryClient();\n return (order: CooOrder) => {\n queryClient.setQueryData([QK, 'order', order.id], order);\n void queryClient.invalidateQueries({ queryKey: [QK, 'orders'] });\n void queryClient.invalidateQueries({ queryKey: [QK, 'cart'] });\n };\n};\n\nexport const useCheckout = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const settle = useOrderInvalidation();\n return useMutation({\n mutationFn: async (input: CooCheckoutInput) => {\n const data = await coolQuery<{ cooCheckout: CooOrderCheckout }>(\n `mutation CooCheckout($input: CooCheckoutInput!) { cooCheckout(input: $input) { ${CHECKOUT_FIELDS} } }`,\n { input },\n apiGatewayUrl\n );\n return data.cooCheckout;\n },\n onSuccess: (checkout) => settle(checkout.order),\n });\n};\n\nexport const useResumeOrderPayment = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const settle = useOrderInvalidation();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await coolQuery<{ cooResumeOrderPayment: CooOrderCheckout }>(\n `mutation CooResumeOrderPayment($id: ID!) { cooResumeOrderPayment(id: $id) { ${CHECKOUT_FIELDS} } }`,\n { id },\n apiGatewayUrl\n );\n return data.cooResumeOrderPayment;\n },\n onSuccess: (checkout) => settle(checkout.order),\n });\n};\n\nexport const useSyncOrderPayment = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const settle = useOrderInvalidation();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await coolQuery<{ cooSyncOrderPayment: CooOrder }>(\n `mutation CooSyncOrderPayment($id: ID!) { cooSyncOrderPayment(id: $id) { ${ORDER_FIELDS} } }`,\n { id },\n apiGatewayUrl\n );\n return data.cooSyncOrderPayment;\n },\n onSuccess: settle,\n });\n};\n\nexport const useCancelOrder = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const settle = useOrderInvalidation();\n return useMutation({\n mutationFn: async (id: string) => {\n const data = await coolQuery<{ cooCancelOrder: CooOrder }>(\n `mutation CooCancelOrder($id: ID!) { cooCancelOrder(id: $id) { ${ORDER_FIELDS} } }`,\n { id },\n apiGatewayUrl\n );\n return data.cooCancelOrder;\n },\n onSuccess: settle,\n });\n};\n\n// ---------------------------------------------------------------------------\n// Creator earnings + payouts\n// ---------------------------------------------------------------------------\n\nexport const useMyCreatorEarnings = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'creator-earnings'],\n queryFn: async () => {\n const data = await coolQuery<{ cooMyCreatorEarnings: CooCreatorEarningConnection }>(\n `query CooMyCreatorEarnings($pagination: PaginationInput) {\n cooMyCreatorEarnings(pagination: $pagination) {\n items {\n id orderId orderNumber lookId collaborationId commissionRate saleAmount amount currency\n availableAt billingSyncStatus reversalStatus reversedAt createdAt\n }\n pageInfo { cursor hasMore }\n }\n }`,\n { pagination: { limit: 50, offset: 0 } },\n apiGatewayUrl\n );\n return data.cooMyCreatorEarnings;\n },\n });\n};\n\nexport const useMyCreatorEarningsSummary = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n return useQuery({\n queryKey: [QK, 'creator-earnings-summary'],\n queryFn: async () => {\n const data = await coolQuery<{ cooMyCreatorEarningsSummary: CooCreatorEarningsSummary }>(\n `query CooMyCreatorEarningsSummary {\n cooMyCreatorEarningsSummary {\n commissionRate holdDays currency totalLifetimeAmount availableAmount pendingAmount\n reservedAmount paidAmount pendingPayoutCount unsyncedCount billingAvailable\n }\n }`,\n {},\n apiGatewayUrl\n );\n return data.cooMyCreatorEarningsSummary;\n },\n });\n};\n\nexport const useRequestCreatorPayout = () => {\n const { apiGatewayUrl } = useCoolAndLovely();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: async (input: { amount: number; currency: string; notes?: string | null }) => {\n const data = await coolQuery<{ cooRequestCreatorPayout: CooCreatorPayout }>(\n `mutation CooRequestCreatorPayout($input: CooRequestCreatorPayoutInput!) {\n cooRequestCreatorPayout(input: $input) { id status requestedAmount currency createdAt }\n }`,\n { input },\n apiGatewayUrl\n );\n return data.cooRequestCreatorPayout;\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: [QK, 'creator-earnings-summary'] });\n },\n });\n};\n"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"BrandDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/coolandlovely/pages/brands/BrandDetailPage.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+CH,wBAAgB,eAAe,gCAkT9B"}
1
+ {"version":3,"file":"BrandDetailPage.d.ts","sourceRoot":"","sources":["../../../../src/coolandlovely/pages/brands/BrandDetailPage.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyDH,wBAAgB,eAAe,gCAyT9B"}