@burdenoff/microfe-coolandlovely 2026.1109.6 → 2026.1109.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/coolandlovely/components/ResaleListingActions.d.ts +8 -0
- package/dist/coolandlovely/components/ResaleListingActions.d.ts.map +1 -0
- package/dist/coolandlovely/components/ResaleListingActions.js +132 -0
- package/dist/coolandlovely/components/ResaleListingActions.js.map +1 -0
- package/dist/coolandlovely/components/ResaleListingEditor.d.ts +7 -0
- package/dist/coolandlovely/components/ResaleListingEditor.d.ts.map +1 -0
- package/dist/coolandlovely/components/ResaleListingEditor.js +276 -0
- package/dist/coolandlovely/components/ResaleListingEditor.js.map +1 -0
- package/dist/coolandlovely/components/ResalePhotoPicker.d.ts +6 -0
- package/dist/coolandlovely/components/ResalePhotoPicker.d.ts.map +1 -0
- package/dist/coolandlovely/components/ResalePhotoPicker.js +150 -0
- package/dist/coolandlovely/components/ResalePhotoPicker.js.map +1 -0
- package/dist/coolandlovely/hooks/useResale.d.ts +178 -2
- package/dist/coolandlovely/hooks/useResale.d.ts.map +1 -1
- package/dist/coolandlovely/hooks/useResale.js +75 -42
- package/dist/coolandlovely/hooks/useResale.js.map +1 -1
- package/dist/coolandlovely/pages/resale/ResaleSellerPage.d.ts.map +1 -1
- package/dist/coolandlovely/pages/resale/ResaleSellerPage.js +130 -86
- package/dist/coolandlovely/pages/resale/ResaleSellerPage.js.map +1 -1
- package/dist/coolandlovely/utils/resaleCreateIntent.d.ts +13 -0
- package/dist/coolandlovely/utils/resaleCreateIntent.d.ts.map +1 -0
- package/dist/coolandlovely/utils/resaleCreateIntent.js +49 -0
- package/dist/coolandlovely/utils/resaleCreateIntent.js.map +1 -0
- package/dist/coolandlovely/utils/resalePresentation.d.ts +3 -0
- package/dist/coolandlovely/utils/resalePresentation.d.ts.map +1 -1
- package/dist/coolandlovely/utils/resalePresentation.js +23 -4
- package/dist/coolandlovely/utils/resalePresentation.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +70 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +41 -9
- package/dist/generated/wspace-operations.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -25,3 +25,33 @@ Backend acceptance lives in `coolandlovely-doctor` (`test-creator-marketplace.py
|
|
|
25
25
|
## License
|
|
26
26
|
|
|
27
27
|
Proprietary — Copyright Burdenoff Consultancy Services Pvt. Ltd.
|
|
28
|
+
|
|
29
|
+
## Resale seller listing editor
|
|
30
|
+
|
|
31
|
+
The seller surface edits private drafts with the current listing revision, submits them for review,
|
|
32
|
+
explicitly publishes unchanged approved drafts only after shop approval, and archives eligible listings
|
|
33
|
+
with confirmation. Editing clears previous moderation and publication. Reserved, sold and archived
|
|
34
|
+
listings are read-only. Publication and photo ownership remain authoritative backend checks.
|
|
35
|
+
|
|
36
|
+
The photo picker browses paginated Files folders and selects only the current seller's active PUBLIC
|
|
37
|
+
JPEG, PNG, WebP or AVIF assets in the current workspace with verified readable HTTPS public URLs.
|
|
38
|
+
It never changes visibility or substitutes private signed download URLs. Upload public photos through
|
|
39
|
+
Files before choosing them; direct upload from this editor remains unfinished.
|
|
40
|
+
|
|
41
|
+
Opening a new listing form prepares an opaque request UUID under the nonsecret captured context key
|
|
42
|
+
without dispatching a mutation. Save durably marks that same UUID dispatched before the network call.
|
|
43
|
+
An unsubmitted prepared intent can be reused; a dispatched intent requires authoritative resolution. Web Locks coordinate tabs, while server request idempotency and durable withdrawal
|
|
44
|
+
handle ambiguous outcomes. A failed response is never automatically replayed. Reopening the same
|
|
45
|
+
account/context exposes explicit recovery that returns the existing listing or withdraws an uncommitted
|
|
46
|
+
request before permitting a new intent. Storage or lock failures refuse creation. Existing-listing
|
|
47
|
+
updates and lifecycle transitions use optimistic revisions and require authoritative refresh after an
|
|
48
|
+
unconfirmed response. Prices use the existing locale-aware ungrouped decimal input contract and integer minor units without
|
|
49
|
+
rounding and reject unsupported currencies, excess precision and out-of-range amounts.
|
|
50
|
+
|
|
51
|
+
These seller controls do not implement checkout, payments, payouts, shipping, returns or operator
|
|
52
|
+
review interfaces. Source and synthetic browser tests are separate from deployed host acceptance.
|
|
53
|
+
|
|
54
|
+
An open listing editor retains its original revision and unsaved fields across background reads.
|
|
55
|
+
A different authoritative revision blocks Save until the editor is closed and reopened. Failed
|
|
56
|
+
lifecycle actions expose a read-only status refresh; only a successful fresh read resets their
|
|
57
|
+
local failure state. Neither a failed refresh nor a background refetch replays a mutation.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResaleOwnListing } from '../hooks/useResale';
|
|
2
|
+
export declare function ResaleListingActions({ listing, shopApproved, onRefresh, onEditingChange, }: {
|
|
3
|
+
listing: ResaleOwnListing;
|
|
4
|
+
shopApproved: boolean;
|
|
5
|
+
onRefresh(): Promise<boolean>;
|
|
6
|
+
onEditingChange?(id: string, editing: boolean): void;
|
|
7
|
+
}): import('react').JSX.Element;
|
|
8
|
+
//# sourceMappingURL=ResaleListingActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResaleListingActions.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/components/ResaleListingActions.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG9E,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,YAAY,EACZ,SAAS,EACT,eAAe,GAChB,EAAE;IACD,OAAO,EAAE,gBAAgB,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,eAAe,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACtD,+BAiKA"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useTr as e } from "../hooks/useTr.js";
|
|
2
|
+
import { CooResaleArchiveListingDocument as t, CooResalePublishListingDocument as n, CooResaleSubmitListingDocument as r } from "../../generated/wspace-operations.js";
|
|
3
|
+
import { useResaleMutation as i } from "../hooks/useResale.js";
|
|
4
|
+
import { ResaleListingEditor as a } from "./ResaleListingEditor.js";
|
|
5
|
+
import { useEffect as o, useState as s } from "react";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { Button as u } from "@burdenoff/fe-libs/ui";
|
|
8
|
+
//#region src/coolandlovely/components/ResaleListingActions.tsx
|
|
9
|
+
function d({ listing: d, shopApproved: f, onRefresh: p, onEditingChange: m }) {
|
|
10
|
+
let h = e(), [g, _] = s(null);
|
|
11
|
+
o(() => () => m?.(d.id, !1), [d.id, m]);
|
|
12
|
+
let [v, y] = s(!1), [b, x] = s(!1), [S, C] = s(!1), w = i(r), T = i(n), E = i(t), D = w.isPending || T.isPending || E.isPending || v, O = w.isError || T.isError || E.isError, k = [
|
|
13
|
+
"DRAFT",
|
|
14
|
+
"IN_REVIEW",
|
|
15
|
+
"PUBLISHED"
|
|
16
|
+
].includes(d.status);
|
|
17
|
+
if (g) return /* @__PURE__ */ c(a, {
|
|
18
|
+
listing: g,
|
|
19
|
+
changed: g.version !== d.version,
|
|
20
|
+
onClose: () => {
|
|
21
|
+
_(null), m?.(d.id, !1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
let A = async () => {
|
|
25
|
+
if (!D) {
|
|
26
|
+
y(!0);
|
|
27
|
+
try {
|
|
28
|
+
let e = await p();
|
|
29
|
+
x(!e), e && (w.reset(), T.reset(), E.reset(), C(!1));
|
|
30
|
+
} catch {
|
|
31
|
+
x(!0);
|
|
32
|
+
} finally {
|
|
33
|
+
y(!1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ l("div", {
|
|
38
|
+
className: "space-y-3",
|
|
39
|
+
children: [
|
|
40
|
+
O && /* @__PURE__ */ c("p", {
|
|
41
|
+
role: "alert",
|
|
42
|
+
className: "text-status-error-text",
|
|
43
|
+
children: h("coolandlovely.resale.editor.actionUnconfirmed", "The listing change was not confirmed. Refresh your listings to read its current status before another action.")
|
|
44
|
+
}),
|
|
45
|
+
O && /* @__PURE__ */ c(u, {
|
|
46
|
+
type: "button",
|
|
47
|
+
variant: "outline",
|
|
48
|
+
disabled: D,
|
|
49
|
+
onClick: () => {
|
|
50
|
+
A();
|
|
51
|
+
},
|
|
52
|
+
children: h("coolandlovely.resale.editor.refreshStatus", "Refresh listing status")
|
|
53
|
+
}),
|
|
54
|
+
b && /* @__PURE__ */ c("p", {
|
|
55
|
+
role: "alert",
|
|
56
|
+
className: "text-status-error-text",
|
|
57
|
+
children: h("coolandlovely.resale.editor.statusUnconfirmed", "The current listing status is still unconfirmed. No action was resubmitted.")
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ l("div", {
|
|
60
|
+
className: "flex flex-wrap gap-2",
|
|
61
|
+
children: [
|
|
62
|
+
k && /* @__PURE__ */ c(u, {
|
|
63
|
+
type: "button",
|
|
64
|
+
variant: "outline",
|
|
65
|
+
disabled: D || O,
|
|
66
|
+
onClick: () => {
|
|
67
|
+
_({
|
|
68
|
+
...d,
|
|
69
|
+
photoFileIds: [...d.photoFileIds]
|
|
70
|
+
}), m?.(d.id, !0);
|
|
71
|
+
},
|
|
72
|
+
children: h("coolandlovely.resale.editor.edit", "Edit draft details")
|
|
73
|
+
}),
|
|
74
|
+
d.status === "DRAFT" && d.moderationStatus !== "APPROVED" && /* @__PURE__ */ c(u, {
|
|
75
|
+
type: "button",
|
|
76
|
+
disabled: D || O,
|
|
77
|
+
onClick: () => w.mutate({
|
|
78
|
+
id: d.id,
|
|
79
|
+
version: d.version
|
|
80
|
+
}),
|
|
81
|
+
children: h("coolandlovely.resale.editor.submit", "Submit for review")
|
|
82
|
+
}),
|
|
83
|
+
d.status === "DRAFT" && d.moderationStatus === "APPROVED" && /* @__PURE__ */ c(u, {
|
|
84
|
+
type: "button",
|
|
85
|
+
disabled: D || O || !f,
|
|
86
|
+
onClick: () => T.mutate({
|
|
87
|
+
id: d.id,
|
|
88
|
+
version: d.version
|
|
89
|
+
}),
|
|
90
|
+
children: h("coolandlovely.resale.editor.publish", "Publish approved listing")
|
|
91
|
+
}),
|
|
92
|
+
k && /* @__PURE__ */ c(u, {
|
|
93
|
+
type: "button",
|
|
94
|
+
variant: "outline",
|
|
95
|
+
disabled: D || O,
|
|
96
|
+
onClick: () => C(!0),
|
|
97
|
+
children: h("coolandlovely.resale.editor.archive", "Archive listing")
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
}),
|
|
101
|
+
d.moderationStatus === "APPROVED" && !f && /* @__PURE__ */ c("p", {
|
|
102
|
+
className: "text-sm text-text-secondary",
|
|
103
|
+
children: h("coolandlovely.resale.editor.shopApprovalRequired", "Your shop must also be approved before publication.")
|
|
104
|
+
}),
|
|
105
|
+
S && /* @__PURE__ */ l("div", {
|
|
106
|
+
className: "space-y-2 rounded-lg border border-border-seam p-3",
|
|
107
|
+
children: [/* @__PURE__ */ c("p", { children: h("coolandlovely.resale.editor.archiveQuestion", "Archive this listing and remove it from the marketplace?") }), /* @__PURE__ */ l("div", {
|
|
108
|
+
className: "flex flex-wrap gap-2",
|
|
109
|
+
children: [/* @__PURE__ */ c(u, {
|
|
110
|
+
type: "button",
|
|
111
|
+
disabled: D || O,
|
|
112
|
+
onClick: () => E.mutate({
|
|
113
|
+
id: d.id,
|
|
114
|
+
version: d.version
|
|
115
|
+
}),
|
|
116
|
+
children: h("coolandlovely.resale.editor.confirmArchive", "Confirm archive")
|
|
117
|
+
}), /* @__PURE__ */ c(u, {
|
|
118
|
+
type: "button",
|
|
119
|
+
variant: "outline",
|
|
120
|
+
disabled: D,
|
|
121
|
+
onClick: () => C(!1),
|
|
122
|
+
children: h("coolandlovely.resale.editor.keepListing", "Keep listing")
|
|
123
|
+
})]
|
|
124
|
+
})]
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { d as ResaleListingActions };
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=ResaleListingActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResaleListingActions.js","names":[],"sources":["../../../src/coolandlovely/components/ResaleListingActions.tsx"],"sourcesContent":["import { useTr } from '../hooks/useTr';\nimport { useEffect, useState } from 'react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport {\n CooResaleSubmitListingDocument,\n CooResalePublishListingDocument,\n CooResaleArchiveListingDocument,\n type CooResaleSubmitListingMutation,\n type CooResaleSubmitListingMutationVariables,\n type CooResalePublishListingMutation,\n type CooResalePublishListingMutationVariables,\n type CooResaleArchiveListingMutation,\n type CooResaleArchiveListingMutationVariables,\n} from '../../generated/wspace-operations';\nimport { useResaleMutation, type ResaleOwnListing } from '../hooks/useResale';\nimport { ResaleListingEditor } from './ResaleListingEditor';\n\nexport function ResaleListingActions({\n listing,\n shopApproved,\n onRefresh,\n onEditingChange,\n}: {\n listing: ResaleOwnListing;\n shopApproved: boolean;\n onRefresh(): Promise<boolean>;\n onEditingChange?(id: string, editing: boolean): void;\n}) {\n const tr = useTr();\n const [editing, setEditing] = useState<ResaleOwnListing | null>(null);\n useEffect(() => () => onEditingChange?.(listing.id, false), [listing.id, onEditingChange]);\n const [refreshing, setRefreshing] = useState(false);\n const [readFailed, setReadFailed] = useState(false);\n const [archiveConfirm, setArchiveConfirm] = useState(false);\n const submit = useResaleMutation<\n CooResaleSubmitListingMutation,\n CooResaleSubmitListingMutationVariables\n >(CooResaleSubmitListingDocument);\n const publish = useResaleMutation<\n CooResalePublishListingMutation,\n CooResalePublishListingMutationVariables\n >(CooResalePublishListingDocument);\n const archive = useResaleMutation<\n CooResaleArchiveListingMutation,\n CooResaleArchiveListingMutationVariables\n >(CooResaleArchiveListingDocument);\n const busy = submit.isPending || publish.isPending || archive.isPending || refreshing;\n const failed = submit.isError || publish.isError || archive.isError;\n const editable = ['DRAFT', 'IN_REVIEW', 'PUBLISHED'].includes(listing.status);\n if (editing)\n return (\n <ResaleListingEditor\n listing={editing}\n changed={editing.version !== listing.version}\n onClose={() => {\n setEditing(null);\n onEditingChange?.(listing.id, false);\n }}\n />\n );\n const refresh = async () => {\n if (busy) return;\n setRefreshing(true);\n try {\n const confirmed = await onRefresh();\n setReadFailed(!confirmed);\n if (confirmed) {\n submit.reset();\n publish.reset();\n archive.reset();\n setArchiveConfirm(false);\n }\n } catch {\n setReadFailed(true);\n } finally {\n setRefreshing(false);\n }\n };\n return (\n <div className=\"space-y-3\">\n {failed && (\n <p role=\"alert\" className=\"text-status-error-text\">\n {tr(\n 'coolandlovely.resale.editor.actionUnconfirmed',\n 'The listing change was not confirmed. Refresh your listings to read its current status before another action.'\n )}\n </p>\n )}\n {failed && (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={busy}\n onClick={() => {\n void refresh();\n }}\n >\n {tr('coolandlovely.resale.editor.refreshStatus', 'Refresh listing status')}\n </Button>\n )}\n {readFailed && (\n <p role=\"alert\" className=\"text-status-error-text\">\n {tr(\n 'coolandlovely.resale.editor.statusUnconfirmed',\n 'The current listing status is still unconfirmed. No action was resubmitted.'\n )}\n </p>\n )}\n <div className=\"flex flex-wrap gap-2\">\n {editable && (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={busy || failed}\n onClick={() => {\n setEditing({ ...listing, photoFileIds: [...listing.photoFileIds] });\n onEditingChange?.(listing.id, true);\n }}\n >\n {tr('coolandlovely.resale.editor.edit', 'Edit draft details')}\n </Button>\n )}\n {listing.status === 'DRAFT' && listing.moderationStatus !== 'APPROVED' && (\n <Button\n type=\"button\"\n disabled={busy || failed}\n onClick={() => submit.mutate({ id: listing.id, version: listing.version })}\n >\n {tr('coolandlovely.resale.editor.submit', 'Submit for review')}\n </Button>\n )}\n {listing.status === 'DRAFT' && listing.moderationStatus === 'APPROVED' && (\n <Button\n type=\"button\"\n disabled={busy || failed || !shopApproved}\n onClick={() => publish.mutate({ id: listing.id, version: listing.version })}\n >\n {tr('coolandlovely.resale.editor.publish', 'Publish approved listing')}\n </Button>\n )}\n {editable && (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={busy || failed}\n onClick={() => setArchiveConfirm(true)}\n >\n {tr('coolandlovely.resale.editor.archive', 'Archive listing')}\n </Button>\n )}\n </div>\n {listing.moderationStatus === 'APPROVED' && !shopApproved && (\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'coolandlovely.resale.editor.shopApprovalRequired',\n 'Your shop must also be approved before publication.'\n )}\n </p>\n )}\n {archiveConfirm && (\n <div className=\"space-y-2 rounded-lg border border-border-seam p-3\">\n <p>\n {tr(\n 'coolandlovely.resale.editor.archiveQuestion',\n 'Archive this listing and remove it from the marketplace?'\n )}\n </p>\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n disabled={busy || failed}\n onClick={() => archive.mutate({ id: listing.id, version: listing.version })}\n >\n {tr('coolandlovely.resale.editor.confirmArchive', 'Confirm archive')}\n </Button>\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={busy}\n onClick={() => setArchiveConfirm(false)}\n >\n {tr('coolandlovely.resale.editor.keepListing', 'Keep listing')}\n </Button>\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAiBA,SAAgB,EAAqB,EACnC,YACA,iBACA,cACA,sBAMC;CACD,IAAM,IAAK,EAAM,GACX,CAAC,GAAS,KAAc,EAAkC,IAAI;CACpE,cAAsB,IAAkB,EAAQ,IAAI,EAAK,GAAG,CAAC,EAAQ,IAAI,CAAe,CAAC;CACzF,IAAM,CAAC,GAAY,KAAiB,EAAS,EAAK,GAC5C,CAAC,GAAY,KAAiB,EAAS,EAAK,GAC5C,CAAC,GAAgB,KAAqB,EAAS,EAAK,GACpD,IAAS,EAGb,CAA8B,GAC1B,IAAU,EAGd,CAA+B,GAC3B,I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WAAW,WAAW,EAAQ,qBAAqB,cAC1D,kBAAC,GAAD;MACE,MAAK;MACL,UAAU,KAAQ;MAClB,eAAe,EAAO,OAAO;OAAE,IAAI,EAAQ;OAAI,SAAS,EAAQ;MAAQ,CAAC;gBAExE,EAAG,sCAAsC,mBAAmB;KACvD,CAAA;KAET,EAAQ,WAAW,WAAW,EAAQ,qBAAqB,cAC1D,kBAAC,GAAD;MACE,MAAK;MACL,UAAU,KAAQ,KAAU,CAAC;MAC7B,eAAe,EAAQ,OAAO;OAAE,IAAI,EAAQ;OAAI,SAAS,EAAQ;MAAQ,CAAC;gBAEzE,EAAG,uCAAuC,0BAA0B;KAC/D,CAAA;KAET,KACC,kBAAC,GAAD;MACE,MAAK;MACL,SAAQ;MACR,UAAU,KAAQ;MAClB,eAAe,EAAkB,EAAI;gBAEpC,EAAG,uCAAuC,iBAAiB;KACtD,CAAA;IAEP;;GACJ,EAAQ,qBAAqB,cAAc,CAAC,KAC3C,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,oDACA,qDACF;GACC,CAAA;GAEJ,KACC,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,KAAD,EAAA,UACG,EACC,+CACA,0DACF,EACC,CAAA,GACH,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,GAAD;MACE,MAAK;MACL,UAAU,KAAQ;MAClB,eAAe,EAAQ,OAAO;OAAE,IAAI,EAAQ;OAAI,SAAS,EAAQ;MAAQ,CAAC;gBAEzE,EAAG,8CAA8C,iBAAiB;KAC7D,CAAA,GACR,kBAAC,GAAD;MACE,MAAK;MACL,SAAQ;MACR,UAAU;MACV,eAAe,EAAkB,EAAK;gBAErC,EAAG,2CAA2C,cAAc;KACvD,CAAA,CACL;MACF;;EAEJ;;AAET"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ResaleOwnListing } from '../hooks/useResale';
|
|
2
|
+
export declare function ResaleListingEditor({ listing, onClose, changed, }: {
|
|
3
|
+
listing?: ResaleOwnListing;
|
|
4
|
+
onClose(): void;
|
|
5
|
+
changed?: boolean;
|
|
6
|
+
}): import('react').JSX.Element;
|
|
7
|
+
//# sourceMappingURL=ResaleListingEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResaleListingEditor.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/components/ResaleListingEditor.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAsC,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAoB/F,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,OAAO,EACP,OAAe,GAChB,EAAE;IACD,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,OAAO,IAAI,IAAI,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,+BA0VA"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { useTr as e } from "../hooks/useTr.js";
|
|
2
|
+
import { CooResaleResolveCreateRequestDocument as t, CooResaleSaveListingDocument as n } from "../../generated/wspace-operations.js";
|
|
3
|
+
import { useResaleClient as ee, useResaleMutation as r } from "../hooks/useResale.js";
|
|
4
|
+
import { RESALE_CATEGORIES as i, RESALE_CONDITIONS as a, parseResalePrice as o, resalePriceInput as s } from "../utils/resalePresentation.js";
|
|
5
|
+
import { clearResaleIntent as c, dispatchResaleIntent as l, prepareResaleIntent as u, readResaleIntent as d, resaleIntentKey as f } from "../utils/resaleCreateIntent.js";
|
|
6
|
+
import { ResalePhotoPicker as te } from "./ResalePhotoPicker.js";
|
|
7
|
+
import { useEffect as ne, useRef as re, useState as p } from "react";
|
|
8
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
9
|
+
import { Button as g } from "@burdenoff/fe-libs/ui";
|
|
10
|
+
//#region src/coolandlovely/components/ResaleListingEditor.tsx
|
|
11
|
+
var _ = "w-full rounded-lg border border-border-seam bg-bg-surface px-3 py-2 text-text-primary";
|
|
12
|
+
function v({ listing: v, onClose: y, changed: b = !1 }) {
|
|
13
|
+
let x = e(), { key: S } = ee(), C = f(S), [w, T] = p(v?.title ?? ""), [E, D] = p(v?.description ?? ""), [O, k] = p(v?.size ?? ""), [A, j] = p(v?.category ?? "TOPS"), [M, N] = p(v?.condition ?? "GOOD"), [P, F] = p(v?.currency ?? "USD"), [I, L] = p(v ? s(v.priceMinor, v.currency) : ""), [R, z] = p(v?.photoFileIds ?? []), [B, V] = p(null), [H, U] = p(!1), W = re(!1), [G, K] = p(!1), [q, J] = p(null), [Y, ie] = p(!v), X = q?.phase === "dispatched", Z = v?.id;
|
|
14
|
+
ne(() => {
|
|
15
|
+
if (Z) return;
|
|
16
|
+
let e = new AbortController(), t = !0;
|
|
17
|
+
return (async () => {
|
|
18
|
+
try {
|
|
19
|
+
if (!navigator.locks) throw Error("Safe request coordination is unavailable.");
|
|
20
|
+
await navigator.locks.request(C, { signal: e.signal }, () => {
|
|
21
|
+
t && J(u(localStorage, C));
|
|
22
|
+
});
|
|
23
|
+
} catch {
|
|
24
|
+
t && (K(!0), V({
|
|
25
|
+
key: "coolandlovely.resale.editor.prepareFailed",
|
|
26
|
+
fallback: "The listing request could not be prepared safely. Close this form before trying again."
|
|
27
|
+
}));
|
|
28
|
+
} finally {
|
|
29
|
+
t && ie(!1);
|
|
30
|
+
}
|
|
31
|
+
})(), () => {
|
|
32
|
+
t = !1, e.abort();
|
|
33
|
+
};
|
|
34
|
+
}, [C, Z]);
|
|
35
|
+
let Q = r(n), ae = r(t), $ = async (e) => {
|
|
36
|
+
if (!navigator.locks) throw Error("This browser cannot safely coordinate listing requests. Use a browser with Web Locks support.");
|
|
37
|
+
await navigator.locks.request(C, { ifAvailable: !0 }, async (t) => {
|
|
38
|
+
if (!t) throw Error("Another tab is processing this listing request.");
|
|
39
|
+
await e();
|
|
40
|
+
});
|
|
41
|
+
}, oe = async (e) => {
|
|
42
|
+
if (e.preventDefault(), W.current || H || Y || G || X || b) return;
|
|
43
|
+
let t;
|
|
44
|
+
try {
|
|
45
|
+
if (t = o(I, P), !w.trim() || !E.trim() || !O.trim() || R.length < 1 || R.length > 10) throw Error("Enter all listing details and choose between one and ten photos.");
|
|
46
|
+
} catch (e) {
|
|
47
|
+
V({
|
|
48
|
+
key: "coolandlovely.resale.editor.invalidListing",
|
|
49
|
+
fallback: e instanceof Error ? e.message : "Check listing details."
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let n = {
|
|
54
|
+
title: w.trim(),
|
|
55
|
+
description: E.trim(),
|
|
56
|
+
size: O.trim(),
|
|
57
|
+
category: A,
|
|
58
|
+
condition: M,
|
|
59
|
+
currency: P,
|
|
60
|
+
priceMinor: t,
|
|
61
|
+
photoFileIds: R
|
|
62
|
+
};
|
|
63
|
+
U(!0), W.current = !0, V(null);
|
|
64
|
+
try {
|
|
65
|
+
v ? await Q.mutateAsync({
|
|
66
|
+
input: n,
|
|
67
|
+
id: v.id,
|
|
68
|
+
version: v.version
|
|
69
|
+
}) : await $(async () => {
|
|
70
|
+
if (!q) throw Error("The prepared listing request is missing.");
|
|
71
|
+
let e = q.requestId;
|
|
72
|
+
if (l(localStorage, C, e), J({
|
|
73
|
+
requestId: e,
|
|
74
|
+
phase: "dispatched"
|
|
75
|
+
}), !(await Q.mutateAsync({
|
|
76
|
+
input: n,
|
|
77
|
+
requestId: e
|
|
78
|
+
})).cooSaveResaleListing.id) throw Error("Listing result is missing.");
|
|
79
|
+
c(localStorage, C, e), J(null);
|
|
80
|
+
}), y();
|
|
81
|
+
} catch {
|
|
82
|
+
K(!0);
|
|
83
|
+
let e = null;
|
|
84
|
+
if (!v) try {
|
|
85
|
+
e = d(localStorage, C), J(e);
|
|
86
|
+
} catch {
|
|
87
|
+
K(!0);
|
|
88
|
+
}
|
|
89
|
+
V(v ? {
|
|
90
|
+
key: "coolandlovely.resale.editor.editUnconfirmed",
|
|
91
|
+
fallback: "The save was not confirmed. Close this editor and refresh the listing before editing again."
|
|
92
|
+
} : e?.phase === "dispatched" ? {
|
|
93
|
+
key: "coolandlovely.resale.editor.createUnconfirmed",
|
|
94
|
+
fallback: "The save was not confirmed. Do not submit again. Resolve the pending request below before creating another listing."
|
|
95
|
+
} : {
|
|
96
|
+
key: "coolandlovely.resale.editor.setupUnconfirmed",
|
|
97
|
+
fallback: "The save was not confirmed. Close this form and refresh the current listings before starting another request."
|
|
98
|
+
});
|
|
99
|
+
} finally {
|
|
100
|
+
U(!1), W.current = !1;
|
|
101
|
+
}
|
|
102
|
+
}, se = async () => {
|
|
103
|
+
if (!(W.current || H)) {
|
|
104
|
+
W.current = !0, U(!0);
|
|
105
|
+
try {
|
|
106
|
+
await $(async () => {
|
|
107
|
+
let e = d(localStorage, C);
|
|
108
|
+
if (!e) {
|
|
109
|
+
J(null), y();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
let t = e.requestId, n = (await ae.mutateAsync({ requestId: t })).cooResolveResaleCreateRequest;
|
|
113
|
+
if (!n.listing?.id && !n.withdrawn) throw Error("Request resolution is incomplete.");
|
|
114
|
+
c(localStorage, C, t), J(null), y();
|
|
115
|
+
});
|
|
116
|
+
} catch {
|
|
117
|
+
V({
|
|
118
|
+
key: "coolandlovely.resale.editor.resolveUnconfirmed",
|
|
119
|
+
fallback: "The pending request is still unresolved. Keep this account and workspace selected, then try resolving its status again. No listing was resubmitted."
|
|
120
|
+
});
|
|
121
|
+
} finally {
|
|
122
|
+
U(!1), W.current = !1;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
return /* @__PURE__ */ h("form", {
|
|
127
|
+
"data-resale-request-id": v ? void 0 : q?.requestId,
|
|
128
|
+
"data-resale-request-phase": v ? void 0 : q?.phase,
|
|
129
|
+
onSubmit: (e) => {
|
|
130
|
+
oe(e);
|
|
131
|
+
},
|
|
132
|
+
"aria-label": v ? x("coolandlovely.resale.editor.editLabel", "Edit resale listing") : x("coolandlovely.resale.editor.createLabel", "Create resale listing"),
|
|
133
|
+
className: "space-y-4",
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ m("p", {
|
|
136
|
+
className: "text-sm text-text-secondary",
|
|
137
|
+
children: x("coolandlovely.resale.editor.draftNotice", "Saving creates a private draft and clears any previous review and publication. Submit the draft for review separately.")
|
|
138
|
+
}),
|
|
139
|
+
b && !H && /* @__PURE__ */ m("p", {
|
|
140
|
+
role: "alert",
|
|
141
|
+
className: "text-status-error-text",
|
|
142
|
+
children: x("coolandlovely.resale.editor.changed", "This listing changed while the editor was open. Your unsaved fields are preserved. Close this editor and refresh its current status before editing again.")
|
|
143
|
+
}),
|
|
144
|
+
Y && /* @__PURE__ */ m("p", {
|
|
145
|
+
role: "status",
|
|
146
|
+
children: x("coolandlovely.resale.editor.preparing", "Preparing the listing form…")
|
|
147
|
+
}),
|
|
148
|
+
/* @__PURE__ */ h("fieldset", {
|
|
149
|
+
disabled: H || Y || G || X,
|
|
150
|
+
className: "space-y-4",
|
|
151
|
+
children: [
|
|
152
|
+
/* @__PURE__ */ h("label", {
|
|
153
|
+
className: "grid gap-1",
|
|
154
|
+
children: [x("coolandlovely.resale.editor.title", "Title"), /* @__PURE__ */ m("input", {
|
|
155
|
+
className: _,
|
|
156
|
+
required: !0,
|
|
157
|
+
maxLength: 255,
|
|
158
|
+
value: w,
|
|
159
|
+
onChange: (e) => T(e.target.value)
|
|
160
|
+
})]
|
|
161
|
+
}),
|
|
162
|
+
/* @__PURE__ */ h("label", {
|
|
163
|
+
className: "grid gap-1",
|
|
164
|
+
children: [x("coolandlovely.resale.editor.description", "Description"), /* @__PURE__ */ m("textarea", {
|
|
165
|
+
className: `${_} min-h-28`,
|
|
166
|
+
required: !0,
|
|
167
|
+
maxLength: 4e3,
|
|
168
|
+
value: E,
|
|
169
|
+
onChange: (e) => D(e.target.value)
|
|
170
|
+
})]
|
|
171
|
+
}),
|
|
172
|
+
/* @__PURE__ */ h("div", {
|
|
173
|
+
className: "grid gap-4 sm:grid-cols-2",
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ h("label", {
|
|
176
|
+
className: "grid gap-1",
|
|
177
|
+
children: [x("coolandlovely.resale.editor.category", "Category"), /* @__PURE__ */ m("select", {
|
|
178
|
+
className: _,
|
|
179
|
+
value: A,
|
|
180
|
+
onChange: (e) => j(e.target.value),
|
|
181
|
+
children: i.map((e) => /* @__PURE__ */ m("option", {
|
|
182
|
+
value: e,
|
|
183
|
+
children: e.replaceAll("_", " ")
|
|
184
|
+
}, e))
|
|
185
|
+
})]
|
|
186
|
+
}),
|
|
187
|
+
/* @__PURE__ */ h("label", {
|
|
188
|
+
className: "grid gap-1",
|
|
189
|
+
children: [x("coolandlovely.resale.editor.condition", "Condition"), /* @__PURE__ */ m("select", {
|
|
190
|
+
className: _,
|
|
191
|
+
value: M,
|
|
192
|
+
onChange: (e) => N(e.target.value),
|
|
193
|
+
children: a.map((e) => /* @__PURE__ */ m("option", {
|
|
194
|
+
value: e,
|
|
195
|
+
children: e.replaceAll("_", " ")
|
|
196
|
+
}, e))
|
|
197
|
+
})]
|
|
198
|
+
}),
|
|
199
|
+
/* @__PURE__ */ h("label", {
|
|
200
|
+
className: "grid gap-1",
|
|
201
|
+
children: [x("coolandlovely.resale.editor.size", "Size"), /* @__PURE__ */ m("input", {
|
|
202
|
+
className: _,
|
|
203
|
+
required: !0,
|
|
204
|
+
maxLength: 80,
|
|
205
|
+
value: O,
|
|
206
|
+
onChange: (e) => k(e.target.value)
|
|
207
|
+
})]
|
|
208
|
+
}),
|
|
209
|
+
/* @__PURE__ */ h("label", {
|
|
210
|
+
className: "grid gap-1",
|
|
211
|
+
children: [x("coolandlovely.resale.editor.currency", "Currency"), /* @__PURE__ */ m("select", {
|
|
212
|
+
className: _,
|
|
213
|
+
value: P,
|
|
214
|
+
onChange: (e) => F(e.target.value),
|
|
215
|
+
children: Intl.supportedValuesOf("currency").map((e) => /* @__PURE__ */ m("option", { children: e }, e))
|
|
216
|
+
})]
|
|
217
|
+
}),
|
|
218
|
+
/* @__PURE__ */ h("label", {
|
|
219
|
+
className: "grid gap-1",
|
|
220
|
+
children: [x("coolandlovely.resale.editor.price", "Price"), /* @__PURE__ */ m("input", {
|
|
221
|
+
className: _,
|
|
222
|
+
required: !0,
|
|
223
|
+
inputMode: "decimal",
|
|
224
|
+
maxLength: 32,
|
|
225
|
+
value: I,
|
|
226
|
+
onChange: (e) => L(e.target.value)
|
|
227
|
+
})]
|
|
228
|
+
})
|
|
229
|
+
]
|
|
230
|
+
}),
|
|
231
|
+
/* @__PURE__ */ m(te, {
|
|
232
|
+
selected: R,
|
|
233
|
+
onChange: z,
|
|
234
|
+
disabled: H || Y || G || X
|
|
235
|
+
})
|
|
236
|
+
]
|
|
237
|
+
}),
|
|
238
|
+
X && /* @__PURE__ */ h("div", {
|
|
239
|
+
role: "status",
|
|
240
|
+
className: "space-y-2 rounded-lg border border-border-seam p-3",
|
|
241
|
+
children: [/* @__PURE__ */ m("p", { children: x("coolandlovely.resale.editor.pendingNotice", "A listing request remains pending for this account and context. Resolve it to recover its saved listing or permanently withdraw an uncommitted create. This never submits another listing.") }), /* @__PURE__ */ m(g, {
|
|
242
|
+
type: "button",
|
|
243
|
+
variant: "outline",
|
|
244
|
+
disabled: H,
|
|
245
|
+
onClick: () => {
|
|
246
|
+
se();
|
|
247
|
+
},
|
|
248
|
+
children: x("coolandlovely.resale.editor.resolvePending", "Resolve pending listing request")
|
|
249
|
+
})]
|
|
250
|
+
}),
|
|
251
|
+
B && /* @__PURE__ */ m("p", {
|
|
252
|
+
role: "alert",
|
|
253
|
+
className: "text-status-error-text",
|
|
254
|
+
children: x(B.key, B.fallback)
|
|
255
|
+
}),
|
|
256
|
+
/* @__PURE__ */ h("div", {
|
|
257
|
+
className: "flex flex-wrap gap-2",
|
|
258
|
+
children: [/* @__PURE__ */ m(g, {
|
|
259
|
+
type: "submit",
|
|
260
|
+
disabled: H || Y || G || X || b,
|
|
261
|
+
children: x("coolandlovely.resale.editor.saveDraft", "Save private draft")
|
|
262
|
+
}), /* @__PURE__ */ m(g, {
|
|
263
|
+
type: "button",
|
|
264
|
+
variant: "outline",
|
|
265
|
+
disabled: H,
|
|
266
|
+
onClick: y,
|
|
267
|
+
children: x("coolandlovely.resale.editor.close", "Close")
|
|
268
|
+
})]
|
|
269
|
+
})
|
|
270
|
+
]
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
export { v as ResaleListingEditor };
|
|
275
|
+
|
|
276
|
+
//# sourceMappingURL=ResaleListingEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResaleListingEditor.js","names":[],"sources":["../../../src/coolandlovely/components/ResaleListingEditor.tsx"],"sourcesContent":["import { useTr } from '../hooks/useTr';\nimport { useEffect, useRef, useState, type FormEvent } from 'react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport {\n CooResaleSaveListingDocument,\n CooResaleResolveCreateRequestDocument,\n type CooResaleSaveListingMutation,\n type CooResaleSaveListingMutationVariables,\n type CooResaleResolveCreateRequestMutation,\n type CooResaleResolveCreateRequestMutationVariables,\n} from '../../generated/wspace-operations';\nimport { useResaleClient, useResaleMutation, type ResaleOwnListing } from '../hooks/useResale';\nimport {\n RESALE_CATEGORIES,\n RESALE_CONDITIONS,\n parseResalePrice,\n resalePriceInput,\n} from '../utils/resalePresentation';\nimport {\n prepareResaleIntent,\n dispatchResaleIntent,\n type ResaleCreateIntent,\n clearResaleIntent,\n readResaleIntent,\n resaleIntentKey,\n} from '../utils/resaleCreateIntent';\nimport { ResalePhotoPicker } from './ResalePhotoPicker';\n\nconst control =\n 'w-full rounded-lg border border-border-seam bg-bg-surface px-3 py-2 text-text-primary';\n\nexport function ResaleListingEditor({\n listing,\n onClose,\n changed = false,\n}: {\n listing?: ResaleOwnListing;\n onClose(): void;\n changed?: boolean;\n}) {\n const tr = useTr();\n const { key } = useResaleClient();\n const intentKey = resaleIntentKey(key);\n const [title, setTitle] = useState(listing?.title ?? '');\n const [description, setDescription] = useState(listing?.description ?? '');\n const [size, setSize] = useState(listing?.size ?? '');\n const [category, setCategory] = useState(listing?.category ?? 'TOPS');\n const [condition, setCondition] = useState(listing?.condition ?? 'GOOD');\n const [currency, setCurrency] = useState(listing?.currency ?? 'USD');\n const [price, setPrice] = useState(\n listing ? resalePriceInput(listing.priceMinor, listing.currency) : ''\n );\n const [photos, setPhotos] = useState(listing?.photoFileIds ?? []);\n const [message, setMessage] = useState<{ key: string; fallback: string } | null>(null);\n const [busy, setBusy] = useState(false);\n const dispatched = useRef(false);\n const [blocked, setBlocked] = useState(false);\n const [intent, setIntent] = useState<ResaleCreateIntent | null>(null);\n const [preparing, setPreparing] = useState(!listing);\n const pending = intent?.phase === 'dispatched';\n const listingId = listing?.id;\n useEffect(() => {\n if (listingId) return;\n const controller = new AbortController();\n let active = true;\n const prepare = async () => {\n try {\n if (!navigator.locks) throw new Error('Safe request coordination is unavailable.');\n await navigator.locks.request(intentKey, { signal: controller.signal }, () => {\n if (active) setIntent(prepareResaleIntent(localStorage, intentKey));\n });\n } catch {\n if (active) {\n setBlocked(true);\n setMessage({\n key: 'coolandlovely.resale.editor.prepareFailed',\n fallback:\n 'The listing request could not be prepared safely. Close this form before trying again.',\n });\n }\n } finally {\n if (active) setPreparing(false);\n }\n };\n void prepare();\n return () => {\n active = false;\n controller.abort();\n };\n }, [intentKey, listingId]);\n const save = useResaleMutation<\n CooResaleSaveListingMutation,\n CooResaleSaveListingMutationVariables\n >(CooResaleSaveListingDocument);\n const recover = useResaleMutation<\n CooResaleResolveCreateRequestMutation,\n CooResaleResolveCreateRequestMutationVariables\n >(CooResaleResolveCreateRequestDocument);\n const locked = async (action: () => Promise<void>) => {\n if (!navigator.locks)\n throw new Error(\n 'This browser cannot safely coordinate listing requests. Use a browser with Web Locks support.'\n );\n // Serialize all tabs for this scope. The opaque durable intent remains if response/context is lost.\n await navigator.locks.request(intentKey, { ifAvailable: true }, async (lock) => {\n if (!lock) throw new Error('Another tab is processing this listing request.');\n await action();\n });\n };\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n if (dispatched.current || busy || preparing || blocked || pending || changed) return;\n let priceMinor: number;\n try {\n priceMinor = parseResalePrice(price, currency);\n if (\n !title.trim() ||\n !description.trim() ||\n !size.trim() ||\n photos.length < 1 ||\n photos.length > 10\n )\n throw new Error('Enter all listing details and choose between one and ten photos.');\n } catch (error) {\n setMessage({\n key: 'coolandlovely.resale.editor.invalidListing',\n fallback: error instanceof Error ? error.message : 'Check listing details.',\n });\n return;\n }\n const input = {\n title: title.trim(),\n description: description.trim(),\n size: size.trim(),\n category,\n condition,\n currency,\n priceMinor,\n photoFileIds: photos,\n };\n setBusy(true);\n dispatched.current = true;\n setMessage(null);\n try {\n if (listing) {\n await save.mutateAsync({ input, id: listing.id, version: listing.version });\n } else {\n await locked(async () => {\n if (!intent) throw new Error('The prepared listing request is missing.');\n const requestId = intent.requestId;\n dispatchResaleIntent(localStorage, intentKey, requestId);\n setIntent({ requestId, phase: 'dispatched' });\n const result = await save.mutateAsync({ input, requestId });\n if (!result.cooSaveResaleListing.id) throw new Error('Listing result is missing.');\n clearResaleIntent(localStorage, intentKey, requestId);\n // This records durable resolution, not a loading flag: failures must keep it pending.\n setIntent(null);\n });\n }\n onClose();\n } catch {\n setBlocked(true);\n let current: ResaleCreateIntent | null = null;\n if (!listing) {\n try {\n current = readResaleIntent(localStorage, intentKey);\n setIntent(current);\n } catch {\n setBlocked(true);\n }\n }\n setMessage(\n listing\n ? {\n key: 'coolandlovely.resale.editor.editUnconfirmed',\n fallback:\n 'The save was not confirmed. Close this editor and refresh the listing before editing again.',\n }\n : current?.phase === 'dispatched'\n ? {\n key: 'coolandlovely.resale.editor.createUnconfirmed',\n fallback:\n 'The save was not confirmed. Do not submit again. Resolve the pending request below before creating another listing.',\n }\n : {\n key: 'coolandlovely.resale.editor.setupUnconfirmed',\n fallback:\n 'The save was not confirmed. Close this form and refresh the current listings before starting another request.',\n }\n );\n } finally {\n setBusy(false);\n dispatched.current = false;\n }\n };\n const resolve = async () => {\n if (dispatched.current || busy) return;\n dispatched.current = true;\n setBusy(true);\n try {\n await locked(async () => {\n const current = readResaleIntent(localStorage, intentKey);\n if (!current) {\n setIntent(null);\n onClose();\n return;\n }\n const requestId = current.requestId;\n const result = await recover.mutateAsync({ requestId });\n const resolution = result.cooResolveResaleCreateRequest;\n if (!resolution.listing?.id && !resolution.withdrawn)\n throw new Error('Request resolution is incomplete.');\n clearResaleIntent(localStorage, intentKey, requestId);\n setIntent(null);\n onClose();\n });\n } catch {\n setMessage({\n key: 'coolandlovely.resale.editor.resolveUnconfirmed',\n fallback:\n 'The pending request is still unresolved. Keep this account and workspace selected, then try resolving its status again. No listing was resubmitted.',\n });\n } finally {\n setBusy(false);\n dispatched.current = false;\n }\n };\n return (\n <form\n data-resale-request-id={listing ? undefined : intent?.requestId}\n data-resale-request-phase={listing ? undefined : intent?.phase}\n onSubmit={(event) => {\n void submit(event);\n }}\n aria-label={\n listing\n ? tr('coolandlovely.resale.editor.editLabel', 'Edit resale listing')\n : tr('coolandlovely.resale.editor.createLabel', 'Create resale listing')\n }\n className=\"space-y-4\"\n >\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'coolandlovely.resale.editor.draftNotice',\n 'Saving creates a private draft and clears any previous review and publication. Submit the draft for review separately.'\n )}\n </p>\n {changed && !busy && (\n <p role=\"alert\" className=\"text-status-error-text\">\n {tr(\n 'coolandlovely.resale.editor.changed',\n 'This listing changed while the editor was open. Your unsaved fields are preserved. Close this editor and refresh its current status before editing again.'\n )}\n </p>\n )}\n {preparing && (\n <p role=\"status\">\n {tr('coolandlovely.resale.editor.preparing', 'Preparing the listing form…')}\n </p>\n )}\n <fieldset disabled={busy || preparing || blocked || pending} className=\"space-y-4\">\n <label className=\"grid gap-1\">\n {tr('coolandlovely.resale.editor.title', 'Title')}\n <input\n className={control}\n required\n maxLength={255}\n value={title}\n onChange={(event) => setTitle(event.target.value)}\n />\n </label>\n <label className=\"grid gap-1\">\n {tr('coolandlovely.resale.editor.description', 'Description')}\n <textarea\n className={`${control} min-h-28`}\n required\n maxLength={4000}\n value={description}\n onChange={(event) => setDescription(event.target.value)}\n />\n </label>\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <label className=\"grid gap-1\">\n {tr('coolandlovely.resale.editor.category', 'Category')}\n <select\n className={control}\n value={category}\n onChange={(event) => setCategory(event.target.value)}\n >\n {RESALE_CATEGORIES.map((value) => (\n <option key={value} value={value}>\n {value.replaceAll('_', ' ')}\n </option>\n ))}\n </select>\n </label>\n <label className=\"grid gap-1\">\n {tr('coolandlovely.resale.editor.condition', 'Condition')}\n <select\n className={control}\n value={condition}\n onChange={(event) => setCondition(event.target.value)}\n >\n {RESALE_CONDITIONS.map((value) => (\n <option key={value} value={value}>\n {value.replaceAll('_', ' ')}\n </option>\n ))}\n </select>\n </label>\n <label className=\"grid gap-1\">\n {tr('coolandlovely.resale.editor.size', 'Size')}\n <input\n className={control}\n required\n maxLength={80}\n value={size}\n onChange={(event) => setSize(event.target.value)}\n />\n </label>\n <label className=\"grid gap-1\">\n {tr('coolandlovely.resale.editor.currency', 'Currency')}\n <select\n className={control}\n value={currency}\n onChange={(event) => setCurrency(event.target.value)}\n >\n {Intl.supportedValuesOf('currency').map((value) => (\n <option key={value}>{value}</option>\n ))}\n </select>\n </label>\n <label className=\"grid gap-1\">\n {tr('coolandlovely.resale.editor.price', 'Price')}\n <input\n className={control}\n required\n inputMode=\"decimal\"\n maxLength={32}\n value={price}\n onChange={(event) => setPrice(event.target.value)}\n />\n </label>\n </div>\n <ResalePhotoPicker\n selected={photos}\n onChange={setPhotos}\n disabled={busy || preparing || blocked || pending}\n />\n </fieldset>\n {pending && (\n <div role=\"status\" className=\"space-y-2 rounded-lg border border-border-seam p-3\">\n <p>\n {tr(\n 'coolandlovely.resale.editor.pendingNotice',\n 'A listing request remains pending for this account and context. Resolve it to recover its saved listing or permanently withdraw an uncommitted create. This never submits another listing.'\n )}\n </p>\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={busy}\n onClick={() => {\n void resolve();\n }}\n >\n {tr('coolandlovely.resale.editor.resolvePending', 'Resolve pending listing request')}\n </Button>\n </div>\n )}\n {message && (\n <p role=\"alert\" className=\"text-status-error-text\">\n {tr(message.key, message.fallback)}\n </p>\n )}\n <div className=\"flex flex-wrap gap-2\">\n <Button type=\"submit\" disabled={busy || preparing || blocked || pending || changed}>\n {tr('coolandlovely.resale.editor.saveDraft', 'Save private draft')}\n </Button>\n <Button type=\"button\" variant=\"outline\" disabled={busy} onClick={onClose}>\n {tr('coolandlovely.resale.editor.close', 'Close')}\n </Button>\n </div>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;AA4BA,IAAM,IACJ;AAEF,SAAgB,EAAoB,EAClC,YACA,YACA,aAAU,MAKT;CACD,IAAM,IAAK,EAAM,GACX,EAAE,WAAQ,GAAgB,GAC1B,IAAY,EAAgB,CAAG,GAC/B,CAAC,GAAO,KAAY,EAAS,GAAS,SAAS,EAAE,GACjD,CAAC,GAAa,KAAkB,EAAS,GAAS,eAAe,EAAE,GACnE,CAAC,GAAM,KAAW,EAAS,GAAS,QAAQ,EAAE,GAC9C,CAAC,GAAU,KAAe,EAAS,GAAS,YAAY,MAAM,GAC9D,CAAC,GAAW,KAAgB,EAAS,GAAS,aAAa,MAAM,GACjE,CAAC,GAAU,KAAe,EAAS,GAAS,YAAY,KAAK,GAC7D,CAAC,GAAO,KAAY,EACxB,IAAU,EAAiB,EAAQ,YAAY,EAAQ,QAAQ,IAAI,EACrE,GACM,CAAC,GAAQ,KAAa,EAAS,GAAS,gBAAgB,CAAC,CAAC,GAC1D,CAAC,GAAS,KAAc,EAAmD,IAAI,GAC/E,CAAC,GAAM,KAAW,EAAS,EAAK,GAChC,IAAa,GAAO,EAAK,GACzB,CAAC,GAAS,KAAc,EAAS,EAAK,GACtC,CAAC,GAAQ,KAAa,EAAoC,IAAI,GAC9D,CAAC,GAAW,MAAgB,EAAS,C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SACP,WAAW,MAAU,EAAS,EAAM,OAAO,KAAK;QACjD,CAAA,CACI;;MACJ;;KACL,kBAAC,IAAD;MACE,UAAU;MACV,UAAU;MACV,UAAU,KAAQ,KAAa,KAAW;KAC3C,CAAA;IACO;;GACT,KACC,kBAAC,OAAD;IAAK,MAAK;IAAS,WAAU;cAA7B,CACE,kBAAC,KAAD,EAAA,UACG,EACC,6CACA,4LACF,EACC,CAAA,GACH,kBAAC,GAAD;KACE,MAAK;KACL,SAAQ;KACR,UAAU;KACV,eAAe;MACb,GAAa;KACf;eAEC,EAAG,8CAA8C,iCAAiC;IAC7E,CAAA,CACL;;GAEN,KACC,kBAAC,KAAD;IAAG,MAAK;IAAQ,WAAU;cACvB,EAAG,EAAQ,KAAK,EAAQ,QAAQ;GAChC,CAAA;GAEL,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KAAQ,MAAK;KAAS,UAAU,KAAQ,KAAa,KAAW,KAAW;eACxE,EAAG,yCAAyC,oBAAoB;IAC3D,CAAA,GACR,kBAAC,GAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,UAAU;KAAM,SAAS;eAC9D,EAAG,qCAAqC,OAAO;IAC1C,CAAA,CACL;;EACD;;AAEV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResalePhotoPicker.d.ts","sourceRoot":"","sources":["../../../src/coolandlovely/components/ResalePhotoPicker.tsx"],"names":[],"mappings":"AAKA,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;CACnB,+BAkLA"}
|