@burdenoff/microfe-coolandlovely 2026.1026.1 → 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 (29) hide show
  1. package/dist/coolandlovely/components/RefundPanel.d.ts +8 -0
  2. package/dist/coolandlovely/components/RefundPanel.d.ts.map +1 -0
  3. package/dist/coolandlovely/components/RefundPanel.js +113 -0
  4. package/dist/coolandlovely/components/RefundPanel.js.map +1 -0
  5. package/dist/coolandlovely/components/StatusBadge.d.ts.map +1 -1
  6. package/dist/coolandlovely/components/StatusBadge.js +9 -1
  7. package/dist/coolandlovely/components/StatusBadge.js.map +1 -1
  8. package/dist/coolandlovely/hooks/useBrandOrdersApi.d.ts +6 -1
  9. package/dist/coolandlovely/hooks/useBrandOrdersApi.d.ts.map +1 -1
  10. package/dist/coolandlovely/hooks/useBrandOrdersApi.js +62 -30
  11. package/dist/coolandlovely/hooks/useBrandOrdersApi.js.map +1 -1
  12. package/dist/coolandlovely/hooks/useCommerceApi.d.ts +3 -1
  13. package/dist/coolandlovely/hooks/useCommerceApi.d.ts.map +1 -1
  14. package/dist/coolandlovely/hooks/useCommerceApi.js +25 -24
  15. package/dist/coolandlovely/hooks/useCommerceApi.js.map +1 -1
  16. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.d.ts +2 -1
  17. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.d.ts.map +1 -1
  18. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.js +94 -92
  19. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.js.map +1 -1
  20. package/dist/coolandlovely/pages/commerce/CreatorEarningsPage.d.ts.map +1 -1
  21. package/dist/coolandlovely/pages/commerce/CreatorEarningsPage.js +108 -106
  22. package/dist/coolandlovely/pages/commerce/CreatorEarningsPage.js.map +1 -1
  23. package/dist/coolandlovely/pages/commerce/OrdersPage.d.ts +2 -1
  24. package/dist/coolandlovely/pages/commerce/OrdersPage.d.ts.map +1 -1
  25. package/dist/coolandlovely/pages/commerce/OrdersPage.js +114 -52
  26. package/dist/coolandlovely/pages/commerce/OrdersPage.js.map +1 -1
  27. package/dist/coolandlovely/types/commerce.d.ts +37 -1
  28. package/dist/coolandlovely/types/commerce.d.ts.map +1 -1
  29. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import { CooBrandOrder } from '../types';
2
+
3
+ /** Whether the brand can (still) start or retry a refund of this order. */
4
+ export declare function canRefund(order: CooBrandOrder): boolean;
5
+ export declare function RefundPanel({ order }: {
6
+ order: CooBrandOrder;
7
+ }): import("react").JSX.Element;
8
+ //# sourceMappingURL=RefundPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RefundPanel.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/components/RefundPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAc9C,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAIvD;AAED,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,+BAwH9D"}
@@ -0,0 +1,113 @@
1
+ import { cn as e } from "../utils/cn.js";
2
+ import { useTr as t } from "../hooks/useTr.js";
3
+ import "../hooks/index.js";
4
+ import { StatusBadge as n } from "./StatusBadge.js";
5
+ import { formatDate as r, formatPrice as i } from "../utils/formatters.js";
6
+ import { TextAreaField as a } from "./Field.js";
7
+ import { useRefundBrandOrder as o } from "../hooks/useBrandOrdersApi.js";
8
+ import { useState as s } from "react";
9
+ import { Loader2 as c, RotateCcw as l } from "lucide-react";
10
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
11
+ //#region src/coolandlovely/components/RefundPanel.tsx
12
+ var f = 3, p = 1e3, m = "inline-flex w-full items-center justify-center gap-2 rounded-lg border border-status-error-text px-4 py-2.5 text-sm font-semibold text-status-error-text transition-colors hover:bg-status-error-bg-subtle disabled:opacity-50", h = "inline-flex w-full items-center justify-center gap-1.5 rounded-lg border border-border-seam px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:opacity-50";
13
+ function g(e) {
14
+ let t = e.refund?.status;
15
+ return t === "COMPLETED" || t === "PENDING" ? !1 : e.status === "PAID" || e.status === "PARTIALLY_REFUNDED";
16
+ }
17
+ function _({ order: _ }) {
18
+ let v = t(), y = o(), [b, x] = s(!1), [S, C] = s(""), w = _.refund, T = S.trim(), E = T.length >= f && T.length <= p;
19
+ return /* @__PURE__ */ d("div", {
20
+ className: "space-y-3 border-t border-border-seam pt-4",
21
+ "data-testid": "brand-refund-panel",
22
+ children: [w && /* @__PURE__ */ d("div", {
23
+ className: "space-y-1 text-sm",
24
+ children: [
25
+ /* @__PURE__ */ d("div", {
26
+ className: "flex items-center justify-between",
27
+ children: [/* @__PURE__ */ u("span", {
28
+ className: "text-text-secondary",
29
+ children: v("coolandlovely.refund.label", "Refund")
30
+ }), /* @__PURE__ */ u("span", {
31
+ "data-testid": "brand-refund-status",
32
+ children: /* @__PURE__ */ u(n, { status: w.status })
33
+ })]
34
+ }),
35
+ /* @__PURE__ */ d("div", {
36
+ className: "flex justify-between",
37
+ children: [/* @__PURE__ */ u("span", {
38
+ className: "text-text-secondary",
39
+ children: v("coolandlovely.refund.amount", "Amount")
40
+ }), /* @__PURE__ */ u("span", {
41
+ className: "font-semibold tabular-nums text-text-primary",
42
+ children: i(w.amount, w.currency)
43
+ })]
44
+ }),
45
+ w.refundedAt && /* @__PURE__ */ u("p", {
46
+ className: "text-xs text-text-secondary",
47
+ children: v("coolandlovely.refund.refundedOn", "Refunded {{date}}", { date: r(w.refundedAt) })
48
+ }),
49
+ /* @__PURE__ */ u("p", {
50
+ className: "text-xs text-text-secondary",
51
+ children: v("coolandlovely.refund.reasonShown", "Reason: {{reason}}", { reason: w.reason })
52
+ }),
53
+ w.status === "PENDING" && /* @__PURE__ */ u("p", {
54
+ className: "text-xs text-status-warning-text",
55
+ children: v("coolandlovely.refund.pendingHint", "The refund is being processed with the payment provider. Refresh in a moment.")
56
+ }),
57
+ w.status === "FAILED" && w.failureReason && /* @__PURE__ */ u("p", {
58
+ className: "text-xs text-status-error-text",
59
+ children: w.failureReason
60
+ })
61
+ ]
62
+ }), g(_) && (b ? /* @__PURE__ */ d("div", {
63
+ className: "space-y-3",
64
+ children: [
65
+ /* @__PURE__ */ u("p", {
66
+ className: "text-sm text-text-secondary",
67
+ children: v("coolandlovely.refund.explain", "Refunds {{amount}} plus its share of tax to the shopper, for all of your pieces in this order. Creator commissions on them are reversed. This cannot be undone.", { amount: i(_.brandSubtotal, _.currency) })
68
+ }),
69
+ /* @__PURE__ */ u(a, {
70
+ id: "coo-refund-reason",
71
+ label: v("coolandlovely.refund.reason", "Reason (shown to the shopper)"),
72
+ value: S,
73
+ onChange: C,
74
+ rows: 3
75
+ }),
76
+ y.error && /* @__PURE__ */ u("p", {
77
+ className: "text-sm text-status-error-text",
78
+ role: "alert",
79
+ children: y.error.message
80
+ }),
81
+ /* @__PURE__ */ d("button", {
82
+ type: "button",
83
+ disabled: y.isPending || !E,
84
+ onClick: () => y.mutate({
85
+ brandId: _.brandId,
86
+ orderId: _.id,
87
+ reason: T
88
+ }, { onSuccess: () => x(!1) }),
89
+ className: m,
90
+ "data-testid": "brand-refund-confirm",
91
+ children: [y.isPending ? /* @__PURE__ */ u(c, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ u(l, { className: "h-4 w-4" }), v("coolandlovely.refund.confirm", "Refund my pieces")]
92
+ }),
93
+ /* @__PURE__ */ u("button", {
94
+ type: "button",
95
+ disabled: y.isPending,
96
+ onClick: () => x(!1),
97
+ className: h,
98
+ children: v("coolandlovely.common.cancel", "Cancel")
99
+ })
100
+ ]
101
+ }) : /* @__PURE__ */ d("button", {
102
+ type: "button",
103
+ onClick: () => x(!0),
104
+ className: e(h),
105
+ "data-testid": "brand-refund-open",
106
+ children: [/* @__PURE__ */ u(l, { className: "h-4 w-4" }), w?.status === "FAILED" ? v("coolandlovely.refund.retry", "Retry refund") : v("coolandlovely.refund.start", "Refund this order")]
107
+ }))]
108
+ });
109
+ }
110
+ //#endregion
111
+ export { _ as RefundPanel };
112
+
113
+ //# sourceMappingURL=RefundPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RefundPanel.js","names":[],"sources":["../../../src/coolandlovely/components/RefundPanel.tsx"],"sourcesContent":["/**\n * Brand refund panel (BOFF-9702)\n * @module coolandlovely/components\n *\n * On the brand's order detail: refund all of the brand's pieces of the order to the shopper\n * (`cooRefundBrandOrder`), or see the refund once it exists. The money goes back through\n * global-billing to the shopper's original payment method, and the creator commissions on the\n * refunded pieces are reversed while they are still unpaid.\n */\n\nimport { useState } from 'react';\nimport { Loader2, RotateCcw } from 'lucide-react';\n\nimport { useTr } from '../hooks';\nimport { useRefundBrandOrder } from '../hooks/useBrandOrdersApi';\nimport type { CooBrandOrder } from '../types';\nimport { cn } from '../utils/cn';\nimport { formatDate, formatPrice } from '../utils/formatters';\nimport { TextAreaField } from './Field';\nimport { StatusBadge } from './StatusBadge';\n\nconst MIN_REASON = 3;\nconst MAX_REASON = 1000;\n\nconst dangerButton =\n 'inline-flex w-full items-center justify-center gap-2 rounded-lg border border-status-error-text px-4 py-2.5 text-sm font-semibold text-status-error-text transition-colors hover:bg-status-error-bg-subtle disabled:opacity-50';\nconst secondaryButton =\n 'inline-flex w-full items-center justify-center gap-1.5 rounded-lg border border-border-seam px-3 py-2 text-sm font-medium text-text-primary transition-colors hover:bg-bg-sunken disabled:opacity-50';\n\n/** Whether the brand can (still) start or retry a refund of this order. */\nexport function canRefund(order: CooBrandOrder): boolean {\n const status = order.refund?.status;\n if (status === 'COMPLETED' || status === 'PENDING') return false;\n return order.status === 'PAID' || order.status === 'PARTIALLY_REFUNDED';\n}\n\nexport function RefundPanel({ order }: { order: CooBrandOrder }) {\n const tr = useTr();\n const refund = useRefundBrandOrder();\n const [open, setOpen] = useState(false);\n const [reason, setReason] = useState('');\n const existing = order.refund;\n const trimmed = reason.trim();\n const reasonValid = trimmed.length >= MIN_REASON && trimmed.length <= MAX_REASON;\n\n return (\n <div className=\"space-y-3 border-t border-border-seam pt-4\" data-testid=\"brand-refund-panel\">\n {existing && (\n <div className=\"space-y-1 text-sm\">\n <div className=\"flex items-center justify-between\">\n <span className=\"text-text-secondary\">\n {tr('coolandlovely.refund.label', 'Refund')}\n </span>\n <span data-testid=\"brand-refund-status\">\n <StatusBadge status={existing.status} />\n </span>\n </div>\n <div className=\"flex justify-between\">\n <span className=\"text-text-secondary\">\n {tr('coolandlovely.refund.amount', 'Amount')}\n </span>\n <span className=\"font-semibold tabular-nums text-text-primary\">\n {formatPrice(existing.amount, existing.currency)}\n </span>\n </div>\n {existing.refundedAt && (\n <p className=\"text-xs text-text-secondary\">\n {tr('coolandlovely.refund.refundedOn', 'Refunded {{date}}', {\n date: formatDate(existing.refundedAt),\n })}\n </p>\n )}\n <p className=\"text-xs text-text-secondary\">\n {tr('coolandlovely.refund.reasonShown', 'Reason: {{reason}}', {\n reason: existing.reason,\n })}\n </p>\n {existing.status === 'PENDING' && (\n <p className=\"text-xs text-status-warning-text\">\n {tr(\n 'coolandlovely.refund.pendingHint',\n 'The refund is being processed with the payment provider. Refresh in a moment.'\n )}\n </p>\n )}\n {existing.status === 'FAILED' && existing.failureReason && (\n <p className=\"text-xs text-status-error-text\">{existing.failureReason}</p>\n )}\n </div>\n )}\n\n {canRefund(order) &&\n (open ? (\n <div className=\"space-y-3\">\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'coolandlovely.refund.explain',\n 'Refunds {{amount}} plus its share of tax to the shopper, for all of your pieces in this order. Creator commissions on them are reversed. This cannot be undone.',\n { amount: formatPrice(order.brandSubtotal, order.currency) }\n )}\n </p>\n <TextAreaField\n id=\"coo-refund-reason\"\n label={tr('coolandlovely.refund.reason', 'Reason (shown to the shopper)')}\n value={reason}\n onChange={setReason}\n rows={3}\n />\n {refund.error && (\n <p className=\"text-sm text-status-error-text\" role=\"alert\">\n {refund.error.message}\n </p>\n )}\n <button\n type=\"button\"\n disabled={refund.isPending || !reasonValid}\n onClick={() =>\n refund.mutate(\n { brandId: order.brandId, orderId: order.id, reason: trimmed },\n { onSuccess: () => setOpen(false) }\n )\n }\n className={dangerButton}\n data-testid=\"brand-refund-confirm\"\n >\n {refund.isPending ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n ) : (\n <RotateCcw className=\"h-4 w-4\" />\n )}\n {tr('coolandlovely.refund.confirm', 'Refund my pieces')}\n </button>\n <button\n type=\"button\"\n disabled={refund.isPending}\n onClick={() => setOpen(false)}\n className={secondaryButton}\n >\n {tr('coolandlovely.common.cancel', 'Cancel')}\n </button>\n </div>\n ) : (\n <button\n type=\"button\"\n onClick={() => setOpen(true)}\n className={cn(secondaryButton)}\n data-testid=\"brand-refund-open\"\n >\n <RotateCcw className=\"h-4 w-4\" />\n {existing?.status === 'FAILED'\n ? tr('coolandlovely.refund.retry', 'Retry refund')\n : tr('coolandlovely.refund.start', 'Refund this order')}\n </button>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAqBA,IAAM,IAAa,GACb,IAAa,KAEb,IACJ,kOACI,IACJ;AAGF,SAAgB,EAAU,GAA+B;CACvD,IAAM,IAAS,EAAM,QAAQ;AAE7B,QADI,MAAW,eAAe,MAAW,YAAkB,KACpD,EAAM,WAAW,UAAU,EAAM,WAAW;;AAGrD,SAAgB,EAAY,EAAE,YAAmC;CAC/D,IAAM,IAAK,GAAO,EACZ,IAAS,GAAqB,EAC9B,CAAC,GAAM,KAAW,EAAS,GAAM,EACjC,CAAC,GAAQ,KAAa,EAAS,GAAG,EAClC,IAAW,EAAM,QACjB,IAAU,EAAO,MAAM,EACvB,IAAc,EAAQ,UAAU,KAAc,EAAQ,UAAU;AAEtE,QACE,kBAAC,OAAD;EAAK,WAAU;EAA6C,eAAY;YA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KACE,MAAK;KACL,UAAU,EAAO,aAAa,CAAC;KAC/B,eACE,EAAO,OACL;MAAE,SAAS,EAAM;MAAS,SAAS,EAAM;MAAI,QAAQ;MAAS,EAC9D,EAAE,iBAAiB,EAAQ,GAAM,EAAE,CACpC;KAEH,WAAW;KACX,eAAY;eAVd,CAYG,EAAO,YACN,kBAAC,GAAD,EAAS,WAAU,wBAAyB,CAAA,GAE5C,kBAAC,GAAD,EAAW,WAAU,WAAY,CAAA,EAElC,EAAG,gCAAgC,mBAAmB,CAChD;;IACT,kBAAC,UAAD;KACE,MAAK;KACL,UAAU,EAAO;KACjB,eAAe,EAAQ,GAAM;KAC7B,WAAW;eAEV,EAAG,+BAA+B,SAAS;KACrC,CAAA;IACL;OAEN,kBAAC,UAAD;GACE,MAAK;GACL,eAAe,EAAQ,GAAK;GAC5B,WAAW,EAAG,EAAgB;GAC9B,eAAY;aAJd,CAME,kBAAC,GAAD,EAAW,WAAU,WAAY,CAAA,EAChC,GAAU,WAAW,WAClB,EAAG,8BAA8B,eAAe,GAChD,EAAG,8BAA8B,oBAAoB,CAClD;MAET"}
@@ -1 +1 @@
1
- {"version":3,"file":"StatusBadge.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/components/StatusBadge.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAsHD,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA2B5C,CAAC"}
1
+ {"version":3,"file":"StatusBadge.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/components/StatusBadge.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgID,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA2B5C,CAAC"}
@@ -49,6 +49,10 @@ var i = {
49
49
  confirmed: "info",
50
50
  shipped: "info",
51
51
  delivered: "success",
52
+ partially_refunded: "warning",
53
+ refunded: "outline",
54
+ reversed: "outline",
55
+ not_reversible: "warning",
52
56
  inactive: "secondary",
53
57
  error: "destructive",
54
58
  failed: "destructive",
@@ -89,7 +93,11 @@ var i = {
89
93
  unfulfilled: "coolandlovely.status.unfulfilled",
90
94
  confirmed: "coolandlovely.status.confirmed",
91
95
  shipped: "coolandlovely.status.shipped",
92
- delivered: "coolandlovely.status.delivered"
96
+ delivered: "coolandlovely.status.delivered",
97
+ partially_refunded: "coolandlovely.status.partiallyRefunded",
98
+ refunded: "coolandlovely.status.refunded",
99
+ reversed: "coolandlovely.status.reversed",
100
+ not_reversible: "coolandlovely.status.notReversible"
93
101
  };
94
102
  function l(e) {
95
103
  return e.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
@@ -1 +1 @@
1
- {"version":3,"file":"StatusBadge.js","names":[],"sources":["../../../src/coolandlovely/components/StatusBadge.tsx"],"sourcesContent":["/**\n * Status Badge Component\n * @module coolandlovely/components\n *\n * A colored badge based on status value with semantic color mapping\n * for various order, cart, and investment statuses.\n */\n\nimport type { FC } from 'react';\nimport { cn } from '../utils/cn';\nimport { useTr } from '../hooks';\n\ninterface StatusBadgeProps {\n status: string;\n className?: string;\n}\n\ntype BadgeVariant = 'success' | 'warning' | 'destructive' | 'secondary' | 'info' | 'outline';\n\nconst variantStyles: Record<BadgeVariant, string> = {\n success: 'bg-status-success-bg-subtle text-status-success-text',\n warning: 'bg-status-warning-bg-subtle text-status-warning-text',\n destructive: 'bg-status-error-bg-subtle text-status-error-text',\n secondary: 'bg-bg-sunken text-text-secondary',\n info: 'bg-accent-blue-subtle text-accent-blue',\n outline: 'border border-border-seam text-text-primary',\n};\n\nconst dotStyles: Record<BadgeVariant, string> = {\n success: 'bg-status-success-text',\n warning: 'bg-status-warning-text',\n destructive: 'bg-status-error-text',\n secondary: 'bg-text-secondary',\n info: 'bg-accent-blue',\n outline: 'bg-text-secondary',\n};\n\nconst statusVariantMap: Record<string, BadgeVariant> = {\n // Brand lifecycle\n draft: 'secondary',\n pending_review: 'warning',\n published: 'success',\n suspended: 'destructive',\n archived: 'outline',\n\n // Collection lifecycle\n scheduled: 'info',\n live: 'success',\n ended: 'outline',\n\n // Style item status\n active: 'success',\n out_of_stock: 'warning',\n retired: 'outline',\n\n // Collaboration lifecycle\n proposed: 'secondary',\n accepted: 'info',\n in_progress: 'warning',\n declined: 'destructive',\n cancelled: 'destructive',\n\n // Visibility\n public: 'success',\n followers: 'info',\n private: 'secondary',\n\n // Wardrobe source\n owned: 'success',\n wishlist: 'info',\n purchased_on_platform: 'success',\n gifted: 'warning',\n\n // Orders + creator commissions (BOFF-3370)\n pending_payment: 'warning',\n paid: 'success',\n pending: 'secondary',\n synced: 'success',\n\n // Brand fulfilment (BOFF-9636)\n unfulfilled: 'warning',\n confirmed: 'info',\n shipped: 'info',\n delivered: 'success',\n\n // Generic\n inactive: 'secondary',\n error: 'destructive',\n failed: 'destructive',\n completed: 'success',\n};\n\n/** Statuses that represent a live/active state get a calm opacity pulse on the dot. */\nconst liveStatuses = new Set(['live', 'published', 'active', 'in_progress']);\n\nconst STATUS_LABEL_KEYS: Record<string, string> = {\n draft: 'coolandlovely.status.draft',\n pending_review: 'coolandlovely.status.pendingReview',\n published: 'coolandlovely.status.published',\n suspended: 'coolandlovely.status.suspended',\n archived: 'coolandlovely.status.archived',\n scheduled: 'coolandlovely.status.scheduled',\n live: 'coolandlovely.status.live',\n ended: 'coolandlovely.status.ended',\n active: 'coolandlovely.status.active',\n out_of_stock: 'coolandlovely.status.outOfStock',\n retired: 'coolandlovely.status.retired',\n proposed: 'coolandlovely.status.proposed',\n accepted: 'coolandlovely.status.accepted',\n in_progress: 'coolandlovely.status.inProgress',\n declined: 'coolandlovely.status.declined',\n cancelled: 'coolandlovely.status.cancelled',\n public: 'coolandlovely.status.public',\n followers: 'coolandlovely.status.followers',\n private: 'coolandlovely.status.private',\n owned: 'coolandlovely.status.owned',\n wishlist: 'coolandlovely.status.wishlist',\n purchased_on_platform: 'coolandlovely.status.purchasedOnPlatform',\n gifted: 'coolandlovely.status.gifted',\n inactive: 'coolandlovely.status.inactive',\n error: 'coolandlovely.status.error',\n failed: 'coolandlovely.status.failed',\n completed: 'coolandlovely.status.completed',\n unfulfilled: 'coolandlovely.status.unfulfilled',\n confirmed: 'coolandlovely.status.confirmed',\n shipped: 'coolandlovely.status.shipped',\n delivered: 'coolandlovely.status.delivered',\n};\n\nfunction formatStatusLabel(status: string): string {\n return status.replace(/_/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase());\n}\n\nexport const StatusBadge: FC<StatusBadgeProps> = ({ status, className }) => {\n const tr = useTr();\n const key = status.toLowerCase();\n const variant = statusVariantMap[key] || 'secondary';\n const isLive = liveStatuses.has(key);\n const labelKey = STATUS_LABEL_KEYS[key];\n const label = labelKey ? tr(labelKey, formatStatusLabel(status)) : formatStatusLabel(status);\n\n return (\n <span\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium',\n variantStyles[variant],\n className\n )}\n >\n <span\n aria-hidden=\"true\"\n className={cn(\n 'h-1.5 w-1.5 rounded-full',\n dotStyles[variant],\n isLive && 'motion-safe:animate-vc-glow-pulse'\n )}\n />\n {label}\n </span>\n );\n};\n"],"mappings":";;;;;AAmBA,IAAM,IAA8C;CAClD,SAAS;CACT,SAAS;CACT,aAAa;CACb,WAAW;CACX,MAAM;CACN,SAAS;CACV,EAEK,IAA0C;CAC9C,SAAS;CACT,SAAS;CACT,aAAa;CACb,WAAW;CACX,MAAM;CACN,SAAS;CACV,EAEK,IAAiD;CAErD,OAAO;CACP,gBAAgB;CAChB,WAAW;CACX,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AD;GACE,eAAY;GACZ,WAAW,EACT,4BACA,EAAU,IACV,KAAU,oCACX;GACD,CAAA,EACD,EACI"}
1
+ {"version":3,"file":"StatusBadge.js","names":[],"sources":["../../../src/coolandlovely/components/StatusBadge.tsx"],"sourcesContent":["/**\n * Status Badge Component\n * @module coolandlovely/components\n *\n * A colored badge based on status value with semantic color mapping\n * for various order, cart, and investment statuses.\n */\n\nimport type { FC } from 'react';\nimport { cn } from '../utils/cn';\nimport { useTr } from '../hooks';\n\ninterface StatusBadgeProps {\n status: string;\n className?: string;\n}\n\ntype BadgeVariant = 'success' | 'warning' | 'destructive' | 'secondary' | 'info' | 'outline';\n\nconst variantStyles: Record<BadgeVariant, string> = {\n success: 'bg-status-success-bg-subtle text-status-success-text',\n warning: 'bg-status-warning-bg-subtle text-status-warning-text',\n destructive: 'bg-status-error-bg-subtle text-status-error-text',\n secondary: 'bg-bg-sunken text-text-secondary',\n info: 'bg-accent-blue-subtle text-accent-blue',\n outline: 'border border-border-seam text-text-primary',\n};\n\nconst dotStyles: Record<BadgeVariant, string> = {\n success: 'bg-status-success-text',\n warning: 'bg-status-warning-text',\n destructive: 'bg-status-error-text',\n secondary: 'bg-text-secondary',\n info: 'bg-accent-blue',\n outline: 'bg-text-secondary',\n};\n\nconst statusVariantMap: Record<string, BadgeVariant> = {\n // Brand lifecycle\n draft: 'secondary',\n pending_review: 'warning',\n published: 'success',\n suspended: 'destructive',\n archived: 'outline',\n\n // Collection lifecycle\n scheduled: 'info',\n live: 'success',\n ended: 'outline',\n\n // Style item status\n active: 'success',\n out_of_stock: 'warning',\n retired: 'outline',\n\n // Collaboration lifecycle\n proposed: 'secondary',\n accepted: 'info',\n in_progress: 'warning',\n declined: 'destructive',\n cancelled: 'destructive',\n\n // Visibility\n public: 'success',\n followers: 'info',\n private: 'secondary',\n\n // Wardrobe source\n owned: 'success',\n wishlist: 'info',\n purchased_on_platform: 'success',\n gifted: 'warning',\n\n // Orders + creator commissions (BOFF-3370)\n pending_payment: 'warning',\n paid: 'success',\n pending: 'secondary',\n synced: 'success',\n\n // Brand fulfilment (BOFF-9636)\n unfulfilled: 'warning',\n confirmed: 'info',\n shipped: 'info',\n delivered: 'success',\n\n // Refunds and commission reversal (BOFF-9702)\n partially_refunded: 'warning',\n refunded: 'outline',\n reversed: 'outline',\n not_reversible: 'warning',\n\n // Generic\n inactive: 'secondary',\n error: 'destructive',\n failed: 'destructive',\n completed: 'success',\n};\n\n/** Statuses that represent a live/active state get a calm opacity pulse on the dot. */\nconst liveStatuses = new Set(['live', 'published', 'active', 'in_progress']);\n\nconst STATUS_LABEL_KEYS: Record<string, string> = {\n draft: 'coolandlovely.status.draft',\n pending_review: 'coolandlovely.status.pendingReview',\n published: 'coolandlovely.status.published',\n suspended: 'coolandlovely.status.suspended',\n archived: 'coolandlovely.status.archived',\n scheduled: 'coolandlovely.status.scheduled',\n live: 'coolandlovely.status.live',\n ended: 'coolandlovely.status.ended',\n active: 'coolandlovely.status.active',\n out_of_stock: 'coolandlovely.status.outOfStock',\n retired: 'coolandlovely.status.retired',\n proposed: 'coolandlovely.status.proposed',\n accepted: 'coolandlovely.status.accepted',\n in_progress: 'coolandlovely.status.inProgress',\n declined: 'coolandlovely.status.declined',\n cancelled: 'coolandlovely.status.cancelled',\n public: 'coolandlovely.status.public',\n followers: 'coolandlovely.status.followers',\n private: 'coolandlovely.status.private',\n owned: 'coolandlovely.status.owned',\n wishlist: 'coolandlovely.status.wishlist',\n purchased_on_platform: 'coolandlovely.status.purchasedOnPlatform',\n gifted: 'coolandlovely.status.gifted',\n inactive: 'coolandlovely.status.inactive',\n error: 'coolandlovely.status.error',\n failed: 'coolandlovely.status.failed',\n completed: 'coolandlovely.status.completed',\n unfulfilled: 'coolandlovely.status.unfulfilled',\n confirmed: 'coolandlovely.status.confirmed',\n shipped: 'coolandlovely.status.shipped',\n delivered: 'coolandlovely.status.delivered',\n partially_refunded: 'coolandlovely.status.partiallyRefunded',\n refunded: 'coolandlovely.status.refunded',\n reversed: 'coolandlovely.status.reversed',\n not_reversible: 'coolandlovely.status.notReversible',\n};\n\nfunction formatStatusLabel(status: string): string {\n return status.replace(/_/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase());\n}\n\nexport const StatusBadge: FC<StatusBadgeProps> = ({ status, className }) => {\n const tr = useTr();\n const key = status.toLowerCase();\n const variant = statusVariantMap[key] || 'secondary';\n const isLive = liveStatuses.has(key);\n const labelKey = STATUS_LABEL_KEYS[key];\n const label = labelKey ? tr(labelKey, formatStatusLabel(status)) : formatStatusLabel(status);\n\n return (\n <span\n className={cn(\n 'inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium',\n variantStyles[variant],\n className\n )}\n >\n <span\n aria-hidden=\"true\"\n className={cn(\n 'h-1.5 w-1.5 rounded-full',\n dotStyles[variant],\n isLive && 'motion-safe:animate-vc-glow-pulse'\n )}\n />\n {label}\n </span>\n );\n};\n"],"mappings":";;;;;AAmBA,IAAM,IAA8C;CAClD,SAAS;CACT,SAAS;CACT,aAAa;CACb,WAAW;CACX,MAAM;CACN,SAAS;CACV,EAEK,IAA0C;CAC9C,SAAS;CACT,SAAS;CACT,aAAa;CACb,WAAW;CACX,MAAM;CACN,SAAS;CACV,EAEK,IAAiD;CAErD,OAAO;CACP,gBAAgB;CAChB,WAAW;CACX,WAAW;CACX,UAAU;CAGV,WAAW;CACX,MAAM;CACN,OAAO;CAGP,QAAQ;CACR,cAAc;CACd,SAAS;CAGT,UAAU;CACV,UAAU;CACV,aAAa;CACb,UAAU;CACV,WAAW;CAGX,QAAQ;CACR,WAAW;CACX,SAAS;CAGT,OAAO;CACP,UAAU;CACV,uBAAuB;CACvB,QAAQ;CAGR,iBAAiB;CACjB,MAAM;CACN,SAAS;CACT,QAAQ;CAGR,aAAa;CACb,WAAW;CACX,SAAS;CACT,WAAW;CAGX,oBAAoB;CACpB,UAAU;CACV,UAAU;CACV,gBAAgB;CAGhB,UAAU;CACV,OAAO;CACP,QAAQ;CACR,WAAW;CACZ,EAGK,IAAe,IAAI,IAAI;CAAC;CAAQ;CAAa;CAAU;CAAc,CAAC,EAEtE,IAA4C;CAChD,OAAO;CACP,gBAAgB;CAChB,WAAW;CACX,WAAW;CACX,UAAU;CACV,WAAW;CACX,MAAM;CACN,OAAO;CACP,QAAQ;CACR,cAAc;CACd,SAAS;CACT,UAAU;CACV,UAAU;CACV,aAAa;CACb,UAAU;CACV,WAAW;CACX,QAAQ;CACR,WAAW;CACX,SAAS;CACT,OAAO;CACP,UAAU;CACV,uBAAuB;CACvB,QAAQ;CACR,UAAU;CACV,OAAO;CACP,QAAQ;CACR,WAAW;CACX,aAAa;CACb,WAAW;CACX,SAAS;CACT,WAAW;CACX,oBAAoB;CACpB,UAAU;CACV,UAAU;CACV,gBAAgB;CACjB;AAED,SAAS,EAAkB,GAAwB;AACjD,QAAO,EAAO,QAAQ,MAAM,IAAI,CAAC,QAAQ,UAAU,MAAS,EAAK,aAAa,CAAC;;AAGjF,IAAa,KAAqC,EAAE,WAAQ,mBAAgB;CAC1E,IAAM,IAAK,GAAO,EACZ,IAAM,EAAO,aAAa,EAC1B,IAAU,EAAiB,MAAQ,aACnC,IAAS,EAAa,IAAI,EAAI,EAC9B,IAAW,EAAkB,IAC7B,IAAQ,IAAW,EAAG,GAAU,EAAkB,EAAO,CAAC,GAAG,EAAkB,EAAO;AAE5F,QACE,kBAAC,QAAD;EACE,WAAW,EACT,mFACA,EAAc,IACd,EACD;YALH,CAOE,kBAAC,QAAD;GACE,eAAY;GACZ,WAAW,EACT,4BACA,EAAU,IACV,KAAU,oCACX;GACD,CAAA,EACD,EACI"}
@@ -1,7 +1,12 @@
1
- import { CooBrandOrder, CooBrandOrderConnection, CooBrandOrderSummary, CooFulfilmentStatus, CooUpdateOrderFulfilmentInput } from '../types';
1
+ import { CooBrandOrder, CooBrandOrderConnection, CooBrandOrderSummary, CooFulfilmentStatus, CooRefundBrandOrderInput, CooUpdateOrderFulfilmentInput } from '../types';
2
2
 
3
3
  export declare const useBrandOrders: (brandId: string | undefined, fulfilmentStatus?: CooFulfilmentStatus) => import('@tanstack/react-query').UseQueryResult<NoInfer<CooBrandOrderConnection>, Error>;
4
4
  export declare const useBrandOrderSummary: (brandId: string | undefined) => import('@tanstack/react-query').UseQueryResult<NoInfer<CooBrandOrderSummary>, Error>;
5
5
  export declare const useBrandOrder: (brandId: string | undefined, id: string | undefined) => import('@tanstack/react-query').UseQueryResult<NoInfer<CooBrandOrder | null>, Error>;
6
6
  export declare const useUpdateOrderFulfilment: () => import('@tanstack/react-query').UseMutationResult<CooBrandOrder, Error, CooUpdateOrderFulfilmentInput, unknown>;
7
+ /**
8
+ * Refund the brand's pieces of an order (BOFF-9702). global-billing returns the money to the
9
+ * shopper, and the creator commissions on the refunded lines are reversed.
10
+ */
11
+ export declare const useRefundBrandOrder: () => import('@tanstack/react-query').UseMutationResult<CooBrandOrder, Error, CooRefundBrandOrderInput, unknown>;
7
12
  //# sourceMappingURL=useBrandOrdersApi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBrandOrdersApi.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/hooks/useBrandOrdersApi.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,6BAA6B,EAC9B,MAAM,UAAU,CAAC;AAgBlB,eAAO,MAAM,cAAc,GACzB,SAAS,MAAM,GAAG,SAAS,EAC3B,mBAAmB,mBAAmB,4FAoBvC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,GAAG,SAAS,yFAgB/D,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,GAAG,SAAS,EAAE,IAAI,MAAM,GAAG,SAAS,yFAchF,CAAC;AAEF,eAAO,MAAM,wBAAwB,uHAoBpC,CAAC"}
1
+ {"version":3,"file":"useBrandOrdersApi.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/hooks/useBrandOrdersApi.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,6BAA6B,EAC9B,MAAM,UAAU,CAAC;AAiBlB,eAAO,MAAM,cAAc,GACzB,SAAS,MAAM,GAAG,SAAS,EAC3B,mBAAmB,mBAAmB,4FAoBvC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,GAAG,SAAS,yFAkB/D,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,GAAG,SAAS,EAAE,IAAI,MAAM,GAAG,SAAS,yFAchF,CAAC;AAEF,eAAO,MAAM,wBAAwB,uHAoBpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,kHA0B/B,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { useCoolAndLovely as e } from "../context/CoolAndLovelyContext.js";
2
2
  import "../context/index.js";
3
3
  import { coolQuery as t } from "./useCoolAndLovelyApi.js";
4
- import { FULFILMENT_FIELDS as n } from "./useCommerceApi.js";
5
- import { useMutation as r, useQuery as i, useQueryClient as a } from "@tanstack/react-query";
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
6
  //#region src/coolandlovely/hooks/useBrandOrdersApi.ts
7
- var o = "coolandlovely", s = `
7
+ var s = "coolandlovely", c = `
8
8
  id orderNumber status brandId currency brandSubtotal itemCount
9
9
  shippingName shippingAddress buyerNote paidAt createdAt
10
10
  items {
@@ -12,11 +12,12 @@ var o = "coolandlovely", s = `
12
12
  lookId isCreatorAttributed
13
13
  }
14
14
  fulfilment { ${n} }
15
- `, c = (n, r) => {
16
- let { apiGatewayUrl: a } = e();
17
- return i({
15
+ refund { ${r} }
16
+ `, l = (n, r) => {
17
+ let { apiGatewayUrl: i } = e();
18
+ return a({
18
19
  queryKey: [
19
- o,
20
+ s,
20
21
  "brand-orders",
21
22
  n,
22
23
  r ?? "ALL"
@@ -24,7 +25,7 @@ var o = "coolandlovely", s = `
24
25
  enabled: !!n,
25
26
  queryFn: async () => (await t(`query CooBrandOrders($brandId: ID!, $fulfilmentStatus: CooFulfilmentStatus, $pagination: PaginationInput) {
26
27
  cooBrandOrders(brandId: $brandId, fulfilmentStatus: $fulfilmentStatus, pagination: $pagination) {
27
- items { ${s} }
28
+ items { ${c} }
28
29
  pageInfo { cursor hasMore }
29
30
  }
30
31
  }`, {
@@ -34,59 +35,90 @@ var o = "coolandlovely", s = `
34
35
  limit: 50,
35
36
  offset: 0
36
37
  }
37
- }, a)).cooBrandOrders
38
+ }, i)).cooBrandOrders
38
39
  });
39
- }, l = (n) => {
40
+ }, u = (n) => {
40
41
  let { apiGatewayUrl: r } = e();
41
- return i({
42
+ return a({
42
43
  queryKey: [
43
- o,
44
+ s,
44
45
  "brand-order-summary",
45
46
  n
46
47
  ],
47
48
  enabled: !!n,
48
- queryFn: async () => (await t("query CooBrandOrderSummary($brandId: ID!) {\n cooBrandOrderSummary(brandId: $brandId) { brandId unfulfilled confirmed shipped delivered total }\n }", { brandId: n }, r)).cooBrandOrderSummary
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
49
50
  });
50
- }, u = (n, r) => {
51
- let { apiGatewayUrl: a } = e();
52
- return i({
51
+ }, d = (n, r) => {
52
+ let { apiGatewayUrl: i } = e();
53
+ return a({
53
54
  queryKey: [
54
- o,
55
+ s,
55
56
  "brand-order",
56
57
  n,
57
58
  r
58
59
  ],
59
60
  enabled: !!n && !!r,
60
- queryFn: async () => (await t(`query CooBrandOrder($brandId: ID!, $id: ID!) { cooBrandOrder(brandId: $brandId, id: $id) { ${s} } }`, {
61
+ queryFn: async () => (await t(`query CooBrandOrder($brandId: ID!, $id: ID!) { cooBrandOrder(brandId: $brandId, id: $id) { ${c} } }`, {
61
62
  brandId: n,
62
63
  id: r
63
- }, a)).cooBrandOrder
64
+ }, i)).cooBrandOrder
64
65
  });
65
- }, d = () => {
66
- let { apiGatewayUrl: n } = e(), i = a();
67
- return r({
66
+ }, f = () => {
67
+ let { apiGatewayUrl: n } = e(), r = o();
68
+ return i({
68
69
  mutationFn: async (e) => (await t(`mutation CooUpdateOrderFulfilment($input: CooUpdateOrderFulfilmentInput!) {
69
- cooUpdateOrderFulfilment(input: $input) { ${s} }
70
+ cooUpdateOrderFulfilment(input: $input) { ${c} }
70
71
  }`, { input: e }, n)).cooUpdateOrderFulfilment,
71
72
  onSuccess: (e) => {
72
- i.setQueryData([
73
- o,
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,
74
98
  "brand-order",
75
99
  e.brandId,
76
100
  e.id
77
- ], e), i.invalidateQueries({ queryKey: [
78
- o,
101
+ ], e), r.invalidateQueries({ queryKey: [
102
+ s,
79
103
  "brand-orders",
80
104
  e.brandId
81
- ] }), i.invalidateQueries({ queryKey: [
82
- o,
105
+ ] }), r.invalidateQueries({ queryKey: [
106
+ s,
83
107
  "brand-order-summary",
84
108
  e.brandId
85
109
  ] });
110
+ },
111
+ onError: (e, t) => {
112
+ r.invalidateQueries({ queryKey: [
113
+ s,
114
+ "brand-order",
115
+ t.brandId,
116
+ t.orderId
117
+ ] });
86
118
  }
87
119
  });
88
120
  };
89
121
  //#endregion
90
- export { u as useBrandOrder, l as useBrandOrderSummary, c as useBrandOrders, d as useUpdateOrderFulfilment };
122
+ export { d as useBrandOrder, u as useBrandOrderSummary, l as useBrandOrders, p as useRefundBrandOrder, f as useUpdateOrderFulfilment };
91
123
 
92
124
  //# sourceMappingURL=useBrandOrdersApi.js.map
@@ -1 +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 CooUpdateOrderFulfilmentInput,\n} from '../types';\nimport { FULFILMENT_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`;\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) { brandId unfulfilled confirmed shipped delivered total }\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"],"mappings":";;;;;;AAsBA,IAAM,IAAK,iBAEL,IAAqB;;;;;;;iBAOV,EAAkB;GAGtB,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,uKAGA,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"}
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,E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;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,7 +1,9 @@
1
1
  import { CooAddToCartInput, CooCart, CooCheckoutInput, CooCreatorEarningConnection, CooCreatorEarningsSummary, CooCreatorPayout, CooOrder, CooOrderCheckout, CooOrderConnection, CooOrderStatus } from '../types';
2
2
 
3
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 carrier trackingNumber trackingUrl note\n confirmedAt shippedAt deliveredAt updatedAt\n";
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";
5
7
  export declare const useMyCart: () => import('@tanstack/react-query').UseQueryResult<NoInfer<CooCart>, Error>;
6
8
  export declare const useAddToCart: () => import('@tanstack/react-query').UseMutationResult<CooCart, Error, {
7
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,EACh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;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,20 +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 = "\n id orderId brandId brandName status carrier trackingNumber trackingUrl note\n confirmedAt shippedAt deliveredAt updatedAt\n", l = `
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
7
  ${s}
8
8
  fulfilmentStatus
9
9
  fulfilments { ${c} }
10
- `, u = `
10
+ refunds { ${l} }
11
+ `, d = `
11
12
  order { ${s} }
12
13
  provider providerOrderId razorpayKeyId clientSecret stripePublishableKey subtotal taxAmount total currency
13
- `, d = () => {
14
+ `, f = () => {
14
15
  let { apiGatewayUrl: n } = e();
15
16
  return r({
16
17
  queryKey: [a, "cart"],
17
18
  queryFn: async () => (await t(`query CooMyCart { cooMyCart { ${o} } }`, {}, n)).cooMyCart
18
19
  });
19
- }, f = (r, o) => {
20
+ }, p = (r, o) => {
20
21
  let { apiGatewayUrl: s } = e(), c = i();
21
22
  return n({
22
23
  mutationFn: async (e) => {
@@ -28,9 +29,9 @@ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colo
28
29
  c.setQueryData([a, "cart"], e);
29
30
  }
30
31
  });
31
- }, p = () => f(`mutation CooAddToCart($input: CooAddToCartInput!) { cooAddToCart(input: $input) { ${o} } }`, "cooAddToCart"), m = () => f(`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!) {
32
33
  cooUpdateCartItem(id: $id, quantity: $quantity) { ${o} }
33
- }`, "cooUpdateCartItem"), h = () => f(`mutation CooRemoveCartItem($id: ID!) { cooRemoveCartItem(id: $id) { ${o} } }`, "cooRemoveCartItem"), g = (n) => {
34
+ }`, "cooUpdateCartItem"), g = () => p(`mutation CooRemoveCartItem($id: ID!) { cooRemoveCartItem(id: $id) { ${o} } }`, "cooRemoveCartItem"), _ = (n) => {
34
35
  let { apiGatewayUrl: i } = e();
35
36
  return r({
36
37
  queryKey: [
@@ -51,7 +52,7 @@ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colo
51
52
  }
52
53
  }, i)).cooMyOrders
53
54
  });
54
- }, _ = (n) => {
55
+ }, v = (n) => {
55
56
  let { apiGatewayUrl: i } = e();
56
57
  return r({
57
58
  queryKey: [
@@ -60,9 +61,9 @@ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colo
60
61
  n
61
62
  ],
62
63
  enabled: !!n,
63
- queryFn: async () => (await t(`query CooMyOrder($id: ID!) { cooMyOrder(id: $id) { ${l} } }`, { id: n }, i)).cooMyOrder
64
+ queryFn: async () => (await t(`query CooMyOrder($id: ID!) { cooMyOrder(id: $id) { ${u} } }`, { id: n }, i)).cooMyOrder
64
65
  });
65
- }, v = () => {
66
+ }, y = () => {
66
67
  let e = i();
67
68
  return (t) => {
68
69
  e.setQueryData([
@@ -71,46 +72,46 @@ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colo
71
72
  t.id
72
73
  ], t), e.invalidateQueries({ queryKey: [a, "orders"] }), e.invalidateQueries({ queryKey: [a, "cart"] });
73
74
  };
74
- }, y = () => {
75
- let { apiGatewayUrl: r } = e(), i = v();
75
+ }, b = () => {
76
+ let { apiGatewayUrl: r } = e(), i = y();
76
77
  return n({
77
- mutationFn: async (e) => (await t(`mutation CooCheckout($input: CooCheckoutInput!) { cooCheckout(input: $input) { ${u} } }`, { input: e }, r)).cooCheckout,
78
+ mutationFn: async (e) => (await t(`mutation CooCheckout($input: CooCheckoutInput!) { cooCheckout(input: $input) { ${d} } }`, { input: e }, r)).cooCheckout,
78
79
  onSuccess: (e) => i(e.order)
79
80
  });
80
- }, b = () => {
81
- let { apiGatewayUrl: r } = e(), i = v();
81
+ }, x = () => {
82
+ let { apiGatewayUrl: r } = e(), i = y();
82
83
  return n({
83
- mutationFn: async (e) => (await t(`mutation CooResumeOrderPayment($id: ID!) { cooResumeOrderPayment(id: $id) { ${u} } }`, { id: e }, r)).cooResumeOrderPayment,
84
+ mutationFn: async (e) => (await t(`mutation CooResumeOrderPayment($id: ID!) { cooResumeOrderPayment(id: $id) { ${d} } }`, { id: e }, r)).cooResumeOrderPayment,
84
85
  onSuccess: (e) => i(e.order)
85
86
  });
86
- }, x = () => {
87
+ }, S = () => {
87
88
  let { apiGatewayUrl: r } = e();
88
89
  return n({
89
90
  mutationFn: async (e) => (await t(`mutation CooSyncOrderPayment($id: ID!) { cooSyncOrderPayment(id: $id) { ${s} } }`, { id: e }, r)).cooSyncOrderPayment,
90
- onSuccess: v()
91
+ onSuccess: y()
91
92
  });
92
- }, S = () => {
93
+ }, C = () => {
93
94
  let { apiGatewayUrl: r } = e();
94
95
  return n({
95
96
  mutationFn: async (e) => (await t(`mutation CooCancelOrder($id: ID!) { cooCancelOrder(id: $id) { ${s} } }`, { id: e }, r)).cooCancelOrder,
96
- onSuccess: v()
97
+ onSuccess: y()
97
98
  });
98
- }, C = () => {
99
+ }, w = () => {
99
100
  let { apiGatewayUrl: n } = e();
100
101
  return r({
101
102
  queryKey: [a, "creator-earnings"],
102
- 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: {
103
104
  limit: 50,
104
105
  offset: 0
105
106
  } }, n)).cooMyCreatorEarnings
106
107
  });
107
- }, w = () => {
108
+ }, T = () => {
108
109
  let { apiGatewayUrl: n } = e();
109
110
  return r({
110
111
  queryKey: [a, "creator-earnings-summary"],
111
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
112
113
  });
113
- }, T = () => {
114
+ }, E = () => {
114
115
  let { apiGatewayUrl: r } = e(), o = i();
115
116
  return n({
116
117
  mutationFn: async (e) => (await t("mutation CooRequestCreatorPayout($input: CooRequestCreatorPayoutInput!) {\n cooRequestCreatorPayout(input: $input) { id status requestedAmount currency createdAt }\n }", { input: e }, r)).cooRequestCreatorPayout,
@@ -120,6 +121,6 @@ var a = "coolandlovely", o = "\n items {\n id styleItemId quantity size colo
120
121
  });
121
122
  };
122
123
  //#endregion
123
- export { c as FULFILMENT_FIELDS, p as useAddToCart, S as useCancelOrder, y as useCheckout, d as useMyCart, C as useMyCreatorEarnings, w as useMyCreatorEarningsSummary, _ as useMyOrder, g as useMyOrders, h as useRemoveCartItem, T as useRequestCreatorPayout, b as useResumeOrderPayment, x as useSyncOrderPayment, m 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 };
124
125
 
125
126
  //# sourceMappingURL=useCommerceApi.js.map