@burdenoff/microfe-coolandlovely 2026.1109.6 → 2026.1109.7

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 (33) hide show
  1. package/README.md +30 -0
  2. package/dist/coolandlovely/components/ResaleListingActions.d.ts +8 -0
  3. package/dist/coolandlovely/components/ResaleListingActions.d.ts.map +1 -0
  4. package/dist/coolandlovely/components/ResaleListingActions.js +132 -0
  5. package/dist/coolandlovely/components/ResaleListingActions.js.map +1 -0
  6. package/dist/coolandlovely/components/ResaleListingEditor.d.ts +7 -0
  7. package/dist/coolandlovely/components/ResaleListingEditor.d.ts.map +1 -0
  8. package/dist/coolandlovely/components/ResaleListingEditor.js +276 -0
  9. package/dist/coolandlovely/components/ResaleListingEditor.js.map +1 -0
  10. package/dist/coolandlovely/components/ResalePhotoPicker.d.ts +6 -0
  11. package/dist/coolandlovely/components/ResalePhotoPicker.d.ts.map +1 -0
  12. package/dist/coolandlovely/components/ResalePhotoPicker.js +150 -0
  13. package/dist/coolandlovely/components/ResalePhotoPicker.js.map +1 -0
  14. package/dist/coolandlovely/hooks/useResale.d.ts +178 -2
  15. package/dist/coolandlovely/hooks/useResale.d.ts.map +1 -1
  16. package/dist/coolandlovely/hooks/useResale.js +75 -42
  17. package/dist/coolandlovely/hooks/useResale.js.map +1 -1
  18. package/dist/coolandlovely/pages/resale/ResaleSellerPage.d.ts.map +1 -1
  19. package/dist/coolandlovely/pages/resale/ResaleSellerPage.js +130 -86
  20. package/dist/coolandlovely/pages/resale/ResaleSellerPage.js.map +1 -1
  21. package/dist/coolandlovely/utils/resaleCreateIntent.d.ts +13 -0
  22. package/dist/coolandlovely/utils/resaleCreateIntent.d.ts.map +1 -0
  23. package/dist/coolandlovely/utils/resaleCreateIntent.js +49 -0
  24. package/dist/coolandlovely/utils/resaleCreateIntent.js.map +1 -0
  25. package/dist/coolandlovely/utils/resalePresentation.d.ts +3 -0
  26. package/dist/coolandlovely/utils/resalePresentation.d.ts.map +1 -1
  27. package/dist/coolandlovely/utils/resalePresentation.js +23 -4
  28. package/dist/coolandlovely/utils/resalePresentation.js.map +1 -1
  29. package/dist/generated/wspace-operations.d.ts +70 -0
  30. package/dist/generated/wspace-operations.d.ts.map +1 -1
  31. package/dist/generated/wspace-operations.js +41 -9
  32. package/dist/generated/wspace-operations.js.map +1 -1
  33. package/package.json +6 -2
@@ -6,25 +6,27 @@ import { useContextNavigation as a } from "../../hooks/useContextNavigation.js";
6
6
  import { CooResaleSaveShopDocument as o } from "../../../generated/wspace-operations.js";
7
7
  import { refreshResaleRead as s, useResaleMutation as c, useResaleSeller as l } from "../../hooks/useResale.js";
8
8
  import { formatResalePrice as u } from "../../utils/resalePresentation.js";
9
- import { useState as d } from "react";
10
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
11
- import { Button as h, GlassCard as g, Pagination as _ } from "@burdenoff/fe-libs/ui";
9
+ import { ResaleListingEditor as d } from "../../components/ResaleListingEditor.js";
10
+ import { ResaleListingActions as f } from "../../components/ResaleListingActions.js";
11
+ import { useCallback as p, useState as m } from "react";
12
+ import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
13
+ import { Button as v, GlassCard as y, Pagination as b } from "@burdenoff/fe-libs/ui";
12
14
  //#region src/coolandlovely/pages/resale/ResaleSellerPage.tsx
13
- var v = "2026-11-02", y = "w-full rounded-lg border border-border-seam bg-bg-surface px-3 py-2 text-text-primary";
14
- function b({ shop: e, onClose: n }) {
15
- let r = t(), i = c(o), [a, s] = d(e?.handle ?? ""), [l, u] = d(e?.name ?? ""), [f, g] = d(e?.description ?? ""), [_, b] = d(!1), [x, S] = d("");
16
- return /* @__PURE__ */ m("form", {
15
+ var x = "2026-11-02", S = "w-full rounded-lg border border-border-seam bg-bg-surface px-3 py-2 text-text-primary";
16
+ function C({ shop: e, onClose: n }) {
17
+ let r = t(), i = c(o), [a, s] = m(e?.handle ?? ""), [l, u] = m(e?.name ?? ""), [d, f] = m(e?.description ?? ""), [p, h] = m(!1), [y, b] = m("");
18
+ return /* @__PURE__ */ _("form", {
17
19
  onSubmit: (t) => {
18
- if (t.preventDefault(), !(!_ || i.isPending || i.isError)) {
19
- if (!l.trim() || !f.trim()) {
20
- S(r("coolandlovely.resale.shopDetailsRequired", "Enter a shop name and description containing non-space characters."));
20
+ if (t.preventDefault(), !(!p || i.isPending || i.isError)) {
21
+ if (!l.trim() || !d.trim()) {
22
+ b(r("coolandlovely.resale.shopDetailsRequired", "Enter a shop name and description containing non-space characters."));
21
23
  return;
22
24
  }
23
- S(""), i.mutate({ input: {
25
+ b(""), i.mutate({ input: {
24
26
  handle: a.trim().toLowerCase(),
25
27
  name: l.trim(),
26
- description: f.trim(),
27
- acceptedPolicyVersion: v,
28
+ description: d.trim(),
29
+ acceptedPolicyVersion: x,
28
30
  expectedVersion: e?.version
29
31
  } }, { onSuccess: n });
30
32
  }
@@ -32,9 +34,9 @@ function b({ shop: e, onClose: n }) {
32
34
  "aria-label": "Resale shop details",
33
35
  className: "space-y-4",
34
36
  children: [
35
- /* @__PURE__ */ m("label", {
37
+ /* @__PURE__ */ _("label", {
36
38
  className: "grid gap-1 text-sm text-text-secondary",
37
- children: [r("coolandlovely.resale.shopHandle", "Shop handle"), /* @__PURE__ */ p("input", {
39
+ children: [r("coolandlovely.resale.shopHandle", "Shop handle"), /* @__PURE__ */ g("input", {
38
40
  required: !0,
39
41
  minLength: 3,
40
42
  maxLength: 80,
@@ -42,77 +44,77 @@ function b({ shop: e, onClose: n }) {
42
44
  value: a,
43
45
  disabled: i.isPending,
44
46
  onChange: (e) => s(e.target.value.toLowerCase()),
45
- className: y
47
+ className: S
46
48
  })]
47
49
  }),
48
- /* @__PURE__ */ p("p", {
50
+ /* @__PURE__ */ g("p", {
49
51
  className: "text-sm text-text-secondary",
50
52
  children: r("coolandlovely.resale.handleHelp", "Use 3–80 lowercase letters, digits or interior hyphens.")
51
53
  }),
52
- /* @__PURE__ */ m("label", {
54
+ /* @__PURE__ */ _("label", {
53
55
  className: "grid gap-1 text-sm text-text-secondary",
54
- children: [r("coolandlovely.resale.shopName", "Shop name"), /* @__PURE__ */ p("input", {
56
+ children: [r("coolandlovely.resale.shopName", "Shop name"), /* @__PURE__ */ g("input", {
55
57
  required: !0,
56
58
  maxLength: 160,
57
59
  value: l,
58
60
  disabled: i.isPending,
59
61
  onChange: (e) => u(e.target.value),
60
- className: y
62
+ className: S
61
63
  })]
62
64
  }),
63
- /* @__PURE__ */ m("label", {
65
+ /* @__PURE__ */ _("label", {
64
66
  className: "grid gap-1 text-sm text-text-secondary",
65
- children: [r("coolandlovely.resale.shopDescription", "Shop description"), /* @__PURE__ */ p("textarea", {
67
+ children: [r("coolandlovely.resale.shopDescription", "Shop description"), /* @__PURE__ */ g("textarea", {
66
68
  required: !0,
67
69
  maxLength: 2e3,
68
- value: f,
70
+ value: d,
69
71
  disabled: i.isPending,
70
- onChange: (e) => g(e.target.value),
71
- className: `${y} min-h-28`
72
+ onChange: (e) => f(e.target.value),
73
+ className: `${S} min-h-28`
72
74
  })]
73
75
  }),
74
- /* @__PURE__ */ m("div", {
76
+ /* @__PURE__ */ _("div", {
75
77
  className: "space-y-2 rounded-lg border border-border-seam p-4 text-sm text-text-secondary",
76
78
  children: [
77
- /* @__PURE__ */ m("h3", {
79
+ /* @__PURE__ */ _("h3", {
78
80
  className: "font-semibold text-text-primary",
79
81
  children: [
80
82
  r("coolandlovely.resale.policyTitle", "Seller declaration"),
81
83
  " · ",
82
- v
84
+ x
83
85
  ]
84
86
  }),
85
- /* @__PURE__ */ p("p", { children: r("coolandlovely.resale.policyOwnership", "Offer only fashion items you own and can accurately describe. Counterfeit or prohibited items are not permitted. Use product photos you have the right to publish.") }),
86
- /* @__PURE__ */ p("p", { children: r("coolandlovely.resale.policyReview", "Your shop and listings require review before publication. Editing shop details starts a new review; existing approval does not apply to changed details.") }),
87
- /* @__PURE__ */ m("label", {
87
+ /* @__PURE__ */ g("p", { children: r("coolandlovely.resale.policyOwnership", "Offer only fashion items you own and can accurately describe. Counterfeit or prohibited items are not permitted. Use product photos you have the right to publish.") }),
88
+ /* @__PURE__ */ g("p", { children: r("coolandlovely.resale.policyReview", "Your shop and listings require review before publication. Editing shop details starts a new review; existing approval does not apply to changed details.") }),
89
+ /* @__PURE__ */ _("label", {
88
90
  className: "flex items-start gap-2",
89
- children: [/* @__PURE__ */ p("input", {
91
+ children: [/* @__PURE__ */ g("input", {
90
92
  type: "checkbox",
91
93
  required: !0,
92
- checked: _,
94
+ checked: p,
93
95
  disabled: i.isPending,
94
- onChange: (e) => b(e.target.checked)
95
- }), /* @__PURE__ */ p("span", { children: r("coolandlovely.resale.acceptPolicy", "I confirm this declaration and accept the current resale policy version.") })]
96
+ onChange: (e) => h(e.target.checked)
97
+ }), /* @__PURE__ */ g("span", { children: r("coolandlovely.resale.acceptPolicy", "I confirm this declaration and accept the current resale policy version.") })]
96
98
  })
97
99
  ]
98
100
  }),
99
- x && /* @__PURE__ */ p("p", {
101
+ y && /* @__PURE__ */ g("p", {
100
102
  role: "alert",
101
103
  className: "text-status-error-text",
102
- children: x
104
+ children: y
103
105
  }),
104
- i.isError && /* @__PURE__ */ p("p", {
106
+ i.isError && /* @__PURE__ */ g("p", {
105
107
  role: "alert",
106
108
  className: "text-status-error-text",
107
109
  children: r("coolandlovely.resale.shopUnconfirmed", "The shop update was not confirmed. Close this form and refresh the authoritative shop status before trying again.")
108
110
  }),
109
- /* @__PURE__ */ m("div", {
111
+ /* @__PURE__ */ _("div", {
110
112
  className: "flex flex-wrap gap-2",
111
- children: [/* @__PURE__ */ p(h, {
113
+ children: [/* @__PURE__ */ g(v, {
112
114
  type: "submit",
113
- disabled: !_ || i.isPending || i.isError,
115
+ disabled: !p || i.isPending || i.isError,
114
116
  children: r("coolandlovely.resale.saveShop", "Submit shop for review")
115
- }), /* @__PURE__ */ p(h, {
117
+ }), /* @__PURE__ */ g(v, {
116
118
  variant: "outline",
117
119
  type: "button",
118
120
  disabled: i.isPending,
@@ -123,37 +125,43 @@ function b({ shop: e, onClose: n }) {
123
125
  ]
124
126
  });
125
127
  }
126
- function x({ items: e }) {
127
- let r = t();
128
- return e.length === 0 ? /* @__PURE__ */ p("p", {
128
+ function w({ items: e, shopApproved: r, onRefresh: i, onEditingChange: a }) {
129
+ let o = t();
130
+ return e.length === 0 ? /* @__PURE__ */ g("p", {
129
131
  role: "status",
130
132
  className: "text-text-secondary",
131
- children: r("coolandlovely.resale.noOwnListings", "No listings were found for your current account and workspace.")
132
- }) : /* @__PURE__ */ p("ul", {
133
+ children: o("coolandlovely.resale.noOwnListings", "No listings were found for your current account and workspace.")
134
+ }) : /* @__PURE__ */ g("ul", {
133
135
  className: "grid gap-4 sm:grid-cols-2",
134
136
  "aria-label": "My resale listings",
135
- children: e.map((e) => /* @__PURE__ */ p("li", { children: /* @__PURE__ */ m(g, {
137
+ children: e.map((e) => /* @__PURE__ */ g("li", { children: /* @__PURE__ */ _(y, {
136
138
  className: "min-w-0 space-y-3 p-4",
137
139
  children: [
138
- e.photoUrls[0] && /* @__PURE__ */ p("img", {
140
+ e.photoUrls[0] && /* @__PURE__ */ g("img", {
139
141
  src: e.photoUrls[0],
140
142
  alt: e.title,
141
143
  loading: "lazy",
142
144
  className: "aspect-video w-full rounded-lg object-cover"
143
145
  }),
144
- /* @__PURE__ */ p("h3", {
146
+ /* @__PURE__ */ g("h3", {
145
147
  className: "break-words text-lg font-semibold text-text-primary",
146
148
  children: e.title
147
149
  }),
148
- /* @__PURE__ */ p("p", {
150
+ /* @__PURE__ */ g("p", {
149
151
  className: "text-text-primary",
150
152
  children: u(e.priceMinor, e.currency)
151
153
  }),
152
- /* @__PURE__ */ m("div", {
154
+ /* @__PURE__ */ _("div", {
153
155
  className: "flex flex-wrap gap-2",
154
- children: [/* @__PURE__ */ p(n, { status: e.status }), /* @__PURE__ */ p(n, { status: e.moderationStatus })]
156
+ children: [/* @__PURE__ */ g(n, { status: e.status }), /* @__PURE__ */ g(n, { status: e.moderationStatus })]
155
157
  }),
156
- e.reviewNotes && /* @__PURE__ */ p("p", {
158
+ /* @__PURE__ */ g(f, {
159
+ listing: e,
160
+ shopApproved: r,
161
+ onRefresh: i,
162
+ onEditingChange: a
163
+ }),
164
+ e.reviewNotes && /* @__PURE__ */ g("p", {
157
165
  className: "whitespace-pre-wrap break-words text-sm text-text-secondary",
158
166
  children: e.reviewNotes
159
167
  })
@@ -161,75 +169,111 @@ function x({ items: e }) {
161
169
  }) }, e.id))
162
170
  });
163
171
  }
164
- function S() {
165
- let o = t(), c = a(), [u, v] = d(0), [y, S] = d(!1), C = l(u), w = C.data?.cooMyResaleShop, T = C.data?.cooMyResaleListings.items ?? [];
166
- return /* @__PURE__ */ p(e, {
172
+ function T() {
173
+ let o = t(), c = a(), [u, f] = m(0), [x, S] = m(!1), [T, E] = m(!1), [D, O] = m(() => /* @__PURE__ */ new Set()), k = p((e, t) => {
174
+ O((n) => {
175
+ if (n.has(e) === t) return n;
176
+ let r = new Set(n);
177
+ return t ? r.add(e) : r.delete(e), r;
178
+ });
179
+ }, []), A = T || x || D.size > 0, j = l(u), M = j.data?.cooMyResaleShop, N = j.data?.cooMyResaleListings.items ?? [];
180
+ return /* @__PURE__ */ g(e, {
167
181
  title: o("coolandlovely.resale.myShop", "My resale shop"),
168
- actions: /* @__PURE__ */ p(h, {
182
+ actions: /* @__PURE__ */ g(v, {
169
183
  variant: "outline",
170
184
  onClick: () => c("resale"),
171
185
  children: o("coolandlovely.resale.back", "Back to marketplace")
172
186
  }),
173
- children: /* @__PURE__ */ m("div", {
187
+ children: /* @__PURE__ */ _("div", {
174
188
  className: "space-y-5",
175
- children: [/* @__PURE__ */ m("div", {
189
+ children: [/* @__PURE__ */ _("div", {
176
190
  className: "flex flex-wrap gap-2",
177
- children: [/* @__PURE__ */ p(h, {
191
+ children: [/* @__PURE__ */ g(v, {
178
192
  variant: "outline",
179
- disabled: C.isFetching,
180
- onClick: () => s(C.refetch),
193
+ disabled: j.isFetching,
194
+ onClick: () => s(j.refetch),
181
195
  children: o("coolandlovely.resale.refreshShop", "Refresh shop status")
182
- }), /* @__PURE__ */ p(h, {
196
+ }), /* @__PURE__ */ g(v, {
183
197
  variant: "outline",
184
198
  onClick: () => c("resale/reports"),
185
199
  children: o("coolandlovely.resale.myReports", "My reports")
186
200
  })]
187
- }), C.isPending ? /* @__PURE__ */ p(i, {}) : C.isError ? /* @__PURE__ */ p(r, { onRetry: () => s(C.refetch) }) : /* @__PURE__ */ m(f, { children: [
188
- /* @__PURE__ */ m(g, {
201
+ }), j.isPending ? /* @__PURE__ */ g(i, {}) : j.isError && !j.data ? /* @__PURE__ */ g(r, { onRetry: () => s(j.refetch) }) : /* @__PURE__ */ _(h, { children: [
202
+ j.isError && /* @__PURE__ */ g("p", {
203
+ role: "alert",
204
+ className: "text-status-error-text",
205
+ children: o("coolandlovely.resale.refreshUnconfirmed", "Shop status could not be refreshed. Showing the last loaded values and preserving your unsaved fields. Refresh again before relying on current status.")
206
+ }),
207
+ /* @__PURE__ */ _(y, {
189
208
  className: "space-y-4 p-5",
190
- children: [/* @__PURE__ */ m("div", {
209
+ children: [/* @__PURE__ */ _("div", {
191
210
  className: "flex flex-wrap items-center justify-between gap-2",
192
- children: [/* @__PURE__ */ p("h2", {
211
+ children: [/* @__PURE__ */ g("h2", {
193
212
  className: "break-words text-xl font-semibold text-text-primary",
194
- children: w?.name ?? o("coolandlovely.resale.openShop", "Open a resale shop")
195
- }), w && /* @__PURE__ */ p(n, { status: w.reviewStatus })]
196
- }), y || !w ? /* @__PURE__ */ p(b, {
197
- shop: w,
198
- onClose: () => w ? S(!1) : c("resale")
199
- }, `${w?.id ?? "new"}:${w?.version ?? 0}`) : /* @__PURE__ */ m(f, { children: [
200
- /* @__PURE__ */ p("p", {
213
+ children: M?.name ?? o("coolandlovely.resale.openShop", "Open a resale shop")
214
+ }), M && /* @__PURE__ */ g(n, { status: M.reviewStatus })]
215
+ }), x || !M ? /* @__PURE__ */ g(C, {
216
+ shop: M,
217
+ onClose: () => M ? S(!1) : c("resale")
218
+ }, `${M?.id ?? "new"}:${M?.version ?? 0}`) : /* @__PURE__ */ _(h, { children: [
219
+ /* @__PURE__ */ g("p", {
201
220
  className: "whitespace-pre-wrap break-words text-text-secondary",
202
- children: w.description
221
+ children: M.description
203
222
  }),
204
- w.reviewNotes && /* @__PURE__ */ p("p", {
223
+ M.reviewNotes && /* @__PURE__ */ g("p", {
205
224
  className: "whitespace-pre-wrap break-words text-sm text-text-secondary",
206
- children: w.reviewNotes
225
+ children: M.reviewNotes
207
226
  }),
208
- /* @__PURE__ */ p(h, {
227
+ /* @__PURE__ */ g(v, {
209
228
  variant: "outline",
229
+ disabled: T,
210
230
  onClick: () => S(!0),
211
231
  children: o("coolandlovely.resale.editShop", "Edit shop details")
212
232
  })
213
233
  ] })]
214
234
  }),
215
- /* @__PURE__ */ p("h2", {
235
+ /* @__PURE__ */ g("h2", {
216
236
  className: "text-xl font-semibold text-text-primary",
217
237
  children: o("coolandlovely.resale.myListings", "My listings")
218
238
  }),
219
- /* @__PURE__ */ p(x, { items: T }),
220
- /* @__PURE__ */ p(_, {
239
+ M && !T && /* @__PURE__ */ g(v, {
240
+ type: "button",
241
+ disabled: x,
242
+ onClick: () => E(!0),
243
+ children: o("coolandlovely.resale.editor.create", "Create listing")
244
+ }),
245
+ T && /* @__PURE__ */ g(y, {
246
+ className: "p-4",
247
+ children: /* @__PURE__ */ g(d, { onClose: () => E(!1) })
248
+ }),
249
+ /* @__PURE__ */ g(w, {
250
+ items: N,
251
+ onEditingChange: k,
252
+ shopApproved: M?.reviewStatus === "APPROVED",
253
+ onRefresh: async () => {
254
+ let e = j.dataUpdatedAt, t = await s(j.refetch);
255
+ return t.isSuccess && t.fetchStatus === "idle" && t.dataUpdatedAt > e;
256
+ }
257
+ }),
258
+ A && /* @__PURE__ */ g("p", {
259
+ className: "text-sm text-text-secondary",
260
+ children: o("coolandlovely.resale.closeFormBeforePaging", "Close the open form before changing listing pages.")
261
+ }),
262
+ /* @__PURE__ */ g(b, {
221
263
  page: u + 1,
222
264
  pageSize: 20,
223
- hasNextPage: C.data?.cooMyResaleListings.pageInfo.hasMore ?? !1,
265
+ hasNextPage: j.data?.cooMyResaleListings.pageInfo.hasMore ?? !1,
224
266
  hasPreviousPage: u > 0,
225
- loading: C.isFetching,
226
- onPageChange: (e) => v(e - 1)
267
+ loading: j.isFetching || A,
268
+ onPageChange: (e) => {
269
+ A || f(e - 1);
270
+ }
227
271
  })
228
272
  ] })]
229
273
  })
230
274
  });
231
275
  }
232
276
  //#endregion
233
- export { S as ResaleSellerPage };
277
+ export { T as ResaleSellerPage };
234
278
 
235
279
  //# sourceMappingURL=ResaleSellerPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ResaleSellerPage.js","names":[],"sources":["../../../../src/coolandlovely/pages/resale/ResaleSellerPage.tsx"],"sourcesContent":["import { useState, type FormEvent } from 'react';\nimport { Button, GlassCard, Pagination } from '@burdenoff/fe-libs/ui';\nimport {\n CooResaleSaveShopDocument,\n type CooResaleSaveShopMutation,\n type CooResaleSaveShopMutationVariables,\n} from '../../../generated/wspace-operations';\nimport { PageLayout } from '../../components/PageLayout';\nimport { ErrorView, LoadingView } from '../../components/StateViews';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { useContextNavigation } from '../../hooks/useContextNavigation';\nimport {\n RESALE_PAGE_SIZE,\n refreshResaleRead,\n useResaleMutation,\n useResaleSeller,\n type ResaleShop,\n type ResaleOwnListing,\n} from '../../hooks/useResale';\nimport { useTr } from '../../hooks/useTr';\nimport { formatResalePrice } from '../../utils/resalePresentation';\n\nconst POLICY_VERSION = '2026-11-02';\nconst control =\n 'w-full rounded-lg border border-border-seam bg-bg-surface px-3 py-2 text-text-primary';\n\nfunction ShopEditor({ shop, onClose }: { shop?: ResaleShop | null; onClose(): void }) {\n const tr = useTr();\n const save = useResaleMutation<CooResaleSaveShopMutation, CooResaleSaveShopMutationVariables>(\n CooResaleSaveShopDocument\n );\n const [handle, setHandle] = useState(shop?.handle ?? '');\n const [name, setName] = useState(shop?.name ?? '');\n const [description, setDescription] = useState(shop?.description ?? '');\n const [accepted, setAccepted] = useState(false);\n const [validation, setValidation] = useState('');\n const submit = (event: FormEvent) => {\n event.preventDefault();\n if (!accepted || save.isPending || save.isError) return;\n if (!name.trim() || !description.trim()) {\n setValidation(\n tr(\n 'coolandlovely.resale.shopDetailsRequired',\n 'Enter a shop name and description containing non-space characters.'\n )\n );\n return;\n }\n setValidation('');\n save.mutate(\n {\n input: {\n handle: handle.trim().toLowerCase(),\n name: name.trim(),\n description: description.trim(),\n acceptedPolicyVersion: POLICY_VERSION,\n expectedVersion: shop?.version,\n },\n },\n { onSuccess: onClose }\n );\n };\n return (\n <form onSubmit={submit} aria-label=\"Resale shop details\" className=\"space-y-4\">\n <label className=\"grid gap-1 text-sm text-text-secondary\">\n {tr('coolandlovely.resale.shopHandle', 'Shop handle')}\n <input\n required\n minLength={3}\n maxLength={80}\n pattern=\"[a-z0-9]([a-z0-9-]{1,78}[a-z0-9])\"\n value={handle}\n disabled={save.isPending}\n onChange={(event) => setHandle(event.target.value.toLowerCase())}\n className={control}\n />\n </label>\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'coolandlovely.resale.handleHelp',\n 'Use 3–80 lowercase letters, digits or interior hyphens.'\n )}\n </p>\n <label className=\"grid gap-1 text-sm text-text-secondary\">\n {tr('coolandlovely.resale.shopName', 'Shop name')}\n <input\n required\n maxLength={160}\n value={name}\n disabled={save.isPending}\n onChange={(event) => setName(event.target.value)}\n className={control}\n />\n </label>\n <label className=\"grid gap-1 text-sm text-text-secondary\">\n {tr('coolandlovely.resale.shopDescription', 'Shop description')}\n <textarea\n required\n maxLength={2000}\n value={description}\n disabled={save.isPending}\n onChange={(event) => setDescription(event.target.value)}\n className={`${control} min-h-28`}\n />\n </label>\n <div className=\"space-y-2 rounded-lg border border-border-seam p-4 text-sm text-text-secondary\">\n <h3 className=\"font-semibold text-text-primary\">\n {tr('coolandlovely.resale.policyTitle', 'Seller declaration')} · {POLICY_VERSION}\n </h3>\n <p>\n {tr(\n 'coolandlovely.resale.policyOwnership',\n 'Offer only fashion items you own and can accurately describe. Counterfeit or prohibited items are not permitted. Use product photos you have the right to publish.'\n )}\n </p>\n <p>\n {tr(\n 'coolandlovely.resale.policyReview',\n 'Your shop and listings require review before publication. Editing shop details starts a new review; existing approval does not apply to changed details.'\n )}\n </p>\n <label className=\"flex items-start gap-2\">\n <input\n type=\"checkbox\"\n required\n checked={accepted}\n disabled={save.isPending}\n onChange={(event) => setAccepted(event.target.checked)}\n />\n <span>\n {tr(\n 'coolandlovely.resale.acceptPolicy',\n 'I confirm this declaration and accept the current resale policy version.'\n )}\n </span>\n </label>\n </div>\n {validation && (\n <p role=\"alert\" className=\"text-status-error-text\">\n {validation}\n </p>\n )}\n {save.isError && (\n <p role=\"alert\" className=\"text-status-error-text\">\n {tr(\n 'coolandlovely.resale.shopUnconfirmed',\n 'The shop update was not confirmed. Close this form and refresh the authoritative shop status before trying again.'\n )}\n </p>\n )}\n <div className=\"flex flex-wrap gap-2\">\n <Button type=\"submit\" disabled={!accepted || save.isPending || save.isError}>\n {tr('coolandlovely.resale.saveShop', 'Submit shop for review')}\n </Button>\n <Button variant=\"outline\" type=\"button\" disabled={save.isPending} onClick={onClose}>\n {tr('coolandlovely.common.cancel', 'Cancel')}\n </Button>\n </div>\n </form>\n );\n}\n\nfunction SellerListings({ items }: { items: ResaleOwnListing[] }) {\n const tr = useTr();\n return items.length === 0 ? (\n <p role=\"status\" className=\"text-text-secondary\">\n {tr(\n 'coolandlovely.resale.noOwnListings',\n 'No listings were found for your current account and workspace.'\n )}\n </p>\n ) : (\n <ul className=\"grid gap-4 sm:grid-cols-2\" aria-label=\"My resale listings\">\n {items.map((item) => (\n <li key={item.id}>\n <GlassCard className=\"min-w-0 space-y-3 p-4\">\n {item.photoUrls[0] && (\n <img\n src={item.photoUrls[0]}\n alt={item.title}\n loading=\"lazy\"\n className=\"aspect-video w-full rounded-lg object-cover\"\n />\n )}\n <h3 className=\"break-words text-lg font-semibold text-text-primary\">{item.title}</h3>\n <p className=\"text-text-primary\">{formatResalePrice(item.priceMinor, item.currency)}</p>\n <div className=\"flex flex-wrap gap-2\">\n <StatusBadge status={item.status} />\n <StatusBadge status={item.moderationStatus} />\n </div>\n {item.reviewNotes && (\n <p className=\"whitespace-pre-wrap break-words text-sm text-text-secondary\">\n {item.reviewNotes}\n </p>\n )}\n </GlassCard>\n </li>\n ))}\n </ul>\n );\n}\n\nexport function ResaleSellerPage() {\n const tr = useTr();\n const navigate = useContextNavigation();\n const [page, setPage] = useState(0);\n const [editing, setEditing] = useState(false);\n const seller = useResaleSeller(page);\n const shop = seller.data?.cooMyResaleShop;\n const items = seller.data?.cooMyResaleListings.items ?? [];\n return (\n <PageLayout\n title={tr('coolandlovely.resale.myShop', 'My resale shop')}\n actions={\n <Button variant=\"outline\" onClick={() => navigate('resale')}>\n {tr('coolandlovely.resale.back', 'Back to marketplace')}\n </Button>\n }\n >\n <div className=\"space-y-5\">\n <div className=\"flex flex-wrap gap-2\">\n <Button\n variant=\"outline\"\n disabled={seller.isFetching}\n onClick={() => refreshResaleRead(seller.refetch)}\n >\n {tr('coolandlovely.resale.refreshShop', 'Refresh shop status')}\n </Button>\n <Button variant=\"outline\" onClick={() => navigate('resale/reports')}>\n {tr('coolandlovely.resale.myReports', 'My reports')}\n </Button>\n </div>\n {seller.isPending ? (\n <LoadingView />\n ) : seller.isError ? (\n <ErrorView onRetry={() => refreshResaleRead(seller.refetch)} />\n ) : (\n <>\n <GlassCard className=\"space-y-4 p-5\">\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <h2 className=\"break-words text-xl font-semibold text-text-primary\">\n {shop?.name ?? tr('coolandlovely.resale.openShop', 'Open a resale shop')}\n </h2>\n {shop && <StatusBadge status={shop.reviewStatus} />}\n </div>\n {editing || !shop ? (\n <ShopEditor\n key={`${shop?.id ?? 'new'}:${shop?.version ?? 0}`}\n shop={shop}\n onClose={() => (shop ? setEditing(false) : navigate('resale'))}\n />\n ) : (\n <>\n <p className=\"whitespace-pre-wrap break-words text-text-secondary\">\n {shop.description}\n </p>\n {shop.reviewNotes && (\n <p className=\"whitespace-pre-wrap break-words text-sm text-text-secondary\">\n {shop.reviewNotes}\n </p>\n )}\n <Button variant=\"outline\" onClick={() => setEditing(true)}>\n {tr('coolandlovely.resale.editShop', 'Edit shop details')}\n </Button>\n </>\n )}\n </GlassCard>\n <h2 className=\"text-xl font-semibold text-text-primary\">\n {tr('coolandlovely.resale.myListings', 'My listings')}\n </h2>\n <SellerListings items={items} />\n <Pagination\n page={page + 1}\n pageSize={RESALE_PAGE_SIZE}\n hasNextPage={seller.data?.cooMyResaleListings.pageInfo.hasMore ?? false}\n hasPreviousPage={page > 0}\n loading={seller.isFetching}\n onPageChange={(next) => setPage(next - 1)}\n />\n </>\n )}\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,IAAM,IAAiB,cACjB,IACJ;AAEF,SAAS,EAAW,EAAE,SAAM,cAA0D;CACpF,IAAM,IAAK,EAAM,GACX,IAAO,EACX,CACF,GACM,CAAC,GAAQ,KAAa,EAAS,GAAM,UAAU,EAAE,GACjD,CAAC,GAAM,KAAW,EAAS,GAAM,QAAQ,EAAE,GAC3C,CAAC,GAAa,KAAkB,EAAS,GAAM,eAAe,EAAE,GAChE,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,CAAC,GAAY,KAAiB,EAAS,EAAE;CA2B/C,OACE,kBAAC,QAAD;EAAM,WA3BQ,MAAqB;GACnC,MAAM,eAAe,GACjB,GAAC,KAAY,EAAK,aAAa,EAAK,UACxC;QAAI,CAAC,EAAK,KAAK,KAAK,CAAC,EAAY,KAAK,GAAG;KACvC,EACE,EACE,4CACA,oEACF,CACF;KACA;IACF;IAEA,AADA,EAAc,EAAE,GAChB,EAAK,OACH,EACE,OAAO;KACL,QAAQ,EAAO,KAAK,CAAC,CAA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AAD;MAEQ;MACN,eAAgB,IAAO,EAAW,EAAK,IAAI,EAAS,QAAQ;KAC7D,GAHM,GAAG,GAAM,MAAM,MAAM,GAAG,GAAM,WAAW,GAG/C,IAED,kBAAA,GAAA,EAAA,UAAA;MACE,kBAAC,KAAD;OAAG,WAAU;iBACV,EAAK;MACL,CAAA;MACF,EAAK,eACJ,kBAAC,KAAD;OAAG,WAAU;iBACV,EAAK;MACL,CAAA;MAEL,kBAAC,GAAD;OAAQ,SAAQ;OAAU,eAAe,EAAW,EAAI;iBACrD,EAAG,iCAAiC,mBAAmB;MAClD,CAAA;KACR,EAAA,CAAA,CAEK;;IACX,kBAAC,MAAD;KAAI,WAAU;eACX,EAAG,mCAAmC,aAAa;IAClD,CAAA;IACJ,kBAAC,GAAD,EAAuB,SAAQ,CAAA;IAC/B,kBAAC,GAAD;KACE,MAAM,IAAO;KACb,UAAA;KACA,aAAa,EAAO,MAAM,oBAAoB,SAAS,WAAW;KAClE,iBAAiB,IAAO;KACxB,SAAS,EAAO;KAChB,eAAe,MAAS,EAAQ,IAAO,CAAC;IACzC,CAAA;GACD,EAAA,CAAA,CAED;;CACK,CAAA;AAEhB"}
1
+ {"version":3,"file":"ResaleSellerPage.js","names":[],"sources":["../../../../src/coolandlovely/pages/resale/ResaleSellerPage.tsx"],"sourcesContent":["import { useCallback, useState, type FormEvent } from 'react';\nimport { Button, GlassCard, Pagination } from '@burdenoff/fe-libs/ui';\nimport {\n CooResaleSaveShopDocument,\n type CooResaleSaveShopMutation,\n type CooResaleSaveShopMutationVariables,\n} from '../../../generated/wspace-operations';\nimport { PageLayout } from '../../components/PageLayout';\nimport { ErrorView, LoadingView } from '../../components/StateViews';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { ResaleListingEditor } from '../../components/ResaleListingEditor';\nimport { ResaleListingActions } from '../../components/ResaleListingActions';\nimport { useContextNavigation } from '../../hooks/useContextNavigation';\nimport {\n RESALE_PAGE_SIZE,\n refreshResaleRead,\n useResaleMutation,\n useResaleSeller,\n type ResaleShop,\n type ResaleOwnListing,\n} from '../../hooks/useResale';\nimport { useTr } from '../../hooks/useTr';\nimport { formatResalePrice } from '../../utils/resalePresentation';\n\nconst POLICY_VERSION = '2026-11-02';\nconst control =\n 'w-full rounded-lg border border-border-seam bg-bg-surface px-3 py-2 text-text-primary';\n\nfunction ShopEditor({ shop, onClose }: { shop?: ResaleShop | null; onClose(): void }) {\n const tr = useTr();\n const save = useResaleMutation<CooResaleSaveShopMutation, CooResaleSaveShopMutationVariables>(\n CooResaleSaveShopDocument\n );\n const [handle, setHandle] = useState(shop?.handle ?? '');\n const [name, setName] = useState(shop?.name ?? '');\n const [description, setDescription] = useState(shop?.description ?? '');\n const [accepted, setAccepted] = useState(false);\n const [validation, setValidation] = useState('');\n const submit = (event: FormEvent) => {\n event.preventDefault();\n if (!accepted || save.isPending || save.isError) return;\n if (!name.trim() || !description.trim()) {\n setValidation(\n tr(\n 'coolandlovely.resale.shopDetailsRequired',\n 'Enter a shop name and description containing non-space characters.'\n )\n );\n return;\n }\n setValidation('');\n save.mutate(\n {\n input: {\n handle: handle.trim().toLowerCase(),\n name: name.trim(),\n description: description.trim(),\n acceptedPolicyVersion: POLICY_VERSION,\n expectedVersion: shop?.version,\n },\n },\n { onSuccess: onClose }\n );\n };\n return (\n <form onSubmit={submit} aria-label=\"Resale shop details\" className=\"space-y-4\">\n <label className=\"grid gap-1 text-sm text-text-secondary\">\n {tr('coolandlovely.resale.shopHandle', 'Shop handle')}\n <input\n required\n minLength={3}\n maxLength={80}\n pattern=\"[a-z0-9]([a-z0-9-]{1,78}[a-z0-9])\"\n value={handle}\n disabled={save.isPending}\n onChange={(event) => setHandle(event.target.value.toLowerCase())}\n className={control}\n />\n </label>\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'coolandlovely.resale.handleHelp',\n 'Use 3–80 lowercase letters, digits or interior hyphens.'\n )}\n </p>\n <label className=\"grid gap-1 text-sm text-text-secondary\">\n {tr('coolandlovely.resale.shopName', 'Shop name')}\n <input\n required\n maxLength={160}\n value={name}\n disabled={save.isPending}\n onChange={(event) => setName(event.target.value)}\n className={control}\n />\n </label>\n <label className=\"grid gap-1 text-sm text-text-secondary\">\n {tr('coolandlovely.resale.shopDescription', 'Shop description')}\n <textarea\n required\n maxLength={2000}\n value={description}\n disabled={save.isPending}\n onChange={(event) => setDescription(event.target.value)}\n className={`${control} min-h-28`}\n />\n </label>\n <div className=\"space-y-2 rounded-lg border border-border-seam p-4 text-sm text-text-secondary\">\n <h3 className=\"font-semibold text-text-primary\">\n {tr('coolandlovely.resale.policyTitle', 'Seller declaration')} · {POLICY_VERSION}\n </h3>\n <p>\n {tr(\n 'coolandlovely.resale.policyOwnership',\n 'Offer only fashion items you own and can accurately describe. Counterfeit or prohibited items are not permitted. Use product photos you have the right to publish.'\n )}\n </p>\n <p>\n {tr(\n 'coolandlovely.resale.policyReview',\n 'Your shop and listings require review before publication. Editing shop details starts a new review; existing approval does not apply to changed details.'\n )}\n </p>\n <label className=\"flex items-start gap-2\">\n <input\n type=\"checkbox\"\n required\n checked={accepted}\n disabled={save.isPending}\n onChange={(event) => setAccepted(event.target.checked)}\n />\n <span>\n {tr(\n 'coolandlovely.resale.acceptPolicy',\n 'I confirm this declaration and accept the current resale policy version.'\n )}\n </span>\n </label>\n </div>\n {validation && (\n <p role=\"alert\" className=\"text-status-error-text\">\n {validation}\n </p>\n )}\n {save.isError && (\n <p role=\"alert\" className=\"text-status-error-text\">\n {tr(\n 'coolandlovely.resale.shopUnconfirmed',\n 'The shop update was not confirmed. Close this form and refresh the authoritative shop status before trying again.'\n )}\n </p>\n )}\n <div className=\"flex flex-wrap gap-2\">\n <Button type=\"submit\" disabled={!accepted || save.isPending || save.isError}>\n {tr('coolandlovely.resale.saveShop', 'Submit shop for review')}\n </Button>\n <Button variant=\"outline\" type=\"button\" disabled={save.isPending} onClick={onClose}>\n {tr('coolandlovely.common.cancel', 'Cancel')}\n </Button>\n </div>\n </form>\n );\n}\n\nfunction SellerListings({\n items,\n shopApproved,\n onRefresh,\n onEditingChange,\n}: {\n items: ResaleOwnListing[];\n shopApproved: boolean;\n onRefresh(): Promise<boolean>;\n onEditingChange(id: string, editing: boolean): void;\n}) {\n const tr = useTr();\n return items.length === 0 ? (\n <p role=\"status\" className=\"text-text-secondary\">\n {tr(\n 'coolandlovely.resale.noOwnListings',\n 'No listings were found for your current account and workspace.'\n )}\n </p>\n ) : (\n <ul className=\"grid gap-4 sm:grid-cols-2\" aria-label=\"My resale listings\">\n {items.map((item) => (\n <li key={item.id}>\n <GlassCard className=\"min-w-0 space-y-3 p-4\">\n {item.photoUrls[0] && (\n <img\n src={item.photoUrls[0]}\n alt={item.title}\n loading=\"lazy\"\n className=\"aspect-video w-full rounded-lg object-cover\"\n />\n )}\n <h3 className=\"break-words text-lg font-semibold text-text-primary\">{item.title}</h3>\n <p className=\"text-text-primary\">{formatResalePrice(item.priceMinor, item.currency)}</p>\n <div className=\"flex flex-wrap gap-2\">\n <StatusBadge status={item.status} />\n <StatusBadge status={item.moderationStatus} />\n </div>\n <ResaleListingActions\n listing={item}\n shopApproved={shopApproved}\n onRefresh={onRefresh}\n onEditingChange={onEditingChange}\n />\n {item.reviewNotes && (\n <p className=\"whitespace-pre-wrap break-words text-sm text-text-secondary\">\n {item.reviewNotes}\n </p>\n )}\n </GlassCard>\n </li>\n ))}\n </ul>\n );\n}\n\nexport function ResaleSellerPage() {\n const tr = useTr();\n const navigate = useContextNavigation();\n const [page, setPage] = useState(0);\n const [editing, setEditing] = useState(false);\n const [creating, setCreating] = useState(false);\n const [listingEditors, setListingEditors] = useState<ReadonlySet<string>>(() => new Set());\n const onListingEditingChange = useCallback((id: string, open: boolean) => {\n setListingEditors((current) => {\n if (current.has(id) === open) return current;\n const next = new Set(current);\n if (open) next.add(id);\n else next.delete(id);\n return next;\n });\n }, []);\n const formOpen = creating || editing || listingEditors.size > 0;\n const seller = useResaleSeller(page);\n const shop = seller.data?.cooMyResaleShop;\n const items = seller.data?.cooMyResaleListings.items ?? [];\n return (\n <PageLayout\n title={tr('coolandlovely.resale.myShop', 'My resale shop')}\n actions={\n <Button variant=\"outline\" onClick={() => navigate('resale')}>\n {tr('coolandlovely.resale.back', 'Back to marketplace')}\n </Button>\n }\n >\n <div className=\"space-y-5\">\n <div className=\"flex flex-wrap gap-2\">\n <Button\n variant=\"outline\"\n disabled={seller.isFetching}\n onClick={() => refreshResaleRead(seller.refetch)}\n >\n {tr('coolandlovely.resale.refreshShop', 'Refresh shop status')}\n </Button>\n <Button variant=\"outline\" onClick={() => navigate('resale/reports')}>\n {tr('coolandlovely.resale.myReports', 'My reports')}\n </Button>\n </div>\n {seller.isPending ? (\n <LoadingView />\n ) : seller.isError && !seller.data ? (\n <ErrorView onRetry={() => refreshResaleRead(seller.refetch)} />\n ) : (\n <>\n {seller.isError && (\n <p role=\"alert\" className=\"text-status-error-text\">\n {tr(\n 'coolandlovely.resale.refreshUnconfirmed',\n 'Shop status could not be refreshed. Showing the last loaded values and preserving your unsaved fields. Refresh again before relying on current status.'\n )}\n </p>\n )}\n <GlassCard className=\"space-y-4 p-5\">\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <h2 className=\"break-words text-xl font-semibold text-text-primary\">\n {shop?.name ?? tr('coolandlovely.resale.openShop', 'Open a resale shop')}\n </h2>\n {shop && <StatusBadge status={shop.reviewStatus} />}\n </div>\n {editing || !shop ? (\n <ShopEditor\n key={`${shop?.id ?? 'new'}:${shop?.version ?? 0}`}\n shop={shop}\n onClose={() => (shop ? setEditing(false) : navigate('resale'))}\n />\n ) : (\n <>\n <p className=\"whitespace-pre-wrap break-words text-text-secondary\">\n {shop.description}\n </p>\n {shop.reviewNotes && (\n <p className=\"whitespace-pre-wrap break-words text-sm text-text-secondary\">\n {shop.reviewNotes}\n </p>\n )}\n <Button variant=\"outline\" disabled={creating} onClick={() => setEditing(true)}>\n {tr('coolandlovely.resale.editShop', 'Edit shop details')}\n </Button>\n </>\n )}\n </GlassCard>\n <h2 className=\"text-xl font-semibold text-text-primary\">\n {tr('coolandlovely.resale.myListings', 'My listings')}\n </h2>\n {shop && !creating && (\n <Button type=\"button\" disabled={editing} onClick={() => setCreating(true)}>\n {tr('coolandlovely.resale.editor.create', 'Create listing')}\n </Button>\n )}\n {creating && (\n <GlassCard className=\"p-4\">\n <ResaleListingEditor onClose={() => setCreating(false)} />\n </GlassCard>\n )}\n <SellerListings\n items={items}\n onEditingChange={onListingEditingChange}\n shopApproved={shop?.reviewStatus === 'APPROVED'}\n onRefresh={async () => {\n const previous = seller.dataUpdatedAt;\n const refreshed = await refreshResaleRead(seller.refetch);\n return (\n refreshed.isSuccess &&\n refreshed.fetchStatus === 'idle' &&\n refreshed.dataUpdatedAt > previous\n );\n }}\n />\n {formOpen && (\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'coolandlovely.resale.closeFormBeforePaging',\n 'Close the open form before changing listing pages.'\n )}\n </p>\n )}\n <Pagination\n page={page + 1}\n pageSize={RESALE_PAGE_SIZE}\n hasNextPage={seller.data?.cooMyResaleListings.pageInfo.hasMore ?? false}\n hasPreviousPage={page > 0}\n loading={seller.isFetching || formOpen}\n onPageChange={(next) => {\n if (!formOpen) setPage(next - 1);\n }}\n />\n </>\n )}\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,IAAM,IAAiB,cACjB,IACJ;AAEF,SAAS,EAAW,EAAE,SAAM,cAA0D;CACpF,IAAM,IAAK,EAAM,GACX,IAAO,EACX,CACF,GACM,CAAC,GAAQ,KAAa,EAAS,GAAM,UAAU,EAAE,GACjD,CAAC,GAAM,KAAW,EAAS,GAAM,QAAQ,EAAE,GAC3C,CAAC,GAAa,KAAkB,EAAS,GAAM,eAAe,EAAE,GAChE,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,CAAC,GAAY,KAAiB,EAAS,EAAE;CA2B/C,OACE,kBAAC,QAAD;EAAM,WA3BQ,MAAqB;GACnC,MAAM,eAAe,GACjB,GAA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H,KAAQ,CAAC,KACR,kBAAC,GAAD;KAAQ,MAAK;KAAS,UAAU;KAAS,eAAe,EAAY,EAAI;eACrE,EAAG,sCAAsC,gBAAgB;IACpD,CAAA;IAET,KACC,kBAAC,GAAD;KAAW,WAAU;eACnB,kBAAC,GAAD,EAAqB,eAAe,EAAY,EAAK,EAAI,CAAA;IAChD,CAAA;IAEb,kBAAC,GAAD;KACS;KACP,iBAAiB;KACjB,cAAc,GAAM,iBAAiB;KACrC,WAAW,YAAY;MACrB,IAAM,IAAW,EAAO,eAClB,IAAY,MAAM,EAAkB,EAAO,OAAO;MACxD,OACE,EAAU,aACV,EAAU,gBAAgB,UAC1B,EAAU,gBAAgB;KAE9B;IACD,CAAA;IACA,KACC,kBAAC,KAAD;KAAG,WAAU;eACV,EACC,8CACA,oDACF;IACC,CAAA;IAEL,kBAAC,GAAD;KACE,MAAM,IAAO;KACb,UAAA;KACA,aAAa,EAAO,MAAM,oBAAoB,SAAS,WAAW;KAClE,iBAAiB,IAAO;KACxB,SAAS,EAAO,cAAc;KAC9B,eAAe,MAAS;MACtB,AAAK,KAAU,EAAQ,IAAO,CAAC;KACjC;IACD,CAAA;GACD,EAAA,CAAA,CAED;;CACK,CAAA;AAEhB"}
@@ -0,0 +1,13 @@
1
+ export interface ResaleCreateIntent {
2
+ requestId: string;
3
+ phase: 'prepared' | 'dispatched';
4
+ }
5
+ /** Only opaque request metadata and nonsecret query scope are persisted, never form data or tokens. */
6
+ export declare function resaleIntentKey(scope: readonly unknown[]): string;
7
+ export declare function readResaleIntent(storage: Storage, key: string): ResaleCreateIntent | null;
8
+ /** Call only while holding this scope's Web Lock. Preparation does not dispatch a mutation. */
9
+ export declare function prepareResaleIntent(storage: Storage, key: string): ResaleCreateIntent;
10
+ /** A stale second tab must never silently allocate another intent or replay a dispatched one. */
11
+ export declare function dispatchResaleIntent(storage: Storage, key: string, requestId: string): void;
12
+ export declare function clearResaleIntent(storage: Storage, key: string, id: string): void;
13
+ //# sourceMappingURL=resaleCreateIntent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resaleCreateIntent.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/utils/resaleCreateIntent.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,UAAU,GAAG,YAAY,CAAC;CAClC;AAED,uGAAuG;AACvG,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAEjE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAqBzF;AAUD,+FAA+F;AAC/F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAMrF;AAED,iGAAiG;AACjG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAQ3F;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAMjF"}
@@ -0,0 +1,49 @@
1
+ //#region src/coolandlovely/utils/resaleCreateIntent.ts
2
+ var e = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
3
+ function t(e) {
4
+ return `coolandlovely:resale:create:${JSON.stringify(e)}`;
5
+ }
6
+ function n(t, n) {
7
+ let r = t.getItem(n);
8
+ if (r === null) return null;
9
+ if (e.test(r)) return {
10
+ requestId: r,
11
+ phase: "dispatched"
12
+ };
13
+ let i = JSON.parse(r);
14
+ if (typeof i != "object" || !i || !("requestId" in i) || !("phase" in i) || Object.keys(i).length !== 2 || typeof i.requestId != "string" || !e.test(i.requestId) || i.phase !== "prepared" && i.phase !== "dispatched") throw Error("The pending listing request cannot be read. Contact support before creating another listing.");
15
+ return {
16
+ requestId: i.requestId,
17
+ phase: i.phase
18
+ };
19
+ }
20
+ function r(e, t, r) {
21
+ e.setItem(t, JSON.stringify(r));
22
+ let i = n(e, t);
23
+ if (i?.requestId !== r.requestId || i.phase !== r.phase) throw Error("The listing request could not be saved safely.");
24
+ }
25
+ function i(e, t) {
26
+ let i = n(e, t);
27
+ if (i) return i;
28
+ let a = {
29
+ requestId: crypto.randomUUID(),
30
+ phase: "prepared"
31
+ };
32
+ return r(e, t, a), a;
33
+ }
34
+ function a(e, t, i) {
35
+ let a = n(e, t);
36
+ if (a?.requestId !== i || a.phase !== "prepared") throw Error("The listing request changed or was already dispatched. Resolve its status first.");
37
+ r(e, t, {
38
+ requestId: i,
39
+ phase: "dispatched"
40
+ });
41
+ }
42
+ function o(e, t, r) {
43
+ if (n(e, t)?.requestId !== r) throw Error("The pending listing request changed. Refresh before continuing.");
44
+ if (e.removeItem(t), e.getItem(t) !== null) throw Error("The listing request is still pending.");
45
+ }
46
+ //#endregion
47
+ export { o as clearResaleIntent, a as dispatchResaleIntent, i as prepareResaleIntent, n as readResaleIntent, t as resaleIntentKey };
48
+
49
+ //# sourceMappingURL=resaleCreateIntent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resaleCreateIntent.js","names":[],"sources":["../../../src/coolandlovely/utils/resaleCreateIntent.ts"],"sourcesContent":["const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nexport interface ResaleCreateIntent {\n requestId: string;\n phase: 'prepared' | 'dispatched';\n}\n\n/** Only opaque request metadata and nonsecret query scope are persisted, never form data or tokens. */\nexport function resaleIntentKey(scope: readonly unknown[]): string {\n return `coolandlovely:resale:create:${JSON.stringify(scope)}`;\n}\n\nexport function readResaleIntent(storage: Storage, key: string): ResaleCreateIntent | null {\n const value = storage.getItem(key);\n if (value === null) return null;\n // Earlier source previews stored a dispatched UUID directly. Never forget that possible write.\n if (UUID.test(value)) return { requestId: value, phase: 'dispatched' };\n const parsed: unknown = JSON.parse(value);\n if (\n typeof parsed !== 'object' ||\n parsed === null ||\n !('requestId' in parsed) ||\n !('phase' in parsed) ||\n Object.keys(parsed).length !== 2 ||\n typeof parsed.requestId !== 'string' ||\n !UUID.test(parsed.requestId) ||\n (parsed.phase !== 'prepared' && parsed.phase !== 'dispatched')\n ) {\n throw new Error(\n 'The pending listing request cannot be read. Contact support before creating another listing.'\n );\n }\n return { requestId: parsed.requestId, phase: parsed.phase };\n}\n\nfunction writeIntent(storage: Storage, key: string, intent: ResaleCreateIntent): void {\n storage.setItem(key, JSON.stringify(intent));\n const persisted = readResaleIntent(storage, key);\n if (persisted?.requestId !== intent.requestId || persisted.phase !== intent.phase) {\n throw new Error('The listing request could not be saved safely.');\n }\n}\n\n/** Call only while holding this scope's Web Lock. Preparation does not dispatch a mutation. */\nexport function prepareResaleIntent(storage: Storage, key: string): ResaleCreateIntent {\n const existing = readResaleIntent(storage, key);\n if (existing) return existing;\n const intent: ResaleCreateIntent = { requestId: crypto.randomUUID(), phase: 'prepared' };\n writeIntent(storage, key, intent);\n return intent;\n}\n\n/** A stale second tab must never silently allocate another intent or replay a dispatched one. */\nexport function dispatchResaleIntent(storage: Storage, key: string, requestId: string): void {\n const current = readResaleIntent(storage, key);\n if (current?.requestId !== requestId || current.phase !== 'prepared') {\n throw new Error(\n 'The listing request changed or was already dispatched. Resolve its status first.'\n );\n }\n writeIntent(storage, key, { requestId, phase: 'dispatched' });\n}\n\nexport function clearResaleIntent(storage: Storage, key: string, id: string): void {\n if (readResaleIntent(storage, key)?.requestId !== id) {\n throw new Error('The pending listing request changed. Refresh before continuing.');\n }\n storage.removeItem(key);\n if (storage.getItem(key) !== null) throw new Error('The listing request is still pending.');\n}\n"],"mappings":";AAAA,IAAM,IAAO;AAQb,SAAgB,EAAgB,GAAmC;CACjE,O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iB,GAAS,CAAG,CAAC,EAAE,cAAc,GAChD,MAAU,MAAM,iEAAiE;CAGnF,IADA,EAAQ,WAAW,CAAG,GAClB,EAAQ,QAAQ,CAAG,MAAM,MAAM,MAAU,MAAM,uCAAuC;AAC5F"}
@@ -1,5 +1,8 @@
1
1
  /** Resale prices are integer minor units, unlike the product's legacy major-unit prices. */
2
2
  export declare function formatResalePrice(minor: number, currency: string): string;
3
+ /** Delegate locale/precision handling to the existing integer-minor-unit input contract. */
4
+ export declare function parseResalePrice(text: string, currency: string, locale?: string): number;
5
+ export declare function resalePriceInput(minor: number, currency: string, locale?: string): string;
3
6
  export declare const RESALE_CATEGORIES: readonly ["TOPS", "BOTTOMS", "DRESSES", "OUTERWEAR", "FOOTWEAR", "BAGS", "ACCESSORIES", "JEWELLERY"];
4
7
  export declare const RESALE_CONDITIONS: readonly ["NEW_WITH_TAGS", "EXCELLENT", "GOOD", "FAIR"];
5
8
  //# sourceMappingURL=resalePresentation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resalePresentation.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/utils/resalePresentation.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAazE;AAED,eAAO,MAAM,iBAAiB,sGASpB,CAAC;AAEX,eAAO,MAAM,iBAAiB,yDAA0D,CAAC"}
1
+ {"version":3,"file":"resalePresentation.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/utils/resalePresentation.ts"],"names":[],"mappings":"AAEA,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAazE;AAED,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAMxF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAezF;AAED,eAAO,MAAM,iBAAiB,sGASpB,CAAC;AAEX,eAAO,MAAM,iBAAiB,yDAA0D,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { retailerTargetMinor as e } from "../components/prices/money.js";
1
2
  //#region src/coolandlovely/utils/resalePresentation.ts
2
- function e(e, t) {
3
+ function t(e, t) {
3
4
  if (!Number.isSafeInteger(e) || e < 0) return "Price unavailable";
4
5
  try {
5
6
  if (!Intl.supportedValuesOf("currency").includes(t)) return `${t} ${e} minor units`;
@@ -12,7 +13,25 @@ function e(e, t) {
12
13
  return `${t} ${e} minor units`;
13
14
  }
14
15
  }
15
- var t = [
16
+ function n(t, n, r) {
17
+ if (!Intl.supportedValuesOf("currency").includes(n)) throw Error("Choose a supported currency.");
18
+ if (t.length > 32) throw Error("The price is too long.");
19
+ return e(t, n, r);
20
+ }
21
+ function r(e, t, n) {
22
+ if (!Number.isSafeInteger(e) || e < 1 || !Intl.supportedValuesOf("currency").includes(t)) return "";
23
+ let r = new Intl.NumberFormat(n, {
24
+ style: "currency",
25
+ currency: t,
26
+ useGrouping: !1
27
+ }), i = r.resolvedOptions().maximumFractionDigits;
28
+ return i === void 0 ? "" : r.formatToParts(e / 10 ** i).filter((e) => [
29
+ "integer",
30
+ "decimal",
31
+ "fraction"
32
+ ].includes(e.type)).map((e) => e.value).join("");
33
+ }
34
+ var i = [
16
35
  "TOPS",
17
36
  "BOTTOMS",
18
37
  "DRESSES",
@@ -21,13 +40,13 @@ var t = [
21
40
  "BAGS",
22
41
  "ACCESSORIES",
23
42
  "JEWELLERY"
24
- ], n = [
43
+ ], a = [
25
44
  "NEW_WITH_TAGS",
26
45
  "EXCELLENT",
27
46
  "GOOD",
28
47
  "FAIR"
29
48
  ];
30
49
  //#endregion
31
- export { t as RESALE_CATEGORIES, n as RESALE_CONDITIONS, e as formatResalePrice };
50
+ export { i as RESALE_CATEGORIES, a as RESALE_CONDITIONS, t as formatResalePrice, n as parseResalePrice, r as resalePriceInput };
32
51
 
33
52
  //# sourceMappingURL=resalePresentation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resalePresentation.js","names":[],"sources":["../../../src/coolandlovely/utils/resalePresentation.ts"],"sourcesContent":["/** Resale prices are integer minor units, unlike the product's legacy major-unit prices. */\nexport function formatResalePrice(minor: number, currency: string): string {\n if (!Number.isSafeInteger(minor) || minor < 0) return 'Price unavailable';\n try {\n if (!Intl.supportedValuesOf('currency').includes(currency)) {\n return `${currency} ${minor} minor units`;\n }\n const format = new Intl.NumberFormat(undefined, { style: 'currency', currency });\n const digits = format.resolvedOptions().maximumFractionDigits;\n if (digits === undefined) return `${currency} ${minor} minor units`;\n return format.format(minor / 10 ** digits);\n } catch {\n return `${currency} ${minor} minor units`;\n }\n}\n\nexport const RESALE_CATEGORIES = [\n 'TOPS',\n 'BOTTOMS',\n 'DRESSES',\n 'OUTERWEAR',\n 'FOOTWEAR',\n 'BAGS',\n 'ACCESSORIES',\n 'JEWELLERY',\n] as const;\n\nexport const RESALE_CONDITIONS = ['NEW_WITH_TAGS', 'EXCELLENT', 'GOOD', 'FAIR'] as const;\n"],"mappings":";AACA,SAAgB,EAAkB,GAAe,GAA0B;CACzE,IAAI,CAAC,OAAO,cAAc,CAAK,KAAK,IAAQ,GAAG,OAAO;CACtD,IAAI;EACF,IAAI,CAAC,KAAK,kBAAkB,UAAU,CAAC,CAAC,SAAS,CAAQ,GACvD,OAAO,GAAG,EAAS,GAAG,EAAM;EAE9B,IAAM,IAAS,IAAI,KAAK,aAAa,KAAA,GAAW;GAAE,OAAO;GAAY;EAAS,CAAC,GACzE,IAAS,EAAO,gBAAgB,CAAC,CAAC;EAExC,OADI,MAAW,KAAA,IAAkB,GAAG,EAAS,GAAG,EAAM,gBAC/C,EAAO,OAAO,IAAQ,MAAM,CAAM;CAC3C,QAAQ;EACN,OAAO,GAAG,EAAS,GAAG,EAAM;CAC9B;AACF;AAEA,IAAa,IAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEa,IAAoB;CAAC;CAAiB;CAAa;CAAQ;AAAM"}
1
+ {"version":3,"file":"resalePresentation.js","names":[],"sources":["../../../src/coolandlovely/utils/resalePresentation.ts"],"sourcesContent":["import { retailerTargetMinor } from '../components/prices/money';\n\n/** Resale prices are integer minor units, unlike the product's legacy major-unit prices. */\nexport function formatResalePrice(minor: number, currency: string): string {\n if (!Number.isSafeInteger(minor) || minor < 0) return 'Price unavailable';\n try {\n if (!Intl.supportedValuesOf('currency').includes(currency)) {\n return `${currency} ${minor} minor units`;\n }\n const format = new Intl.NumberFormat(undefined, { style: 'currency', currency });\n const digits = format.resolvedOptions().maximumFractionDigits;\n if (digits === undefined) return `${currency} ${minor} minor units`;\n return format.format(minor / 10 ** digits);\n } catch {\n return `${currency} ${minor} minor units`;\n }\n}\n\n/** Delegate locale/precision handling to the existing integer-minor-unit input contract. */\nexport function parseResalePrice(text: string, currency: string, locale?: string): number {\n if (!Intl.supportedValuesOf('currency').includes(currency)) {\n throw new Error('Choose a supported currency.');\n }\n if (text.length > 32) throw new Error('The price is too long.');\n return retailerTargetMinor(text, currency, locale);\n}\n\nexport function resalePriceInput(minor: number, currency: string, locale?: string): string {\n if (!Number.isSafeInteger(minor) || minor < 1) return '';\n if (!Intl.supportedValuesOf('currency').includes(currency)) return '';\n const formatter = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n useGrouping: false,\n });\n const digits = formatter.resolvedOptions().maximumFractionDigits;\n if (digits === undefined) return '';\n return formatter\n .formatToParts(minor / 10 ** digits)\n .filter((part) => ['integer', 'decimal', 'fraction'].includes(part.type))\n .map((part) => part.value)\n .join('');\n}\n\nexport const RESALE_CATEGORIES = [\n 'TOPS',\n 'BOTTOMS',\n 'DRESSES',\n 'OUTERWEAR',\n 'FOOTWEAR',\n 'B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