@burdenoff/microfe-coolandlovely 2026.1028.1 → 2026.1028.3

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 (34) hide show
  1. package/dist/coolandlovely/components/Field.d.ts +1 -0
  2. package/dist/coolandlovely/components/Field.d.ts.map +1 -1
  3. package/dist/coolandlovely/components/Field.js +2 -1
  4. package/dist/coolandlovely/components/Field.js.map +1 -1
  5. package/dist/coolandlovely/components/RefundPanel.d.ts +4 -0
  6. package/dist/coolandlovely/components/RefundPanel.d.ts.map +1 -1
  7. package/dist/coolandlovely/components/RefundPanel.js +163 -97
  8. package/dist/coolandlovely/components/RefundPanel.js.map +1 -1
  9. package/dist/coolandlovely/components/ReturnRequests.d.ts +15 -0
  10. package/dist/coolandlovely/components/ReturnRequests.d.ts.map +1 -0
  11. package/dist/coolandlovely/components/ReturnRequests.js +218 -0
  12. package/dist/coolandlovely/components/ReturnRequests.js.map +1 -0
  13. package/dist/coolandlovely/components/StatusBadge.d.ts.map +1 -1
  14. package/dist/coolandlovely/components/StatusBadge.js +5 -1
  15. package/dist/coolandlovely/components/StatusBadge.js.map +1 -1
  16. package/dist/coolandlovely/hooks/useBrandOrdersApi.d.ts +13 -2
  17. package/dist/coolandlovely/hooks/useBrandOrdersApi.d.ts.map +1 -1
  18. package/dist/coolandlovely/hooks/useBrandOrdersApi.js +113 -33
  19. package/dist/coolandlovely/hooks/useBrandOrdersApi.js.map +1 -1
  20. package/dist/coolandlovely/hooks/useCommerceApi.d.ts +9 -2
  21. package/dist/coolandlovely/hooks/useCommerceApi.d.ts.map +1 -1
  22. package/dist/coolandlovely/hooks/useCommerceApi.js +47 -31
  23. package/dist/coolandlovely/hooks/useCommerceApi.js.map +1 -1
  24. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.d.ts +3 -1
  25. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.d.ts.map +1 -1
  26. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.js +129 -97
  27. package/dist/coolandlovely/pages/commerce/BrandOrdersPage.js.map +1 -1
  28. package/dist/coolandlovely/pages/commerce/OrdersPage.d.ts +2 -1
  29. package/dist/coolandlovely/pages/commerce/OrdersPage.d.ts.map +1 -1
  30. package/dist/coolandlovely/pages/commerce/OrdersPage.js +124 -122
  31. package/dist/coolandlovely/pages/commerce/OrdersPage.js.map +1 -1
  32. package/dist/coolandlovely/types/commerce.d.ts +58 -0
  33. package/dist/coolandlovely/types/commerce.d.ts.map +1 -1
  34. package/package.json +1 -1
@@ -0,0 +1,218 @@
1
+ import { useTr as e } from "../hooks/useTr.js";
2
+ import "../hooks/index.js";
3
+ import { StatusBadge as t } from "./StatusBadge.js";
4
+ import { formatDate as n } from "../utils/formatters.js";
5
+ import { TextAreaField as r } from "./Field.js";
6
+ import { useRequestReturn as i } from "../hooks/useCommerceApi.js";
7
+ import { useApproveReturnRequest as a, useDeclineReturnRequest as o } from "../hooks/useBrandOrdersApi.js";
8
+ import { useState as s } from "react";
9
+ import { CheckCircle2 as c, Loader2 as l, Undo2 as u, XCircle as d } from "lucide-react";
10
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
11
+ import { GlassCard as m } from "@burdenoff/fe-libs/ui";
12
+ //#region src/coolandlovely/components/ReturnRequests.tsx
13
+ var h = 3, g = 1e3, _ = ["PAID", "PARTIALLY_REFUNDED"], v = (e) => {
14
+ let t = e.trim();
15
+ return t.length >= h && t.length <= g;
16
+ }, y = "inline-flex items-center justify-center gap-2 rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-semibold text-action-primary-text transition-colors hover:bg-action-primary-bg/90 disabled:opacity-50", b = "inline-flex 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";
17
+ function x(e, t = Date.now()) {
18
+ return e.returnWindowEndsAt ? new Date(e.returnWindowEndsAt).getTime() > t : !1;
19
+ }
20
+ function S(e, t, n = Date.now()) {
21
+ if (!_.includes(e.status) || e.returnRequests?.some((e) => e.brandId === t)) return !1;
22
+ let r = e.refunds?.find((e) => e.brandId === t);
23
+ return r && (r.status === "COMPLETED" || r.status === "PENDING") ? !1 : x(e, n);
24
+ }
25
+ function C({ request: t }) {
26
+ let r = e();
27
+ return /* @__PURE__ */ p("div", {
28
+ className: "space-y-1 text-xs text-text-secondary",
29
+ children: [
30
+ /* @__PURE__ */ f("p", { children: r("coolandlovely.returns.reasonShown", "Reason: {{reason}}", { reason: t.reason }) }),
31
+ t.status === "REQUESTED" && /* @__PURE__ */ f("p", { children: r("coolandlovely.returns.awaitingBrand", "Asked {{date}}. The brand will approve or decline it.", { date: n(t.createdAt) }) }),
32
+ t.status !== "REQUESTED" && t.decisionNote && /* @__PURE__ */ f("p", {
33
+ "data-testid": "return-decision-note",
34
+ children: r("coolandlovely.returns.brandNote", "Brand’s note: {{note}}", { note: t.decisionNote })
35
+ }),
36
+ t.status !== "REQUESTED" && t.decidedAt && /* @__PURE__ */ f("p", { children: t.status === "APPROVED" ? r("coolandlovely.returns.approvedOn", "Approved {{date}}. See the refund above.", { date: n(t.decidedAt) }) : r("coolandlovely.returns.declinedOn", "Declined {{date}}.", { date: n(t.decidedAt) }) })
37
+ ]
38
+ });
39
+ }
40
+ function w({ orderId: t, brandId: n }) {
41
+ let a = e(), o = i(), [c, d] = s(!1), [m, h] = s("");
42
+ return c ? /* @__PURE__ */ p("div", {
43
+ className: "space-y-2",
44
+ children: [
45
+ /* @__PURE__ */ f(r, {
46
+ id: `coo-return-reason-${n}`,
47
+ label: a("coolandlovely.returns.reason", "Why are you returning these pieces?"),
48
+ hint: a("coolandlovely.returns.reasonHint", "Shown to the brand."),
49
+ value: m,
50
+ onChange: h,
51
+ rows: 3
52
+ }),
53
+ o.error && /* @__PURE__ */ f("p", {
54
+ className: "text-sm text-status-error-text",
55
+ role: "alert",
56
+ children: o.error.message
57
+ }),
58
+ /* @__PURE__ */ p("div", {
59
+ className: "flex flex-wrap gap-2",
60
+ children: [/* @__PURE__ */ p("button", {
61
+ type: "button",
62
+ disabled: o.isPending || !v(m),
63
+ onClick: () => o.mutate({
64
+ orderId: t,
65
+ brandId: n,
66
+ reason: m.trim()
67
+ }, { onSuccess: () => d(!1) }),
68
+ className: y,
69
+ "data-testid": "order-return-submit",
70
+ children: [o.isPending && /* @__PURE__ */ f(l, { className: "h-4 w-4 animate-spin" }), a("coolandlovely.returns.send", "Send return request")]
71
+ }), /* @__PURE__ */ f("button", {
72
+ type: "button",
73
+ disabled: o.isPending,
74
+ onClick: () => d(!1),
75
+ className: b,
76
+ children: a("coolandlovely.common.cancel", "Cancel")
77
+ })]
78
+ })
79
+ ]
80
+ }) : /* @__PURE__ */ p("button", {
81
+ type: "button",
82
+ onClick: () => d(!0),
83
+ className: b,
84
+ "data-testid": "order-return-open",
85
+ children: [/* @__PURE__ */ f(u, { className: "h-4 w-4" }), a("coolandlovely.returns.request", "Request a return")]
86
+ });
87
+ }
88
+ function T({ order: r }) {
89
+ let i = e(), a = r.status === "PAID" || r.status === "PARTIALLY_REFUNDED", o = r.returnRequests ?? [];
90
+ if (!a && o.length === 0) return null;
91
+ let s = [...new Set(r.items.map((e) => e.brandId))], c = (e) => o.find((t) => t.brandId === e)?.brandName ?? r.fulfilments?.find((t) => t.brandId === e)?.brandName ?? r.refunds?.find((t) => t.brandId === e)?.brandName ?? i("coolandlovely.orders.brand", "Brand"), l = x(r);
92
+ return /* @__PURE__ */ p(m, {
93
+ treatment: "plain",
94
+ className: "space-y-4 p-4",
95
+ "data-testid": "order-returns",
96
+ children: [/* @__PURE__ */ p("div", {
97
+ className: "space-y-1",
98
+ children: [/* @__PURE__ */ f("p", {
99
+ className: "text-xs font-medium uppercase tracking-wide text-text-secondary",
100
+ children: i("coolandlovely.returns.title", "Returns")
101
+ }), a && r.returnWindowEndsAt && /* @__PURE__ */ f("p", {
102
+ className: "text-xs text-text-secondary",
103
+ "data-testid": "order-return-window",
104
+ children: l ? i("coolandlovely.returns.windowOpen", "You can ask a brand to take back its pieces until {{date}}.", { date: n(r.returnWindowEndsAt) }) : i("coolandlovely.returns.windowClosed", "The return window closed on {{date}}.", { date: n(r.returnWindowEndsAt) })
105
+ })]
106
+ }), s.map((e) => {
107
+ let n = o.find((t) => t.brandId === e), i = S(r, e);
108
+ return !n && !i ? null : /* @__PURE__ */ p("div", {
109
+ className: "space-y-2",
110
+ "data-testid": "order-return",
111
+ children: [/* @__PURE__ */ p("div", {
112
+ className: "flex items-center justify-between gap-2",
113
+ children: [/* @__PURE__ */ f("span", {
114
+ className: "text-sm font-medium text-text-primary",
115
+ children: c(e)
116
+ }), n && /* @__PURE__ */ f("span", {
117
+ "data-testid": "order-return-status",
118
+ children: /* @__PURE__ */ f(t, { status: n.status })
119
+ })]
120
+ }), n ? /* @__PURE__ */ f(C, { request: n }) : /* @__PURE__ */ f(w, {
121
+ orderId: r.id,
122
+ brandId: e
123
+ })]
124
+ }, e);
125
+ })]
126
+ });
127
+ }
128
+ function E({ order: n }) {
129
+ let i = e(), u = a(), m = o(), [h, g] = s("idle"), [_, x] = s(""), S = n.returnRequest;
130
+ if (!S) return null;
131
+ let w = u.isPending || m.isPending, T = u.error ?? m.error, E = h === "approve" && _.trim() === "" || v(_), D = () => {
132
+ g("idle"), x("");
133
+ };
134
+ return /* @__PURE__ */ p("div", {
135
+ className: "space-y-3 border-t border-border-seam pt-4",
136
+ "data-testid": "brand-return-panel",
137
+ children: [
138
+ /* @__PURE__ */ p("div", {
139
+ className: "flex items-center justify-between text-sm",
140
+ children: [/* @__PURE__ */ f("span", {
141
+ className: "text-text-secondary",
142
+ children: i("coolandlovely.returns.brandTitle", "Return request")
143
+ }), /* @__PURE__ */ f("span", {
144
+ "data-testid": "brand-return-status",
145
+ children: /* @__PURE__ */ f(t, { status: S.status })
146
+ })]
147
+ }),
148
+ /* @__PURE__ */ f(C, { request: S }),
149
+ S.status === "REQUESTED" && (h === "idle" ? /* @__PURE__ */ p("div", {
150
+ className: "grid grid-cols-2 gap-2",
151
+ children: [/* @__PURE__ */ p("button", {
152
+ type: "button",
153
+ onClick: () => g("approve"),
154
+ className: y,
155
+ "data-testid": "brand-return-approve-open",
156
+ children: [/* @__PURE__ */ f(c, { className: "h-4 w-4" }), i("coolandlovely.returns.approve", "Approve")]
157
+ }), /* @__PURE__ */ p("button", {
158
+ type: "button",
159
+ onClick: () => g("decline"),
160
+ className: b,
161
+ "data-testid": "brand-return-decline-open",
162
+ children: [/* @__PURE__ */ f(d, { className: "h-4 w-4" }), i("coolandlovely.returns.decline", "Decline")]
163
+ })]
164
+ }) : /* @__PURE__ */ p("div", {
165
+ className: "space-y-3",
166
+ children: [
167
+ /* @__PURE__ */ f("p", {
168
+ className: "text-sm text-text-secondary",
169
+ children: h === "approve" ? i("coolandlovely.returns.approveExplain", "Approving refunds all of your pieces in this order to the shopper, with their share of tax, and reverses the creator commissions on them. This cannot be undone.") : i("coolandlovely.returns.declineExplain", "The shopper sees your note. A declined return cannot be reopened.")
170
+ }),
171
+ /* @__PURE__ */ f(r, {
172
+ id: "coo-return-decision-note",
173
+ label: h === "approve" ? i("coolandlovely.returns.approveNote", "Note to the shopper (optional)") : i("coolandlovely.returns.declineNote", "Why are you declining?"),
174
+ value: _,
175
+ onChange: x,
176
+ rows: 3
177
+ }),
178
+ T && /* @__PURE__ */ f("p", {
179
+ className: "text-sm text-status-error-text",
180
+ role: "alert",
181
+ children: T.message
182
+ }),
183
+ /* @__PURE__ */ p("button", {
184
+ type: "button",
185
+ disabled: w || !E,
186
+ onClick: () => {
187
+ let e = {
188
+ brandId: n.brandId,
189
+ orderId: n.id
190
+ };
191
+ h === "approve" ? u.mutate({
192
+ ...e,
193
+ note: _.trim() || null
194
+ }, { onSuccess: D }) : m.mutate({
195
+ ...e,
196
+ note: _.trim()
197
+ }, { onSuccess: D });
198
+ },
199
+ className: h === "approve" ? `${y} w-full` : `${b} w-full text-status-error-text`,
200
+ "data-testid": "brand-return-confirm",
201
+ children: [w && /* @__PURE__ */ f(l, { className: "h-4 w-4 animate-spin" }), h === "approve" ? i("coolandlovely.returns.approveConfirm", "Approve and refund") : i("coolandlovely.returns.declineConfirm", "Decline return")]
202
+ }),
203
+ /* @__PURE__ */ f("button", {
204
+ type: "button",
205
+ disabled: w,
206
+ onClick: D,
207
+ className: `${b} w-full`,
208
+ children: i("coolandlovely.common.cancel", "Cancel")
209
+ })
210
+ ]
211
+ }))
212
+ ]
213
+ });
214
+ }
215
+ //#endregion
216
+ export { T as OrderReturns, E as ReturnRequestPanel };
217
+
218
+ //# sourceMappingURL=ReturnRequests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReturnRequests.js","names":[],"sources":["../../../src/coolandlovely/components/ReturnRequests.tsx"],"sourcesContent":["/**\n * Shopper return requests (BOFF-9900)\n * @module coolandlovely/components\n *\n * `OrderReturns` sits on the shopper's order detail: for each brand in a paid order the shopper\n * can ask for a return (`cooRequestReturn`) inside the return window, and sees the request and\n * the brand's decision once it exists. `ReturnRequestPanel` sits on the brand's order detail: the\n * brand approves the request, which refunds its pieces through the brand refund\n * (`cooApproveReturnRequest`), or declines it with a note (`cooDeclineReturnRequest`).\n */\n\nimport { useState } from 'react';\nimport { CheckCircle2, Loader2, Undo2, XCircle } from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\n\nimport { useTr } from '../hooks';\nimport { useApproveReturnRequest, useDeclineReturnRequest } from '../hooks/useBrandOrdersApi';\nimport { useRequestReturn } from '../hooks/useCommerceApi';\nimport type { CooBrandOrder, CooOrder, CooReturnRequest } from '../types';\nimport { formatDate } from '../utils/formatters';\nimport { TextAreaField } from './Field';\nimport { StatusBadge } from './StatusBadge';\n\nconst MIN_TEXT = 3;\nconst MAX_TEXT = 1000;\nconst RETURNABLE_ORDER_STATUSES = ['PAID', 'PARTIALLY_REFUNDED'];\n\nconst isValidText = (value: string): boolean => {\n const trimmed = value.trim();\n return trimmed.length >= MIN_TEXT && trimmed.length <= MAX_TEXT;\n};\n\nconst primaryButton =\n 'inline-flex items-center justify-center gap-2 rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-semibold text-action-primary-text transition-colors hover:bg-action-primary-bg/90 disabled:opacity-50';\nconst secondaryButton =\n 'inline-flex 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 return window of a paid order is still open. */\nexport function isReturnWindowOpen(order: Pick<CooOrder, 'returnWindowEndsAt'>, now = Date.now()) {\n if (!order.returnWindowEndsAt) return false;\n return new Date(order.returnWindowEndsAt).getTime() > now;\n}\n\n/** Whether the shopper can still ask the brand to take back its pieces of this order. */\nexport function canRequestReturn(order: CooOrder, brandId: string, now = Date.now()): boolean {\n if (!RETURNABLE_ORDER_STATUSES.includes(order.status)) return false;\n if (order.returnRequests?.some((request) => request.brandId === brandId)) return false;\n const refund = order.refunds?.find((entry) => entry.brandId === brandId);\n if (refund && (refund.status === 'COMPLETED' || refund.status === 'PENDING')) return false;\n return isReturnWindowOpen(order, now);\n}\n\nfunction RequestDetails({ request }: { request: CooReturnRequest }) {\n const tr = useTr();\n return (\n <div className=\"space-y-1 text-xs text-text-secondary\">\n <p>\n {tr('coolandlovely.returns.reasonShown', 'Reason: {{reason}}', { reason: request.reason })}\n </p>\n {request.status === 'REQUESTED' && (\n <p>\n {tr(\n 'coolandlovely.returns.awaitingBrand',\n 'Asked {{date}}. The brand will approve or decline it.',\n { date: formatDate(request.createdAt) }\n )}\n </p>\n )}\n {request.status !== 'REQUESTED' && request.decisionNote && (\n <p data-testid=\"return-decision-note\">\n {tr('coolandlovely.returns.brandNote', 'Brand’s note: {{note}}', {\n note: request.decisionNote,\n })}\n </p>\n )}\n {request.status !== 'REQUESTED' && request.decidedAt && (\n <p>\n {request.status === 'APPROVED'\n ? tr('coolandlovely.returns.approvedOn', 'Approved {{date}}. See the refund above.', {\n date: formatDate(request.decidedAt),\n })\n : tr('coolandlovely.returns.declinedOn', 'Declined {{date}}.', {\n date: formatDate(request.decidedAt),\n })}\n </p>\n )}\n </div>\n );\n}\n\nfunction RequestReturnForm({ orderId, brandId }: { orderId: string; brandId: string }) {\n const tr = useTr();\n const request = useRequestReturn();\n const [open, setOpen] = useState(false);\n const [reason, setReason] = useState('');\n\n if (!open) {\n return (\n <button\n type=\"button\"\n onClick={() => setOpen(true)}\n className={secondaryButton}\n data-testid=\"order-return-open\"\n >\n <Undo2 className=\"h-4 w-4\" />\n {tr('coolandlovely.returns.request', 'Request a return')}\n </button>\n );\n }\n return (\n <div className=\"space-y-2\">\n <TextAreaField\n id={`coo-return-reason-${brandId}`}\n label={tr('coolandlovely.returns.reason', 'Why are you returning these pieces?')}\n hint={tr('coolandlovely.returns.reasonHint', 'Shown to the brand.')}\n value={reason}\n onChange={setReason}\n rows={3}\n />\n {request.error && (\n <p className=\"text-sm text-status-error-text\" role=\"alert\">\n {request.error.message}\n </p>\n )}\n <div className=\"flex flex-wrap gap-2\">\n <button\n type=\"button\"\n disabled={request.isPending || !isValidText(reason)}\n onClick={() =>\n request.mutate(\n { orderId, brandId, reason: reason.trim() },\n { onSuccess: () => setOpen(false) }\n )\n }\n className={primaryButton}\n data-testid=\"order-return-submit\"\n >\n {request.isPending && <Loader2 className=\"h-4 w-4 animate-spin\" />}\n {tr('coolandlovely.returns.send', 'Send return request')}\n </button>\n <button\n type=\"button\"\n disabled={request.isPending}\n onClick={() => setOpen(false)}\n className={secondaryButton}\n >\n {tr('coolandlovely.common.cancel', 'Cancel')}\n </button>\n </div>\n </div>\n );\n}\n\n/** The shopper's returns card on a paid order: one row per brand in the order. */\nexport function OrderReturns({ order }: { order: CooOrder }) {\n const tr = useTr();\n const paid = order.status === 'PAID' || order.status === 'PARTIALLY_REFUNDED';\n const requests = order.returnRequests ?? [];\n if (!paid && requests.length === 0) return null;\n\n const brandIds = [...new Set(order.items.map((item) => item.brandId))];\n const brandName = (brandId: string): string =>\n requests.find((request) => request.brandId === brandId)?.brandName ??\n order.fulfilments?.find((fulfilment) => fulfilment.brandId === brandId)?.brandName ??\n order.refunds?.find((refund) => refund.brandId === brandId)?.brandName ??\n tr('coolandlovely.orders.brand', 'Brand');\n const windowOpen = isReturnWindowOpen(order);\n\n return (\n <GlassCard treatment=\"plain\" className=\"space-y-4 p-4\" data-testid=\"order-returns\">\n <div className=\"space-y-1\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr('coolandlovely.returns.title', 'Returns')}\n </p>\n {paid && order.returnWindowEndsAt && (\n <p className=\"text-xs text-text-secondary\" data-testid=\"order-return-window\">\n {windowOpen\n ? tr(\n 'coolandlovely.returns.windowOpen',\n 'You can ask a brand to take back its pieces until {{date}}.',\n { date: formatDate(order.returnWindowEndsAt) }\n )\n : tr('coolandlovely.returns.windowClosed', 'The return window closed on {{date}}.', {\n date: formatDate(order.returnWindowEndsAt),\n })}\n </p>\n )}\n </div>\n {brandIds.map((brandId) => {\n const request = requests.find((entry) => entry.brandId === brandId);\n const eligible = canRequestReturn(order, brandId);\n if (!request && !eligible) return null;\n return (\n <div key={brandId} className=\"space-y-2\" data-testid=\"order-return\">\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"text-sm font-medium text-text-primary\">{brandName(brandId)}</span>\n {request && (\n <span data-testid=\"order-return-status\">\n <StatusBadge status={request.status} />\n </span>\n )}\n </div>\n {request ? (\n <RequestDetails request={request} />\n ) : (\n <RequestReturnForm orderId={order.id} brandId={brandId} />\n )}\n </div>\n );\n })}\n </GlassCard>\n );\n}\n\n/** The brand's view of the shopper's return request, with approve and decline. */\nexport function ReturnRequestPanel({ order }: { order: CooBrandOrder }) {\n const tr = useTr();\n const approve = useApproveReturnRequest();\n const decline = useDeclineReturnRequest();\n const [mode, setMode] = useState<'idle' | 'approve' | 'decline'>('idle');\n const [note, setNote] = useState('');\n const request = order.returnRequest;\n if (!request) return null;\n\n const busy = approve.isPending || decline.isPending;\n const error = approve.error ?? decline.error;\n const noteOk = mode === 'approve' ? note.trim() === '' || isValidText(note) : isValidText(note);\n const reset = () => {\n setMode('idle');\n setNote('');\n };\n const submit = () => {\n const input = { brandId: order.brandId, orderId: order.id };\n if (mode === 'approve') {\n approve.mutate({ ...input, note: note.trim() || null }, { onSuccess: reset });\n } else {\n decline.mutate({ ...input, note: note.trim() }, { onSuccess: reset });\n }\n };\n\n return (\n <div className=\"space-y-3 border-t border-border-seam pt-4\" data-testid=\"brand-return-panel\">\n <div className=\"flex items-center justify-between text-sm\">\n <span className=\"text-text-secondary\">\n {tr('coolandlovely.returns.brandTitle', 'Return request')}\n </span>\n <span data-testid=\"brand-return-status\">\n <StatusBadge status={request.status} />\n </span>\n </div>\n <RequestDetails request={request} />\n\n {request.status === 'REQUESTED' &&\n (mode === 'idle' ? (\n <div className=\"grid grid-cols-2 gap-2\">\n <button\n type=\"button\"\n onClick={() => setMode('approve')}\n className={primaryButton}\n data-testid=\"brand-return-approve-open\"\n >\n <CheckCircle2 className=\"h-4 w-4\" />\n {tr('coolandlovely.returns.approve', 'Approve')}\n </button>\n <button\n type=\"button\"\n onClick={() => setMode('decline')}\n className={secondaryButton}\n data-testid=\"brand-return-decline-open\"\n >\n <XCircle className=\"h-4 w-4\" />\n {tr('coolandlovely.returns.decline', 'Decline')}\n </button>\n </div>\n ) : (\n <div className=\"space-y-3\">\n <p className=\"text-sm text-text-secondary\">\n {mode === 'approve'\n ? tr(\n 'coolandlovely.returns.approveExplain',\n 'Approving refunds all of your pieces in this order to the shopper, with their share of tax, and reverses the creator commissions on them. This cannot be undone.'\n )\n : tr(\n 'coolandlovely.returns.declineExplain',\n 'The shopper sees your note. A declined return cannot be reopened.'\n )}\n </p>\n <TextAreaField\n id=\"coo-return-decision-note\"\n label={\n mode === 'approve'\n ? tr('coolandlovely.returns.approveNote', 'Note to the shopper (optional)')\n : tr('coolandlovely.returns.declineNote', 'Why are you declining?')\n }\n value={note}\n onChange={setNote}\n rows={3}\n />\n {error && (\n <p className=\"text-sm text-status-error-text\" role=\"alert\">\n {error.message}\n </p>\n )}\n <button\n type=\"button\"\n disabled={busy || !noteOk}\n onClick={submit}\n className={\n mode === 'approve'\n ? `${primaryButton} w-full`\n : `${secondaryButton} w-full text-status-error-text`\n }\n data-testid=\"brand-return-confirm\"\n >\n {busy && <Loader2 className=\"h-4 w-4 animate-spin\" />}\n {mode === 'approve'\n ? tr('coolandlovely.returns.approveConfirm', 'Approve and refund')\n : tr('coolandlovely.returns.declineConfirm', 'Decline return')}\n </button>\n <button\n type=\"button\"\n disabled={busy}\n onClick={reset}\n className={`${secondaryButton} w-full`}\n >\n {tr('coolandlovely.common.cancel', 'Cancel')}\n </button>\n </div>\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,IAAM,IAAW,GACX,IAAW,KACX,IAA4B,CAAC,QAAQ,qBAAqB,EAE1D,KAAe,MAA2B;CAC9C,IAAM,IAAU,EAAM,MAAM;AAC5B,QAAO,EAAQ,UAAU,KAAY,EAAQ,UAAU;GAGnD,IACJ,8MACI,IACJ;AAGF,SAAgB,EAAmB,GAA6C,IAAM,KAAK,KAAK,EAAE;AAEhG,QADK,EAAM,qBACJ,IAAI,KAAK,EAAM,mBAAmB,CAAC,SAAS,GAAG,IADhB;;AAKxC,SAAgB,EAAiB,GAAiB,GAAiB,IAAM,KAAK,KAAK,EAAW;AAE5F,KADI,CAAC,EAA0B,SAAS,EAAM,OAAO,IACjD,EAAM,gBAAgB,MAAM,MAAY,EAAQ,YAAY,EAAQ,CAAE,QAAO;CACjF,IAAM,IAAS,EAAM,SAAS,MAAM,MAAU,EAAM,YAAY,EAAQ;AAExE,QADI,MAAW,EAAO,WAAW,eAAe,EAAO,WAAW,aAAmB,KAC9E,EAAmB,GAAO,EAAI;;AAGvC,SAAS,EAAe,EAAE,cAA0C;CAClE,IAAM,IAAK,GAAO;AAClB,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,KAAD,EAAA,UACG,EAAG,qCAAqC,sBAAsB,EAAE,Q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Y;gBATd,CAWG,KAAQ,kBAAC,GAAD,EAAS,WAAU,wBAAyB,CAAA,EACpD,MAAS,YACN,EAAG,wCAAwC,qBAAqB,GAChE,EAAG,wCAAwC,iBAAiB,CACzD;;KACT,kBAAC,UAAD;MACE,MAAK;MACL,UAAU;MACV,SAAS;MACT,WAAW,GAAG,EAAgB;gBAE7B,EAAG,+BAA+B,SAAS;MACrC,CAAA;KACL;;GAEN"}
@@ -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;AAoID,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;AA0ID,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA2B5C,CAAC"}
@@ -54,6 +54,8 @@ var i = {
54
54
  refunded: "outline",
55
55
  reversed: "outline",
56
56
  not_reversible: "warning",
57
+ requested: "warning",
58
+ approved: "success",
57
59
  inactive: "secondary",
58
60
  error: "destructive",
59
61
  failed: "destructive",
@@ -99,7 +101,9 @@ var i = {
99
101
  refunded: "coolandlovely.status.refunded",
100
102
  reversed: "coolandlovely.status.reversed",
101
103
  not_reversible: "coolandlovely.status.notReversible",
102
- awaiting_payment: "coolandlovely.status.awaitingPayment"
104
+ awaiting_payment: "coolandlovely.status.awaitingPayment",
105
+ requested: "coolandlovely.status.returnRequested",
106
+ approved: "coolandlovely.status.approved"
103
107
  };
104
108
  function l(e) {
105
109
  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 // Collaboration fees (BOFF-9637)\n awaiting_payment: 'warning',\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 awaiting_payment: 'coolandlovely.status.awaitingPayment',\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,i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atusBadge.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 // Collaboration fees (BOFF-9637)\n awaiting_payment: 'warning',\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 // Shopper return requests (BOFF-9900)\n requested: 'warning',\n approved: '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 partially_refunded: 'coolandlovely.status.partiallyRefunded',\n refunded: 'coolandlovely.status.refunded',\n reversed: 'coolandlovely.status.reversed',\n not_reversible: 'coolandlovely.status.notReversible',\n awaiting_payment: 'coolandlovely.status.awaitingPayment',\n requested: 'coolandlovely.status.returnRequested',\n approved: 'coolandlovely.status.approved',\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,kBAAkB;CAGlB,aAAa;CACb,WAAW;CACX,SAAS;CACT,WAAW;CAG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CooRefundBrandOrderInput, CooUpdateOrderFulfilmentInput } from '../types';
1
+ import { CooApproveReturnRequestInput, CooBrandOrder, CooBrandOrderConnection, CooBrandOrderSummary, CooDeclineReturnRequestInput, CooFulfilmentStatus, CooRefundBrandOrderInput, CooReturnRequestConnection, CooReturnRequestStatus, 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>;
@@ -6,7 +6,18 @@ export declare const useBrandOrder: (brandId: string | undefined, id: string | u
6
6
  export declare const useUpdateOrderFulfilment: () => import('@tanstack/react-query').UseMutationResult<CooBrandOrder, Error, CooUpdateOrderFulfilmentInput, unknown>;
7
7
  /**
8
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.
9
+ * shopper, and the creator commissions on the refunded lines are reversed. With `restock: true`
10
+ * the refunded stock-tracked pieces go back into stock (BOFF-9901); sending it on a completed
11
+ * refund restocks it afterwards.
10
12
  */
11
13
  export declare const useRefundBrandOrder: () => import('@tanstack/react-query').UseMutationResult<CooBrandOrder, Error, CooRefundBrandOrderInput, unknown>;
14
+ /** The brand's return requests, newest first, optionally by status (BOFF-9900). */
15
+ export declare const useBrandReturnRequests: (brandId: string | undefined, status?: CooReturnRequestStatus) => import('@tanstack/react-query').UseQueryResult<NoInfer<CooReturnRequestConnection>, Error>;
16
+ /**
17
+ * Approve a shopper's return (BOFF-9900): refunds the brand's pieces through the brand refund and
18
+ * marks the request approved. On an error the order is refetched so a failed refund shows why.
19
+ */
20
+ export declare const useApproveReturnRequest: () => import('@tanstack/react-query').UseMutationResult<CooBrandOrder, Error, CooApproveReturnRequestInput, unknown>;
21
+ /** Decline a shopper's return with a note the shopper sees (BOFF-9900). */
22
+ export declare const useDeclineReturnRequest: () => import('@tanstack/react-query').UseMutationResult<CooBrandOrder, Error, CooDeclineReturnRequestInput, unknown>;
12
23
  //# 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,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
+ {"version":3,"file":"useBrandOrdersApi.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/hooks/useBrandOrdersApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EACV,4BAA4B,EAC5B,aAAa,EACb,uBAAuB,EACvB,oBAAoB,EACpB,4BAA4B,EAC5B,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,UAAU,CAAC;AAkBlB,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;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,kHAoC/B,CAAC;AAEF,mFAAmF;AACnF,eAAO,MAAM,sBAAsB,GACjC,SAAS,MAAM,GAAG,SAAS,EAC3B,SAAS,sBAAsB,+FAoBhC,CAAC;AAaF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,sHAiBnC,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,uBAAuB,sHAgBnC,CAAC"}
@@ -1,23 +1,24 @@
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, REFUND_FIELDS as r } from "./useCommerceApi.js";
5
- import { useMutation as i, useQuery as a, useQueryClient as o } from "@tanstack/react-query";
4
+ import { FULFILMENT_FIELDS as n, REFUND_FIELDS as r, RETURN_REQUEST_FIELDS as i } from "./useCommerceApi.js";
5
+ import { useMutation as a, useQuery as o, useQueryClient as s } from "@tanstack/react-query";
6
6
  //#region src/coolandlovely/hooks/useBrandOrdersApi.ts
7
- var s = "coolandlovely", c = `
7
+ var c = "coolandlovely", l = `
8
8
  id orderNumber status brandId currency brandSubtotal itemCount
9
9
  shippingName shippingAddress buyerNote paidAt createdAt
10
10
  items {
11
11
  id styleItemId brandId name sku image { id } size colour unitPrice quantity lineTotal
12
- lookId isCreatorAttributed
12
+ lookId isCreatorAttributed stockTracked
13
13
  }
14
14
  fulfilment { ${n} }
15
15
  refund { ${r} }
16
- `, l = (n, r) => {
16
+ returnRequest { ${i} }
17
+ `, u = (n, r) => {
17
18
  let { apiGatewayUrl: i } = e();
18
- return a({
19
+ return o({
19
20
  queryKey: [
20
- s,
21
+ c,
21
22
  "brand-orders",
22
23
  n,
23
24
  r ?? "ALL"
@@ -25,7 +26,7 @@ var s = "coolandlovely", c = `
25
26
  enabled: !!n,
26
27
  queryFn: async () => (await t(`query CooBrandOrders($brandId: ID!, $fulfilmentStatus: CooFulfilmentStatus, $pagination: PaginationInput) {
27
28
  cooBrandOrders(brandId: $brandId, fulfilmentStatus: $fulfilmentStatus, pagination: $pagination) {
28
- items { ${c} }
29
+ items { ${l} }
29
30
  pageInfo { cursor hasMore }
30
31
  }
31
32
  }`, {
@@ -37,88 +38,167 @@ var s = "coolandlovely", c = `
37
38
  }
38
39
  }, i)).cooBrandOrders
39
40
  });
40
- }, u = (n) => {
41
+ }, d = (n) => {
41
42
  let { apiGatewayUrl: r } = e();
42
- return a({
43
+ return o({
43
44
  queryKey: [
44
- s,
45
+ c,
45
46
  "brand-order-summary",
46
47
  n
47
48
  ],
48
49
  enabled: !!n,
49
50
  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
  });
51
- }, d = (n, r) => {
52
+ }, f = (n, r) => {
52
53
  let { apiGatewayUrl: i } = e();
53
- return a({
54
+ return o({
54
55
  queryKey: [
55
- s,
56
+ c,
56
57
  "brand-order",
57
58
  n,
58
59
  r
59
60
  ],
60
61
  enabled: !!n && !!r,
61
- queryFn: async () => (await t(`query CooBrandOrder($brandId: ID!, $id: ID!) { cooBrandOrder(brandId: $brandId, id: $id) { ${c} } }`, {
62
+ queryFn: async () => (await t(`query CooBrandOrder($brandId: ID!, $id: ID!) { cooBrandOrder(brandId: $brandId, id: $id) { ${l} } }`, {
62
63
  brandId: n,
63
64
  id: r
64
65
  }, i)).cooBrandOrder
65
66
  });
66
- }, f = () => {
67
- let { apiGatewayUrl: n } = e(), r = o();
68
- return i({
67
+ }, p = () => {
68
+ let { apiGatewayUrl: n } = e(), r = s();
69
+ return a({
69
70
  mutationFn: async (e) => (await t(`mutation CooUpdateOrderFulfilment($input: CooUpdateOrderFulfilmentInput!) {
70
- cooUpdateOrderFulfilment(input: $input) { ${c} }
71
+ cooUpdateOrderFulfilment(input: $input) { ${l} }
71
72
  }`, { input: e }, n)).cooUpdateOrderFulfilment,
72
73
  onSuccess: (e) => {
73
74
  r.setQueryData([
74
- s,
75
+ c,
75
76
  "brand-order",
76
77
  e.brandId,
77
78
  e.id
78
79
  ], e), r.invalidateQueries({ queryKey: [
79
- s,
80
+ c,
80
81
  "brand-orders",
81
82
  e.brandId
82
83
  ] }), r.invalidateQueries({ queryKey: [
83
- s,
84
+ c,
84
85
  "brand-order-summary",
85
86
  e.brandId
86
87
  ] });
87
88
  }
88
89
  });
89
- }, p = () => {
90
- let { apiGatewayUrl: n } = e(), r = o();
91
- return i({
90
+ }, m = () => {
91
+ let { apiGatewayUrl: n } = e(), r = s();
92
+ return a({
92
93
  mutationFn: async (e) => (await t(`mutation CooRefundBrandOrder($input: CooRefundBrandOrderInput!) {
93
- cooRefundBrandOrder(input: $input) { ${c} }
94
+ cooRefundBrandOrder(input: $input) { ${l} }
94
95
  }`, { input: e }, n)).cooRefundBrandOrder,
95
96
  onSuccess: (e) => {
96
- r.setQueryData([
97
- s,
97
+ if (r.setQueryData([
98
+ c,
98
99
  "brand-order",
99
100
  e.brandId,
100
101
  e.id
101
102
  ], e), r.invalidateQueries({ queryKey: [
102
- s,
103
+ c,
103
104
  "brand-orders",
104
105
  e.brandId
105
106
  ] }), r.invalidateQueries({ queryKey: [
106
- s,
107
+ c,
107
108
  "brand-order-summary",
108
109
  e.brandId
109
- ] });
110
+ ] }), e.refund?.restockStatus === "RESTOCKED") {
111
+ for (let t of new Set(e.items.map((e) => e.styleItemId))) r.invalidateQueries({ queryKey: [
112
+ c,
113
+ "style-item-inventory",
114
+ t
115
+ ] }), r.invalidateQueries({ queryKey: [
116
+ c,
117
+ "style-item",
118
+ t
119
+ ] });
120
+ r.invalidateQueries({ queryKey: [c, "style-items"] });
121
+ }
110
122
  },
111
123
  onError: (e, t) => {
112
124
  r.invalidateQueries({ queryKey: [
113
- s,
125
+ c,
114
126
  "brand-order",
115
127
  t.brandId,
116
128
  t.orderId
117
129
  ] });
118
130
  }
119
131
  });
132
+ }, h = (n, r) => {
133
+ let { apiGatewayUrl: a } = e();
134
+ return o({
135
+ queryKey: [
136
+ c,
137
+ "brand-return-requests",
138
+ n,
139
+ r ?? "ALL"
140
+ ],
141
+ enabled: !!n,
142
+ queryFn: async () => (await t(`query CooBrandReturnRequests($brandId: ID!, $status: CooReturnRequestStatus, $pagination: PaginationInput) {
143
+ cooBrandReturnRequests(brandId: $brandId, status: $status, pagination: $pagination) {
144
+ items { ${i} }
145
+ pageInfo { cursor hasMore }
146
+ }
147
+ }`, {
148
+ brandId: n,
149
+ status: r,
150
+ pagination: {
151
+ limit: 50,
152
+ offset: 0
153
+ }
154
+ }, a)).cooBrandReturnRequests
155
+ });
156
+ }, g = () => {
157
+ let e = s();
158
+ return (t, n, r) => {
159
+ r ? e.setQueryData([
160
+ c,
161
+ "brand-order",
162
+ t,
163
+ n
164
+ ], r) : e.invalidateQueries({ queryKey: [
165
+ c,
166
+ "brand-order",
167
+ t,
168
+ n
169
+ ] }), e.invalidateQueries({ queryKey: [
170
+ c,
171
+ "brand-orders",
172
+ t
173
+ ] }), e.invalidateQueries({ queryKey: [
174
+ c,
175
+ "brand-order-summary",
176
+ t
177
+ ] }), e.invalidateQueries({ queryKey: [
178
+ c,
179
+ "brand-return-requests",
180
+ t
181
+ ] });
182
+ };
183
+ }, _ = () => {
184
+ let { apiGatewayUrl: n } = e(), r = g();
185
+ return a({
186
+ mutationFn: async (e) => (await t(`mutation CooApproveReturnRequest($input: CooApproveReturnRequestInput!) {
187
+ cooApproveReturnRequest(input: $input) { ${l} }
188
+ }`, { input: e }, n)).cooApproveReturnRequest,
189
+ onSuccess: (e, t) => r(t.brandId, t.orderId, e),
190
+ onError: (e, t) => r(t.brandId, t.orderId)
191
+ });
192
+ }, v = () => {
193
+ let { apiGatewayUrl: n } = e(), r = g();
194
+ return a({
195
+ mutationFn: async (e) => (await t(`mutation CooDeclineReturnRequest($input: CooDeclineReturnRequestInput!) {
196
+ cooDeclineReturnRequest(input: $input) { ${l} }
197
+ }`, { input: e }, n)).cooDeclineReturnRequest,
198
+ onSuccess: (e, t) => r(t.brandId, t.orderId, e)
199
+ });
120
200
  };
121
201
  //#endregion
122
- export { d as useBrandOrder, u as useBrandOrderSummary, l as useBrandOrders, p as useRefundBrandOrder, f as useUpdateOrderFulfilment };
202
+ export { _ as useApproveReturnRequest, f as useBrandOrder, d as useBrandOrderSummary, u as useBrandOrders, h as useBrandReturnRequests, v as useDeclineReturnRequest, m as useRefundBrandOrder, p as useUpdateOrderFulfilment };
123
203
 
124
204
  //# sourceMappingURL=useBrandOrdersApi.js.map