@burdenoff/microfe-devportal 2026.831.1 → 2026.914.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ export interface SellerOrganizationSummary {
2
+ id: string;
3
+ name: string;
4
+ slug: string;
5
+ contactEmail: string | null;
6
+ websiteUrl: string | null;
7
+ legalEntityName: string | null;
8
+ taxCountry: string | null;
9
+ }
10
+ export interface UseSellerOrganizationResult {
11
+ organization: SellerOrganizationSummary | null;
12
+ organizations: SellerOrganizationSummary[];
13
+ loading: boolean;
14
+ error: string | null;
15
+ selectOrganization: (id: string) => void;
16
+ }
17
+ export declare function useSellerOrganization(): UseSellerOrganizationResult;
18
+ //# sourceMappingURL=useSellerOrganization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSellerOrganization.d.ts","sourceRoot":"","sources":["../../../src/devportal/hooks/useSellerOrganization.ts"],"names":[],"mappings":"AAkDA,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC/C,aAAa,EAAE,yBAAyB,EAAE,CAAC;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AAED,wBAAgB,qBAAqB,IAAI,2BAA2B,CAyGnE"}
@@ -0,0 +1,58 @@
1
+ import { useDevportal as e } from "../providers/DevportalProvider.js";
2
+ import { useEffect as t, useRef as n, useState as r } from "react";
3
+ //#region src/devportal/hooks/useSellerOrganization.ts
4
+ var i = "\n query SellerPhysicalOrganizations {\n developerOrganizations(kind: PHYSICAL, limit: 50, offset: 0) {\n edges {\n node {\n id\n name\n slug\n contactEmail\n websiteUrl\n legalEntityName\n taxCountry\n }\n }\n }\n }\n", a = "\n mutation CreateSellerOrganizationForSellerPortal($input: CreateDeveloperOrganizationInput!) {\n createSellerOrganization(input: $input) {\n id\n name\n slug\n contactEmail\n websiteUrl\n legalEntityName\n taxCountry\n }\n }\n";
5
+ function o() {
6
+ let { apiGatewayUrl: o, authToken: s, activePhysicalOrgId: c, setActivePhysicalOrgId: l } = e(), [u, d] = r([]), [f, p] = r(!0), [m, h] = r(null), g = n(!1), _ = `${o || ""}/global/graphql`;
7
+ return t(() => {
8
+ let e = !1;
9
+ async function t(e, t) {
10
+ let n = await (await fetch(_, {
11
+ method: "POST",
12
+ headers: {
13
+ "Content-Type": "application/json",
14
+ ...s ? { Authorization: `Bearer ${s}` } : {}
15
+ },
16
+ credentials: "include",
17
+ body: JSON.stringify({
18
+ query: e,
19
+ variables: t
20
+ })
21
+ })).json();
22
+ if (n.errors?.length) throw Error(n.errors.map((e) => e.message).join("; "));
23
+ return n.data;
24
+ }
25
+ async function n() {
26
+ p(!0), h(null);
27
+ try {
28
+ let n = await t(i);
29
+ if (e) return;
30
+ let r = n.developerOrganizations.edges.map((e) => e.node);
31
+ if (r.length === 0 && !g.current) {
32
+ g.current = !0;
33
+ let n = await t(a, { input: { name: "My Store" } });
34
+ if (e) return;
35
+ r = [n.createSellerOrganization];
36
+ }
37
+ d(r), r.some((e) => e.id === c) || l(r[0]?.id ?? null);
38
+ } catch (t) {
39
+ e || h(t instanceof Error ? t.message : String(t));
40
+ } finally {
41
+ e || p(!1);
42
+ }
43
+ }
44
+ return n(), () => {
45
+ e = !0;
46
+ };
47
+ }, [_, s]), {
48
+ organization: u.find((e) => e.id === c) ?? u[0] ?? null,
49
+ organizations: u,
50
+ loading: f,
51
+ error: m,
52
+ selectOrganization: l
53
+ };
54
+ }
55
+ //#endregion
56
+ export { o as useSellerOrganization };
57
+
58
+ //# sourceMappingURL=useSellerOrganization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSellerOrganization.js","names":[],"sources":["../../../src/devportal/hooks/useSellerOrganization.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { useDevportal } from \"../providers/DevportalProvider\";\n\n/**\n * Resolves the seller portal's current PHYSICAL-kind devportal org.\n *\n * Every seller-portal page (Dashboard, My Items, Orders, Create/Edit\n * Physical Item) must operate on the same PHYSICAL org, not independently\n * grab \"whichever org happens to be first\" — that let a multi-org seller's\n * physical listings silently attach to the wrong org. This hook is the\n * single source of truth: it prefers the persisted activePhysicalOrgId (if\n * still one of the caller's PHYSICAL orgs), falls back to the first PHYSICAL\n * org the actor belongs to, and — only if none exists yet — auto-provisions\n * one via createSellerOrganization (mirrors the previous auto-provision-on-\n * first-listing UX, now correctly scoped to PHYSICAL). See DeveloperOrgKind\n * (BOFF-7285).\n */\n\nconst PHYSICAL_ORGS_QUERY = `\n query SellerPhysicalOrganizations {\n developerOrganizations(kind: PHYSICAL, limit: 50, offset: 0) {\n edges {\n node {\n id\n name\n slug\n contactEmail\n websiteUrl\n legalEntityName\n taxCountry\n }\n }\n }\n }\n`;\n\nconst CREATE_SELLER_ORGANIZATION_MUTATION = `\n mutation CreateSellerOrganizationForSellerPortal($input: CreateDeveloperOrganizationInput!) {\n createSellerOrganization(input: $input) {\n id\n name\n slug\n contactEmail\n websiteUrl\n legalEntityName\n taxCountry\n }\n }\n`;\n\nexport interface SellerOrganizationSummary {\n id: string;\n name: string;\n slug: string;\n contactEmail: string | null;\n websiteUrl: string | null;\n legalEntityName: string | null;\n taxCountry: string | null;\n}\n\nexport interface UseSellerOrganizationResult {\n organization: SellerOrganizationSummary | null;\n organizations: SellerOrganizationSummary[];\n loading: boolean;\n error: string | null;\n selectOrganization: (id: string) => void;\n}\n\nexport function useSellerOrganization(): UseSellerOrganizationResult {\n const {\n apiGatewayUrl,\n authToken,\n activePhysicalOrgId,\n setActivePhysicalOrgId,\n } = useDevportal();\n\n const [organizations, setOrganizations] = useState<\n SellerOrganizationSummary[]\n >([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const hasAttemptedAutoCreate = useRef(false);\n\n const endpoint = `${apiGatewayUrl || \"\"}/global/graphql`;\n\n useEffect(() => {\n let cancelled = false;\n\n async function gqlFetch<T>(\n query: string,\n variables?: Record<string, unknown>,\n ): Promise<T> {\n const res = await fetch(endpoint, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(authToken ? { Authorization: `Bearer ${authToken}` } : {}),\n },\n credentials: \"include\",\n body: JSON.stringify({ query, variables }),\n });\n const json = (await res.json()) as {\n data?: T;\n errors?: { message: string }[];\n };\n if (json.errors?.length) {\n throw new Error(json.errors.map((e) => e.message).join(\"; \"));\n }\n return json.data as T;\n }\n\n async function run(): Promise<void> {\n setLoading(true);\n setError(null);\n try {\n const data = await gqlFetch<{\n developerOrganizations: {\n edges: { node: SellerOrganizationSummary }[];\n };\n }>(PHYSICAL_ORGS_QUERY);\n if (cancelled) return;\n\n let physicalOrgs = data.developerOrganizations.edges.map(\n (edge) => edge.node,\n );\n\n if (physicalOrgs.length === 0 && !hasAttemptedAutoCreate.current) {\n hasAttemptedAutoCreate.current = true;\n const created = await gqlFetch<{\n createSellerOrganization: SellerOrganizationSummary;\n }>(CREATE_SELLER_ORGANIZATION_MUTATION, {\n input: { name: \"My Store\" },\n });\n if (cancelled) return;\n physicalOrgs = [created.createSellerOrganization];\n }\n\n setOrganizations(physicalOrgs);\n\n const stillValid = physicalOrgs.some(\n (org) => org.id === activePhysicalOrgId,\n );\n if (!stillValid) {\n setActivePhysicalOrgId(physicalOrgs[0]?.id ?? null);\n }\n } catch (err) {\n if (!cancelled) {\n setError(err instanceof Error ? err.message : String(err));\n }\n } finally {\n if (!cancelled) setLoading(false);\n }\n }\n\n void run();\n return () => {\n cancelled = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- activePhysicalOrgId/setActivePhysicalOrgId intentionally excluded: they're read/written inside this effect, re-running on every write would loop.\n }, [endpoint, authToken]);\n\n const organization =\n organizations.find((org) => org.id === activePhysicalOrgId) ??\n organizations[0] ??\n null;\n\n return {\n organization,\n organizations,\n loading,\n error,\n selectOrganization: setActivePhysicalOrgId,\n };\n}\n"],"mappings":";;;AAkBA,IAAM,IAAsB,6TAkBtB,IAAsC;AAgC5C,SAAgB,IAAqD;CACnE,IAAM,EACJ,kBACA,cACA,wBACA,8BACE,GAAc,EAEZ,CAAC,GAAe,KAAoB,EAExC,EAAE,CAAC,EACC,CAAC,GAAS,KAAc,EAAS,GAAK,EACtC,CAAC,GAAO,KAAY,EAAwB,KAAK,EACjD,IAAyB,EAAO,GAAM,EAEtC,IAAW,GAAG,KAAiB,GAAG;AAmFxC,QAjFA,QAAgB;EACd,IAAI,IAAY;EAEhB,eAAe,EACb,GACA,GACY;GAUZ,IAAM,IAAQ,OATF,MAAM,MAAM,GAAU;IAChC,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,GAAI,IAAY,EAAE,eAAe,UAAU,KAAa,GAAG,EAAE;KAC9D;IACD,aAAa;IACb,MAAM,KAAK,UAAU;KAAE;KAAO;KAAW,CAAC;IAC3C,CAAC,EACsB,MAAM;AAI9B,OAAI,EAAK,QAAQ,OACf,OAAU,MAAM,EAAK,OAAO,KAAK,MAAM,EAAE,QAAQ,CAAC,KAAK,KAAK,CAAC;AAE/D,UAAO,EAAK;;EAGd,eAAe,IAAqB;AAElC,GADA,EAAW,GAAK,EAChB,EAAS,KAAK;AACd,OAAI;IACF,IAAM,IAAO,MAAM,EAIhB,EAAoB;AACvB,QAAI,EAAW;IAEf,IAAI,IAAe,EAAK,uBAAuB,MAAM,KAClD,MAAS,EAAK,KAChB;AAED,QAAI,EAAa,WAAW,KAAK,CAAC,EAAuB,SAAS;AAChE,OAAuB,UAAU;KACjC,IAAM,IAAU,MAAM,EAEnB,GAAqC,EACtC,OAAO,EAAE,MAAM,YAAY,EAC5B,CAAC;AACF,SAAI,EAAW;AACf,SAAe,CAAC,EAAQ,yBAAyB;;AAQnD,IALA,EAAiB,EAAa,EAEX,EAAa,MAC7B,MAAQ,EAAI,OAAO,EACrB,IAEC,EAAuB,EAAa,IAAI,MAAM,KAAK;YAE9C,GAAK;AACZ,IAAK,KACH,EAAS,aAAe,QAAQ,EAAI,UAAU,OAAO,EAAI,CAAC;aAEpD;AACR,IAAK,KAAW,EAAW,GAAM;;;AAKrC,SADK,GAAK,QACG;AACX,OAAY;;IAGb,CAAC,GAAU,EAAU,CAAC,EAOlB;EACL,cALA,EAAc,MAAM,MAAQ,EAAI,OAAO,EAAoB,IAC3D,EAAc,MACd;EAIA;EACA;EACA;EACA,oBAAoB;EACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"CreatePhysicalItemPage.d.ts","sourceRoot":"","sources":["../../../src/devportal/pages/CreatePhysicalItemPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAA0B,MAAM,OAAO,CAAC;AAgKxD,eAAO,MAAM,sBAAsB,EAAE,EA+jBpC,CAAC"}
1
+ {"version":3,"file":"CreatePhysicalItemPage.d.ts","sourceRoot":"","sources":["../../../src/devportal/pages/CreatePhysicalItemPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAA0B,MAAM,OAAO,CAAC;AAiJxD,eAAO,MAAM,sBAAsB,EAAE,EAukBpC,CAAC"}