@burdenoff/microfe-store 2026.801.1 → 2026.819.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/StoreAdminRoutes.js +27 -27
  2. package/dist/StoreRoot.js +78 -45
  3. package/dist/StoreRoot.js.map +1 -1
  4. package/dist/StoreRoutes.js +163 -85
  5. package/dist/StoreRoutes.js.map +1 -1
  6. package/dist/components/InstallAppModal.js +211 -137
  7. package/dist/components/InstallAppModal.js.map +1 -1
  8. package/dist/components/sourcing/SourcingConfirmationDialog.d.ts +15 -0
  9. package/dist/components/sourcing/SourcingConfirmationDialog.js +61 -0
  10. package/dist/components/sourcing/SourcingConfirmationDialog.js.map +1 -0
  11. package/dist/components/sourcing/SourcingUi.d.ts +51 -0
  12. package/dist/components/sourcing/SourcingUi.js +176 -0
  13. package/dist/components/sourcing/SourcingUi.js.map +1 -0
  14. package/dist/generated/global-operations.d.ts +713 -0
  15. package/dist/generated/global-operations.js +557 -175
  16. package/dist/generated/global-operations.js.map +1 -1
  17. package/dist/generated/global-types.d.ts +2158 -2159
  18. package/dist/generated/global-types.js +8 -2
  19. package/dist/generated/global-types.js.map +1 -1
  20. package/dist/hooks/useBackendCart.js +17 -17
  21. package/dist/hooks/useInstallations.js +32 -32
  22. package/dist/hooks/useOrders.js +7 -7
  23. package/dist/hooks/useSourcing.d.ts +319 -0
  24. package/dist/hooks/useSourcing.js +87 -0
  25. package/dist/hooks/useSourcing.js.map +1 -0
  26. package/dist/hooks/useStoreGraphQL.js +163 -163
  27. package/dist/index.js +12 -12
  28. package/dist/pages/AdminDashboardPage.js +132 -132
  29. package/dist/pages/AdminReviewModerationPage.js +55 -55
  30. package/dist/pages/AdminStoresPage.js +95 -95
  31. package/dist/pages/AdminSubmissionsQueuePage.js +297 -297
  32. package/dist/pages/AdminSubmissionsQueuePage.js.map +1 -1
  33. package/dist/pages/AppDetailPage.js +65 -65
  34. package/dist/pages/AppSettingsPage.js +32 -32
  35. package/dist/pages/CartPage.js +66 -66
  36. package/dist/pages/CreateSourcingRequestPage.d.ts +3 -0
  37. package/dist/pages/CreateSourcingRequestPage.js +439 -0
  38. package/dist/pages/CreateSourcingRequestPage.js.map +1 -0
  39. package/dist/pages/InstalledAppsPage.js +15 -15
  40. package/dist/pages/InstalledAppsPage.js.map +1 -1
  41. package/dist/pages/MarketplaceHomePage.js +384 -384
  42. package/dist/pages/MarketplaceHomePage.js.map +1 -1
  43. package/dist/pages/MyLicensesPage.js +39 -39
  44. package/dist/pages/OrderConfirmationPage.js +57 -57
  45. package/dist/pages/OrdersPage.js +3 -3
  46. package/dist/pages/OrdersPage.js.map +1 -1
  47. package/dist/pages/ProductDetailPage.js +6 -6
  48. package/dist/pages/SellerSourcingOffersPage.d.ts +3 -0
  49. package/dist/pages/SellerSourcingOffersPage.js +284 -0
  50. package/dist/pages/SellerSourcingOffersPage.js.map +1 -0
  51. package/dist/pages/SellerSourcingOpportunitiesPage.d.ts +3 -0
  52. package/dist/pages/SellerSourcingOpportunitiesPage.js +272 -0
  53. package/dist/pages/SellerSourcingOpportunitiesPage.js.map +1 -0
  54. package/dist/pages/SellerSourcingOpportunityDetailPage.d.ts +3 -0
  55. package/dist/pages/SellerSourcingOpportunityDetailPage.js +465 -0
  56. package/dist/pages/SellerSourcingOpportunityDetailPage.js.map +1 -0
  57. package/dist/pages/SourcingRequestDetailPage.d.ts +3 -0
  58. package/dist/pages/SourcingRequestDetailPage.js +447 -0
  59. package/dist/pages/SourcingRequestDetailPage.js.map +1 -0
  60. package/dist/pages/SourcingRequestsPage.d.ts +3 -0
  61. package/dist/pages/SourcingRequestsPage.js +272 -0
  62. package/dist/pages/SourcingRequestsPage.js.map +1 -0
  63. package/dist/providers/SourcingAccessProvider.d.ts +21 -0
  64. package/dist/providers/SourcingAccessProvider.js +95 -0
  65. package/dist/providers/SourcingAccessProvider.js.map +1 -0
  66. package/dist/translations/en.d.ts +3 -0
  67. package/dist/translations/en.js +3 -0
  68. package/dist/translations/en.js.map +1 -1
  69. package/package.json +2 -2
@@ -2,62 +2,62 @@ import { STORE_PERMISSIONS as e, useStorePermissions as t } from "./hooks/useSto
2
2
  import { PermissionGuard as n } from "./components/PermissionGuard.js";
3
3
  import { PageLoadingFallback as r } from "./components/RouteGuards.js";
4
4
  import { Suspense as i, lazy as a } from "react";
5
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
- import { Navigate as c, Route as l, Routes as u } from "react-router";
5
+ import { Navigate as o, Route as s, Routes as c } from "react-router";
6
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
7
  //#region src/StoreAdminRoutes.tsx
8
8
  var d = a(() => import("./pages/AdminDashboardPage.js").then((e) => ({ default: e.AdminDashboardPage }))), f = a(() => import("./pages/AdminSubmissionsQueuePage.js").then((e) => ({ default: e.AdminSubmissionsQueuePage }))), p = a(() => import("./pages/AdminStoresPage.js").then((e) => ({ default: e.AdminStoresPage }))), m = a(() => import("./pages/AdminReviewModerationPage.js").then((e) => ({ default: e.AdminReviewModerationPage }))), h = () => {
9
9
  let { hasPermission: a } = t(), h = a(e.REVIEW_ADMIN) || a(e.PRODUCT_ADMIN);
10
- return /* @__PURE__ */ s(u, { children: [
11
- /* @__PURE__ */ o(l, {
10
+ return /* @__PURE__ */ u(c, { children: [
11
+ /* @__PURE__ */ l(s, {
12
12
  index: !0,
13
- element: /* @__PURE__ */ o(c, {
13
+ element: /* @__PURE__ */ l(o, {
14
14
  to: "dashboard",
15
15
  replace: !0
16
16
  })
17
17
  }),
18
- /* @__PURE__ */ o(l, {
18
+ /* @__PURE__ */ l(s, {
19
19
  path: "dashboard",
20
- element: /* @__PURE__ */ o(n, {
20
+ element: /* @__PURE__ */ l(n, {
21
21
  allowed: h,
22
- children: /* @__PURE__ */ o(i, {
23
- fallback: /* @__PURE__ */ o(r, {}),
24
- children: /* @__PURE__ */ o(d, {})
22
+ children: /* @__PURE__ */ l(i, {
23
+ fallback: /* @__PURE__ */ l(r, {}),
24
+ children: /* @__PURE__ */ l(d, {})
25
25
  })
26
26
  })
27
27
  }),
28
- /* @__PURE__ */ o(l, {
28
+ /* @__PURE__ */ l(s, {
29
29
  path: "submissions",
30
- element: /* @__PURE__ */ o(n, {
30
+ element: /* @__PURE__ */ l(n, {
31
31
  allowed: h,
32
- children: /* @__PURE__ */ o(i, {
33
- fallback: /* @__PURE__ */ o(r, {}),
34
- children: /* @__PURE__ */ o(f, {})
32
+ children: /* @__PURE__ */ l(i, {
33
+ fallback: /* @__PURE__ */ l(r, {}),
34
+ children: /* @__PURE__ */ l(f, {})
35
35
  })
36
36
  })
37
37
  }),
38
- /* @__PURE__ */ o(l, {
38
+ /* @__PURE__ */ l(s, {
39
39
  path: "stores",
40
- element: /* @__PURE__ */ o(n, {
40
+ element: /* @__PURE__ */ l(n, {
41
41
  allowed: h,
42
- children: /* @__PURE__ */ o(i, {
43
- fallback: /* @__PURE__ */ o(r, {}),
44
- children: /* @__PURE__ */ o(p, {})
42
+ children: /* @__PURE__ */ l(i, {
43
+ fallback: /* @__PURE__ */ l(r, {}),
44
+ children: /* @__PURE__ */ l(p, {})
45
45
  })
46
46
  })
47
47
  }),
48
- /* @__PURE__ */ o(l, {
48
+ /* @__PURE__ */ l(s, {
49
49
  path: "reviews",
50
- element: /* @__PURE__ */ o(n, {
50
+ element: /* @__PURE__ */ l(n, {
51
51
  allowed: a(e.REVIEW_ADMIN),
52
- children: /* @__PURE__ */ o(i, {
53
- fallback: /* @__PURE__ */ o(r, {}),
54
- children: /* @__PURE__ */ o(m, {})
52
+ children: /* @__PURE__ */ l(i, {
53
+ fallback: /* @__PURE__ */ l(r, {}),
54
+ children: /* @__PURE__ */ l(m, {})
55
55
  })
56
56
  })
57
57
  }),
58
- /* @__PURE__ */ o(l, {
58
+ /* @__PURE__ */ l(s, {
59
59
  path: "*",
60
- element: /* @__PURE__ */ o(c, {
60
+ element: /* @__PURE__ */ l(o, {
61
61
  to: "dashboard",
62
62
  replace: !0
63
63
  })
package/dist/StoreRoot.js CHANGED
@@ -1,96 +1,129 @@
1
- import { StoreProvider as e } from "./providers/StoreProvider.js";
2
- import { StoreRoutes as t } from "./StoreRoutes.js";
3
- import { useCart as n } from "./hooks/useCart.js";
4
- import { useEffect as r, useMemo as i } from "react";
5
- import { ErrorBoundary as a } from "@burdenoff/fe-libs/shared/components";
6
- import { FeatureFlagProvider as o } from "@burdenoff/fe-libs/shared/feature-flags";
7
- import { useI18n as s } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
8
- import { Key as c, Package as l, Receipt as u, ShoppingBag as d, ShoppingCart as f } from "lucide-react";
9
- import { jsx as p } from "react/jsx-runtime";
1
+ import { StoreProvider as e, useStore as t } from "./providers/StoreProvider.js";
2
+ import { PublisherSourcingAccessProvider as n, usePublisherSourcingAccess as r } from "./providers/SourcingAccessProvider.js";
3
+ import { StoreRoutes as i } from "./StoreRoutes.js";
4
+ import { useCart as a } from "./hooks/useCart.js";
5
+ import { useEffect as o, useMemo as s } from "react";
6
+ import { useLocation as c } from "react-router";
7
+ import { ErrorBoundary as l } from "@burdenoff/fe-libs/shared/components";
8
+ import { FeatureFlagProvider as u } from "@burdenoff/fe-libs/shared/feature-flags";
9
+ import { useI18n as d } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
10
+ import { Key as f, Package as p, PackageSearch as m, Receipt as h, ShoppingBag as g, ShoppingCart as _, TicketCheck as v } from "lucide-react";
11
+ import { jsx as y } from "react/jsx-runtime";
10
12
  //#region src/StoreRoot.tsx
11
- var m = (t) => {
12
- let { t: n } = s();
13
- return /* @__PURE__ */ p(o, {
13
+ var b = (t) => {
14
+ let { t: n } = d();
15
+ return /* @__PURE__ */ y(u, {
14
16
  workspaceId: t.workspaceId ?? null,
15
17
  gateway: "global",
16
18
  defaultEnabled: !0,
17
- children: /* @__PURE__ */ p(a, {
18
- fallback: /* @__PURE__ */ p("div", {
19
+ children: /* @__PURE__ */ y(l, {
20
+ fallback: /* @__PURE__ */ y("div", {
19
21
  className: "p-6 text-center text-text-secondary",
20
22
  children: n("common.moduleLoadError", { defaultValue: "Something went wrong loading this module. Please refresh the page." })
21
23
  }),
22
- children: /* @__PURE__ */ p(e, {
24
+ children: /* @__PURE__ */ y(e, {
23
25
  ...t,
24
- children: /* @__PURE__ */ p(h, { ...t })
26
+ children: /* @__PURE__ */ y(x, { children: /* @__PURE__ */ y(S, { ...t }) })
25
27
  })
26
28
  })
27
29
  });
28
- }, h = ({ registerNavItems: e, registerFooterItems: a, basePath: o = "/" }) => {
29
- let { itemCount: m } = n(), { t: h } = s();
30
- r(() => {
30
+ }, x = ({ children: e }) => {
31
+ let { user: r, authToken: i } = t(), { pathname: a } = c(), o = a.includes("/publisher/sourcing/opportunities/");
32
+ return /* @__PURE__ */ y(n, {
33
+ enabled: !!(r?.id || i),
34
+ includeProducts: o,
35
+ children: e
36
+ });
37
+ }, S = ({ registerNavItems: e, registerFooterItems: t, basePath: n = "/" }) => {
38
+ let { itemCount: c } = a(), { profile: l } = r(), { t: u } = d();
39
+ o(() => {
31
40
  if (!e) return;
32
41
  let t = (e, t) => (e.endsWith("/") ? e.slice(0, -1) : e) + (t.startsWith("/") ? t : `/${t}`);
33
42
  return e([
34
43
  {
35
44
  id: "store-marketplace",
36
- label: h("nav.marketplace", { defaultValue: "Marketplace" }),
37
- path: t(o, "marketplace"),
38
- icon: /* @__PURE__ */ p(d, { size: 20 }),
45
+ label: u("nav.marketplace", { defaultValue: "Marketplace" }),
46
+ path: t(n, "marketplace"),
47
+ icon: /* @__PURE__ */ y(g, { size: 20 }),
39
48
  order: 10,
40
49
  group: "store"
41
50
  },
42
51
  {
43
52
  id: "store-cart",
44
- label: h("nav.cart", { defaultValue: "Cart" }),
45
- path: t(o, "cart"),
46
- icon: /* @__PURE__ */ p(f, { size: 20 }),
47
- badge: m > 0 ? m : void 0,
53
+ label: u("nav.cart", { defaultValue: "Cart" }),
54
+ path: t(n, "cart"),
55
+ icon: /* @__PURE__ */ y(_, { size: 20 }),
56
+ badge: c > 0 ? c : void 0,
48
57
  order: 20,
49
58
  group: "store"
50
59
  },
51
60
  {
52
61
  id: "store-orders",
53
- label: h("nav.orders", { defaultValue: "My Orders" }),
54
- path: t(o, "orders"),
55
- icon: /* @__PURE__ */ p(u, { size: 20 }),
62
+ label: u("nav.orders", { defaultValue: "My Orders" }),
63
+ path: t(n, "orders"),
64
+ icon: /* @__PURE__ */ y(h, { size: 20 }),
56
65
  order: 30,
57
66
  group: "store"
58
67
  },
68
+ {
69
+ id: "store-sourcing-requests",
70
+ label: u("nav.sourcingRequests", { defaultValue: "Sourcing requests" }),
71
+ path: t(n, "sourcing/requests"),
72
+ icon: /* @__PURE__ */ y(m, { size: 20 }),
73
+ order: 35,
74
+ group: "store"
75
+ },
76
+ ...l ? [{
77
+ id: "store-sourcing-opportunities",
78
+ label: u("nav.sourcingOpportunities", { defaultValue: "Sourcing opportunities" }),
79
+ path: t(n, "publisher/sourcing/opportunities"),
80
+ icon: /* @__PURE__ */ y(m, { size: 20 }),
81
+ order: 36,
82
+ group: "store"
83
+ }, {
84
+ id: "store-sourcing-offers",
85
+ label: u("nav.sourcingOffers", { defaultValue: "My sourcing offers" }),
86
+ path: t(n, "publisher/sourcing/offers"),
87
+ icon: /* @__PURE__ */ y(v, { size: 20 }),
88
+ order: 37,
89
+ group: "store"
90
+ }] : [],
59
91
  {
60
92
  id: "store-installed",
61
- label: h("nav.installed", { defaultValue: "Installed Apps" }),
62
- path: t(o, "installed"),
63
- icon: /* @__PURE__ */ p(l, { size: 20 }),
93
+ label: u("nav.installed", { defaultValue: "Installed Apps" }),
94
+ path: t(n, "installed"),
95
+ icon: /* @__PURE__ */ y(p, { size: 20 }),
64
96
  order: 40,
65
97
  group: "store"
66
98
  },
67
99
  {
68
100
  id: "store-licenses",
69
- label: h("nav.licenses", { defaultValue: "Licenses" }),
70
- path: t(o, "licenses"),
71
- icon: /* @__PURE__ */ p(c, { size: 20 }),
101
+ label: u("nav.licenses", { defaultValue: "Licenses" }),
102
+ path: t(n, "licenses"),
103
+ icon: /* @__PURE__ */ y(f, { size: 20 }),
72
104
  order: 50,
73
105
  group: "store"
74
106
  }
75
107
  ]);
76
108
  }, [
77
109
  e,
78
- o,
79
- m,
80
- h
110
+ n,
111
+ c,
112
+ l,
113
+ u
81
114
  ]);
82
- let g = i(() => [{
115
+ let b = s(() => [{
83
116
  id: "store-status",
84
- label: h("store.footer.ready", { defaultValue: "Store Ready" }),
117
+ label: u("store.footer.ready", { defaultValue: "Store Ready" }),
85
118
  type: "status",
86
119
  order: 10,
87
120
  section: "left"
88
- }], [h]);
89
- return r(() => {
90
- if (a) return a(g);
91
- }, [a, g]), /* @__PURE__ */ p(t, {});
121
+ }], [u]);
122
+ return o(() => {
123
+ if (t) return t(b);
124
+ }, [t, b]), /* @__PURE__ */ y(i, {});
92
125
  };
93
126
  //#endregion
94
- export { m as StoreRoot };
127
+ export { b as StoreRoot };
95
128
 
96
129
  //# sourceMappingURL=StoreRoot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StoreRoot.js","names":[],"sources":["../src/StoreRoot.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useEffect, useMemo } from 'react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { ShoppingBag, ShoppingCart, Receipt, Package, Key } from 'lucide-react';\nimport { StoreProvider } from './providers/StoreProvider';\nimport type { NavItem, StoreRootProps } from './types';\nimport { StoreRoutes } from './StoreRoutes';\nimport { useCart } from './hooks/useCart';\n\n/**\n * Root component for the Store microfrontend.\n *\n * This is the main entry point that host applications import and render.\n * It sets up the necessary providers and renders the internal routing.\n * Automatically registers navigation items with the shell if registration functions are provided.\n *\n * @example\n * ```tsx\n * import { StoreRoot, type StoreRootProps } from '@burdenoff/micro-fe/store';\n *\n * function App() {\n * const props: StoreRootProps = {\n * basePath: '/store',\n * navigate: (path) => router.push(path),\n * currentUser: { id: '1', email: 'user@example.com', firstName: 'John', lastName: 'Doe' },\n * workspaceId: 'ws-123',\n * organizationId: 'org-123',\n * apiGatewayUrl: 'https://api.example.com/tenant/graphql',\n * authToken: 'token',\n * registerNavItems: (items) => { return () => {}; },\n * };\n *\n * return <StoreRoot {...props} />;\n * }\n * ```\n */\nexport const StoreRoot: FC<StoreRootProps> = (props) => {\n const { t } = useI18n();\n\n return (\n <FeatureFlagProvider\n workspaceId={props.workspaceId ?? null}\n gateway=\"global\"\n defaultEnabled={true}\n >\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n {t('common.moduleLoadError', {\n defaultValue: 'Something went wrong loading this module. Please refresh the page.',\n })}\n </div>\n }\n >\n <StoreProvider {...props}>\n <StoreNavigationRegistration {...props} />\n </StoreProvider>\n </ErrorBoundary>\n </FeatureFlagProvider>\n );\n};\n\n/**\n * Internal component that handles navigation registration\n */\nconst StoreNavigationRegistration: FC<StoreRootProps> = ({\n registerNavItems,\n registerFooterItems,\n basePath = '/',\n}) => {\n const { itemCount } = useCart();\n const { t } = useI18n();\n\n // Register navigation items with the shell\n useEffect(() => {\n if (!registerNavItems) return;\n\n const joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n };\n\n const navItems: NavItem[] = [\n {\n id: 'store-marketplace',\n label: t('nav.marketplace', { defaultValue: 'Marketplace' }),\n path: joinPath(basePath, 'marketplace'),\n icon: <ShoppingBag size={20} />,\n order: 10,\n group: 'store',\n },\n {\n id: 'store-cart',\n label: t('nav.cart', { defaultValue: 'Cart' }),\n path: joinPath(basePath, 'cart'),\n icon: <ShoppingCart size={20} />,\n badge: itemCount > 0 ? itemCount : undefined,\n order: 20,\n group: 'store',\n },\n {\n id: 'store-orders',\n label: t('nav.orders', { defaultValue: 'My Orders' }),\n path: joinPath(basePath, 'orders'),\n icon: <Receipt size={20} />,\n order: 30,\n group: 'store',\n },\n {\n id: 'store-installed',\n label: t('nav.installed', { defaultValue: 'Installed Apps' }),\n path: joinPath(basePath, 'installed'),\n icon: <Package size={20} />,\n order: 40,\n group: 'store',\n },\n {\n id: 'store-licenses',\n label: t('nav.licenses', { defaultValue: 'Licenses' }),\n path: joinPath(basePath, 'licenses'),\n icon: <Key size={20} />,\n order: 50,\n group: 'store',\n },\n ];\n\n const cleanup = registerNavItems(navItems);\n return cleanup;\n }, [registerNavItems, basePath, itemCount, t]);\n\n // Register footer items — memoized to avoid re-registering on every render.\n const footerItems = useMemo(\n () => [\n {\n id: 'store-status',\n label: t('store.footer.ready', { defaultValue: 'Store Ready' }),\n type: 'status' as const,\n order: 10,\n section: 'left' as const,\n },\n ],\n [t]\n );\n\n useEffect(() => {\n if (!registerFooterItems) return;\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems, footerItems]);\n\n return <StoreRoutes />;\n};\n"],"mappings":";;;;;;;;;;AAsCA,IAAa,KAAiC,MAAU;CACtD,IAAM,EAAE,SAAM,GAAS;AAEvB,QACE,kBAAC,GAAD;EACE,aAAa,EAAM,eAAe;EAClC,SAAQ;EACR,gBAAgB;YAEhB,kBAAC,GAAD;GACE,UACE,kBAAC,OAAD;IAAK,WAAU;cACZ,EAAE,0BAA0B,EAC3B,cAAc,sEACf,CAAC;IACE,CAAA;aAGR,kBAAC,GAAD;IAAe,GAAI;cACjB,kBAAC,GAAD,EAA6B,GAAI,GAAS,CAAA;IAC5B,CAAA;GACF,CAAA;EACI,CAAA;GAOpB,KAAmD,EACvD,qBACA,wBACA,cAAW,UACP;CACJ,IAAM,EAAE,iBAAc,GAAS,EACzB,EAAE,SAAM,GAAS;AAGvB,SAAgB;AACd,MAAI,CAAC,EAAkB;EAEvB,IAAM,KAAY,GAAc,OACZ,EAAK,SAAS,IAAI,GAAG,EAAK,MAAM,GAAG,GAAG,GAA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oB,EAAY;IAE/C,CAAC,GAAqB,EAAY,CAAC,EAE/B,kBAAC,GAAD,EAAe,CAAA"}
1
+ {"version":3,"file":"StoreRoot.js","names":[],"sources":["../src/StoreRoot.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { useEffect, useMemo } from 'react';\nimport { useLocation } from 'react-router';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n ShoppingBag,\n ShoppingCart,\n Receipt,\n Package,\n Key,\n PackageSearch,\n TicketCheck,\n} from 'lucide-react';\nimport { StoreProvider, useStore } from './providers/StoreProvider';\nimport {\n PublisherSourcingAccessProvider,\n usePublisherSourcingAccess,\n} from './providers/SourcingAccessProvider';\nimport type { NavItem, StoreRootProps } from './types';\nimport { StoreRoutes } from './StoreRoutes';\nimport { useCart } from './hooks/useCart';\n\n/**\n * Root component for the Store microfrontend.\n *\n * This is the main entry point that host applications import and render.\n * It sets up the necessary providers and renders the internal routing.\n * Automatically registers navigation items with the shell if registration functions are provided.\n *\n * @example\n * ```tsx\n * import { StoreRoot, type StoreRootProps } from '@burdenoff/micro-fe/store';\n *\n * function App() {\n * const props: StoreRootProps = {\n * basePath: '/store',\n * navigate: (path) => router.push(path),\n * currentUser: { id: '1', email: 'user@example.com', firstName: 'John', lastName: 'Doe' },\n * workspaceId: 'ws-123',\n * organizationId: 'org-123',\n * apiGatewayUrl: 'https://api.example.com/tenant/graphql',\n * authToken: 'token',\n * registerNavItems: (items) => { return () => {}; },\n * };\n *\n * return <StoreRoot {...props} />;\n * }\n * ```\n */\nexport const StoreRoot: FC<StoreRootProps> = (props) => {\n const { t } = useI18n();\n\n return (\n <FeatureFlagProvider\n workspaceId={props.workspaceId ?? null}\n gateway=\"global\"\n defaultEnabled={true}\n >\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n {t('common.moduleLoadError', {\n defaultValue: 'Something went wrong loading this module. Please refresh the page.',\n })}\n </div>\n }\n >\n <StoreProvider {...props}>\n <StoreSourcingAccessBoundary>\n <StoreNavigationRegistration {...props} />\n </StoreSourcingAccessBoundary>\n </StoreProvider>\n </ErrorBoundary>\n </FeatureFlagProvider>\n );\n};\n\nconst StoreSourcingAccessBoundary: FC<{ children: ReactNode }> = ({ children }) => {\n const { user, authToken } = useStore();\n const { pathname } = useLocation();\n const includeProducts = pathname.includes('/publisher/sourcing/opportunities/');\n return (\n <PublisherSourcingAccessProvider\n enabled={Boolean(user?.id || authToken)}\n includeProducts={includeProducts}\n >\n {children}\n </PublisherSourcingAccessProvider>\n );\n};\n\n/**\n * Internal component that handles navigation registration\n */\nconst StoreNavigationRegistration: FC<StoreRootProps> = ({\n registerNavItems,\n registerFooterItems,\n basePath = '/',\n}) => {\n const { itemCount } = useCart();\n const { profile: sellerProfile } = usePublisherSourcingAccess();\n const { t } = useI18n();\n\n // Register navigation items with the shell\n useEffect(() => {\n if (!registerNavItems) return;\n\n const joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n };\n\n const navItems: NavItem[] = [\n {\n id: 'store-marketplace',\n label: t('nav.marketplace', { defaultValue: 'Marketplace' }),\n path: joinPath(basePath, 'marketplace'),\n icon: <ShoppingBag size={20} />,\n order: 10,\n group: 'store',\n },\n {\n id: 'store-cart',\n label: t('nav.cart', { defaultValue: 'Cart' }),\n path: joinPath(basePath, 'cart'),\n icon: <ShoppingCart size={20} />,\n badge: itemCount > 0 ? itemCount : undefined,\n order: 20,\n group: 'store',\n },\n {\n id: 'store-orders',\n label: t('nav.orders', { defaultValue: 'My Orders' }),\n path: joinPath(basePath, 'orders'),\n icon: <Receipt size={20} />,\n order: 30,\n group: 'store',\n },\n {\n id: 'store-sourcing-requests',\n label: t('nav.sourcingRequests', { defaultValue: 'Sourcing requests' }),\n path: joinPath(basePath, 'sourcing/requests'),\n icon: <PackageSearch size={20} />,\n order: 35,\n group: 'store',\n },\n ...(sellerProfile\n ? [\n {\n id: 'store-sourcing-opportunities',\n label: t('nav.sourcingOpportunities', { defaultValue: 'Sourcing opportunities' }),\n path: joinPath(basePath, 'publisher/sourcing/opportunities'),\n icon: <PackageSearch size={20} />,\n order: 36,\n group: 'store',\n },\n {\n id: 'store-sourcing-offers',\n label: t('nav.sourcingOffers', { defaultValue: 'My sourcing offers' }),\n path: joinPath(basePath, 'publisher/sourcing/offers'),\n icon: <TicketCheck size={20} />,\n order: 37,\n group: 'store',\n },\n ]\n : []),\n {\n id: 'store-installed',\n label: t('nav.installed', { defaultValue: 'Installed Apps' }),\n path: joinPath(basePath, 'installed'),\n icon: <Package size={20} />,\n order: 40,\n group: 'store',\n },\n {\n id: 'store-licenses',\n label: t('nav.licenses', { defaultValue: 'Licenses' }),\n path: joinPath(basePath, 'licenses'),\n icon: <Key size={20} />,\n order: 50,\n group: 'store',\n },\n ];\n\n const cleanup = registerNavItems(navItems);\n return cleanup;\n }, [registerNavItems, basePath, itemCount, sellerProfile, t]);\n\n // Register footer items — memoized to avoid re-registering on every render.\n const footerItems = useMemo(\n () => [\n {\n id: 'store-status',\n label: t('store.footer.ready', { defaultValue: 'Store Ready' }),\n type: 'status' as const,\n order: 10,\n section: 'left' as const,\n },\n ],\n [t]\n );\n\n useEffect(() => {\n if (!registerFooterItems) return;\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems, footerItems]);\n\n return <StoreRoutes />;\n};\n"],"mappings":";;;;;;;;;;;;AAmDA,IAAa,KAAiC,MAAU;CACtD,IAAM,EAAE,SAAM,GAAS;AAEvB,QACE,kBAAC,GAAD;EACE,aAAa,EAAM,eAAe;EAClC,SAAQ;EACR,gBAAgB;YAEhB,kBAAC,GAAD;GACE,UACE,kBAAC,OAAD;IAAK,WAAU;cACZ,EAAE,0BAA0B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