@fluid-app/portal-sdk 0.1.135 → 0.1.136
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/dist/ProductsScreen-C7cXqLN8.cjs +110 -0
- package/dist/ProductsScreen-C7cXqLN8.cjs.map +1 -0
- package/dist/{ProductsScreen-CbKT2maZ.mjs → ProductsScreen-CTUejNR0.mjs} +2 -2
- package/dist/{ProductsScreen-T1tGuiGy.cjs → ProductsScreen-CcF3f9VD.cjs} +2 -2
- package/dist/ProductsScreen-Di6uVQCx.mjs +98 -0
- package/dist/ProductsScreen-Di6uVQCx.mjs.map +1 -0
- package/dist/ShareablesScreen-B-uZ3B5d.cjs +430 -0
- package/dist/ShareablesScreen-B-uZ3B5d.cjs.map +1 -0
- package/dist/{ShareablesScreen-DSW36iS7.mjs → ShareablesScreen-BHyxG-oy.mjs} +2 -2
- package/dist/{ShareablesScreen-BLbzr0Jb.cjs → ShareablesScreen-DAM01cxf.cjs} +2 -2
- package/dist/ShareablesScreen-iBUd6p7M.mjs +412 -0
- package/dist/ShareablesScreen-iBUd6p7M.mjs.map +1 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/{src-BbjxT3sc.mjs → portal-tenant-product-media-adapter-Co9Kw-US.mjs} +980 -4
- package/dist/portal-tenant-product-media-adapter-Co9Kw-US.mjs.map +1 -0
- package/dist/{src-DmzXXBVt.cjs → portal-tenant-product-media-adapter-DM94zJXA.cjs} +1039 -3
- package/dist/portal-tenant-product-media-adapter-DM94zJXA.cjs.map +1 -0
- package/package.json +16 -16
- package/dist/ProductsScreen-B1OAGNQx.cjs +0 -283
- package/dist/ProductsScreen-B1OAGNQx.cjs.map +0 -1
- package/dist/ProductsScreen-CL71MQNL.mjs +0 -271
- package/dist/ProductsScreen-CL71MQNL.mjs.map +0 -1
- package/dist/ShareablesScreen-CecBPoFO.mjs +0 -1360
- package/dist/ShareablesScreen-CecBPoFO.mjs.map +0 -1
- package/dist/ShareablesScreen-DDutXKpW.cjs +0 -1378
- package/dist/ShareablesScreen-DDutXKpW.cjs.map +0 -1
- package/dist/src-BbjxT3sc.mjs.map +0 -1
- package/dist/src-DmzXXBVt.cjs.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
require("./chunk-9hOWP6kD.cjs");
|
|
2
|
+
const require_FluidProvider = require("./FluidProvider-Dyq7lCdf.cjs");
|
|
3
|
+
const require_use_current_user = require("./use-current-user-C4oXzxPk.cjs");
|
|
4
|
+
const require_AppNavigationContext = require("./AppNavigationContext-Agp0UkCQ.cjs");
|
|
5
|
+
const require_use_account_clients = require("./use-account-clients-C6QS6yk6.cjs");
|
|
6
|
+
const require_portal_tenant_product_media_adapter = require("./portal-tenant-product-media-adapter-DM94zJXA.cjs");
|
|
7
|
+
const require_use_portal_products_client = require("./use-portal-products-client-CTaxgbMq.cjs");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
//#region src/screens/ProductsScreen.tsx
|
|
11
|
+
function ProductsScreen({ background, textColor, accentColor, padding, borderRadius, ...divProps }) {
|
|
12
|
+
const domainClient = require_use_account_clients.useSdkClient();
|
|
13
|
+
const portalProductsApi = require_use_portal_products_client.usePortalProductsClient();
|
|
14
|
+
const portalTenantClient = require_FluidProvider.usePortalTenantClient();
|
|
15
|
+
const { data: userData } = require_use_current_user.useCurrentUser();
|
|
16
|
+
const { currentSlug, navigate } = require_AppNavigationContext.useAppNavigation();
|
|
17
|
+
const fetchProducts = (0, react.useCallback)(async (search, cursor, limit) => {
|
|
18
|
+
if (search) return portalProductsApi.searchProducts(search, {
|
|
19
|
+
cursor,
|
|
20
|
+
limit
|
|
21
|
+
});
|
|
22
|
+
return portalProductsApi.listProducts({
|
|
23
|
+
cursor,
|
|
24
|
+
limit
|
|
25
|
+
});
|
|
26
|
+
}, [portalProductsApi]);
|
|
27
|
+
const fetchProduct = (0, react.useCallback)(async (id) => portalProductsApi.getProduct(id), [portalProductsApi]);
|
|
28
|
+
const productId = (0, react.useMemo)(() => {
|
|
29
|
+
return currentSlug.match(/^products\/(.+)/)?.[1] ?? null;
|
|
30
|
+
}, [currentSlug]);
|
|
31
|
+
const handleSelectProduct = (0, react.useCallback)((id) => {
|
|
32
|
+
navigate(`products/${id}`);
|
|
33
|
+
}, [navigate]);
|
|
34
|
+
const handleBack = (0, react.useCallback)(() => {
|
|
35
|
+
navigate("products");
|
|
36
|
+
}, [navigate]);
|
|
37
|
+
const coreConfig = (0, react.useMemo)(() => ({
|
|
38
|
+
client: domainClient,
|
|
39
|
+
user: userData ? { id: userData.id } : null,
|
|
40
|
+
repContext: true
|
|
41
|
+
}), [domainClient, userData]);
|
|
42
|
+
const mediaAdapter = (0, react.useMemo)(() => require_portal_tenant_product_media_adapter.createPortalTenantMediaShareablesAdapter(portalTenantClient), [portalTenantClient]);
|
|
43
|
+
const playlistsAdapter = (0, react.useMemo)(() => require_portal_tenant_product_media_adapter.createPortalTenantPlaylistsShareablesAdapter(portalTenantClient), [portalTenantClient]);
|
|
44
|
+
const filesAdapter = (0, react.useMemo)(() => require_portal_tenant_product_media_adapter.createPortalTenantFilesShareablesAdapter(portalTenantClient), [portalTenantClient]);
|
|
45
|
+
const sharesAdapter = (0, react.useMemo)(() => require_portal_tenant_product_media_adapter.createPortalTenantSharesShareablesAdapter(portalTenantClient), [portalTenantClient]);
|
|
46
|
+
const productMediaAdapter = (0, react.useMemo)(() => require_portal_tenant_product_media_adapter.createPortalTenantProductMediaShareablesAdapter(portalProductsApi), [portalProductsApi]);
|
|
47
|
+
const uiConfig = (0, react.useMemo)(() => ({
|
|
48
|
+
user: userData ? {
|
|
49
|
+
id: userData.id,
|
|
50
|
+
company: userData.company ? { logo_url: userData.company.logo_url } : null
|
|
51
|
+
} : void 0,
|
|
52
|
+
basePath: "",
|
|
53
|
+
navigate: (path) => {
|
|
54
|
+
navigate(path);
|
|
55
|
+
},
|
|
56
|
+
showToast: (opts) => {
|
|
57
|
+
console.log(`[Products] ${opts.type}: ${opts.title}`);
|
|
58
|
+
}
|
|
59
|
+
}), [userData, navigate]);
|
|
60
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
61
|
+
...divProps,
|
|
62
|
+
className: `h-full ${divProps.className ?? ""}`,
|
|
63
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_portal_tenant_product_media_adapter.ShareablesCoreProvider, {
|
|
64
|
+
config: coreConfig,
|
|
65
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_portal_tenant_product_media_adapter.ShareablesApiProvider, {
|
|
66
|
+
media: mediaAdapter,
|
|
67
|
+
playlists: playlistsAdapter,
|
|
68
|
+
fileResources: filesAdapter,
|
|
69
|
+
share: sharesAdapter,
|
|
70
|
+
productMedia: productMediaAdapter,
|
|
71
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_portal_tenant_product_media_adapter.ShareablesUIProvider, {
|
|
72
|
+
config: uiConfig,
|
|
73
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_portal_tenant_product_media_adapter.ProductsApp, {
|
|
74
|
+
countryCode: userData?.country?.iso,
|
|
75
|
+
companyLogoUrl: userData?.company?.logo_url,
|
|
76
|
+
fetchProducts,
|
|
77
|
+
fetchProduct,
|
|
78
|
+
productId,
|
|
79
|
+
onSelectProduct: handleSelectProduct,
|
|
80
|
+
onBack: handleBack
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const productsScreenPropertySchema = {
|
|
88
|
+
widgetType: "ProductsScreen",
|
|
89
|
+
displayName: "Products Screen",
|
|
90
|
+
tabsConfig: [{
|
|
91
|
+
id: "styling",
|
|
92
|
+
label: "Styling"
|
|
93
|
+
}],
|
|
94
|
+
fields: []
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
Object.defineProperty(exports, "ProductsScreen", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function() {
|
|
100
|
+
return ProductsScreen;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(exports, "productsScreenPropertySchema", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function() {
|
|
106
|
+
return productsScreenPropertySchema;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=ProductsScreen-C7cXqLN8.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductsScreen-C7cXqLN8.cjs","names":["useSdkClient","usePortalProductsClient","usePortalTenantClient","useCurrentUser","useAppNavigation","createPortalTenantMediaShareablesAdapter","createPortalTenantPlaylistsShareablesAdapter","createPortalTenantFilesShareablesAdapter","createPortalTenantSharesShareablesAdapter","createPortalTenantProductMediaShareablesAdapter","ShareablesCoreProvider","ShareablesApiProvider","ShareablesUIProvider","ProductsApp"],"sources":["../src/screens/ProductsScreen.tsx"],"sourcesContent":["import { useCallback, useMemo, type ComponentProps } from \"react\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n ColorOptions,\n PaddingOptions,\n} from \"../types\";\nimport type { WidgetPropertySchema } from \"../registries/property-schema-types\";\nimport {\n ShareablesCoreProvider,\n ShareablesApiProvider,\n} from \"@fluid-app/shareables-core\";\nimport { ShareablesUIProvider, ProductsApp } from \"@fluid-app/shareables-ui\";\nimport {\n createPortalTenantMediaShareablesAdapter,\n createPortalTenantPlaylistsShareablesAdapter,\n createPortalTenantFilesShareablesAdapter,\n createPortalTenantSharesShareablesAdapter,\n createPortalTenantProductMediaShareablesAdapter,\n} from \"@fluid-app/shareables-api-client\";\nimport { useCurrentUser } from \"../hooks/use-current-user\";\nimport { useAppNavigation } from \"../shell/AppNavigationContext\";\nimport { useSdkClient } from \"../account/use-account-clients\";\nimport { usePortalTenantClient } from \"../providers/PortalTenantClientProvider\";\nimport { usePortalProductsClient } from \"../products/use-portal-products-client\";\n\ntype ProductsScreenProps = ComponentProps<\"div\"> & {\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n};\n\nexport function ProductsScreen({\n /* eslint-disable @typescript-eslint/no-unused-vars -- destructured to exclude from divProps spread */\n background,\n textColor,\n accentColor,\n padding,\n borderRadius,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ...divProps\n}: ProductsScreenProps): React.JSX.Element {\n const domainClient = useSdkClient();\n const portalProductsApi = usePortalProductsClient();\n const portalTenantClient = usePortalTenantClient();\n const { data: userData } = useCurrentUser();\n const { currentSlug, navigate } = useAppNavigation();\n\n const fetchProducts = useCallback(\n async (search: string, cursor?: string, limit?: number) => {\n if (search) {\n return portalProductsApi.searchProducts(search, { cursor, limit });\n }\n return portalProductsApi.listProducts({ cursor, limit });\n },\n [portalProductsApi],\n );\n\n const fetchProduct = useCallback(\n async (id: string | number) => portalProductsApi.getProduct(id),\n [portalProductsApi],\n );\n\n // Extract product ID from slug: \"products/123\" → \"123\"\n const productId = useMemo(() => {\n const match = currentSlug.match(/^products\\/(.+)/);\n return match?.[1] ?? null;\n }, [currentSlug]);\n\n const handleSelectProduct = useCallback(\n (id: string) => {\n navigate(`products/${id}`);\n },\n [navigate],\n );\n\n const handleBack = useCallback(() => {\n navigate(\"products\");\n }, [navigate]);\n\n const coreConfig = useMemo(\n () => ({\n client: domainClient,\n user: userData ? { id: userData.id } : null,\n repContext: true,\n }),\n [domainClient, userData],\n );\n\n const mediaAdapter = useMemo(\n () => createPortalTenantMediaShareablesAdapter(portalTenantClient),\n [portalTenantClient],\n );\n const playlistsAdapter = useMemo(\n () => createPortalTenantPlaylistsShareablesAdapter(portalTenantClient),\n [portalTenantClient],\n );\n const filesAdapter = useMemo(\n () => createPortalTenantFilesShareablesAdapter(portalTenantClient),\n [portalTenantClient],\n );\n const sharesAdapter = useMemo(\n () => createPortalTenantSharesShareablesAdapter(portalTenantClient),\n [portalTenantClient],\n );\n const productMediaAdapter = useMemo(\n () => createPortalTenantProductMediaShareablesAdapter(portalProductsApi),\n [portalProductsApi],\n );\n\n const uiConfig = useMemo(\n () => ({\n user: userData\n ? {\n id: userData.id,\n company: userData.company\n ? { logo_url: userData.company.logo_url }\n : null,\n }\n : undefined,\n basePath: \"\",\n navigate: (path: string) => {\n navigate(path);\n },\n showToast: (opts: {\n title: string;\n type: \"success\" | \"error\" | \"warning\";\n }) => {\n console.log(`[Products] ${opts.type}: ${opts.title}`);\n },\n }),\n [userData, navigate],\n );\n\n return (\n <div {...divProps} className={`h-full ${divProps.className ?? \"\"}`}>\n <ShareablesCoreProvider config={coreConfig}>\n <ShareablesApiProvider\n media={mediaAdapter}\n playlists={playlistsAdapter}\n fileResources={filesAdapter}\n share={sharesAdapter}\n productMedia={productMediaAdapter}\n >\n <ShareablesUIProvider config={uiConfig}>\n <ProductsApp\n countryCode={userData?.country?.iso}\n companyLogoUrl={userData?.company?.logo_url}\n fetchProducts={fetchProducts}\n fetchProduct={fetchProduct}\n productId={productId}\n onSelectProduct={handleSelectProduct}\n onBack={handleBack}\n />\n </ShareablesUIProvider>\n </ShareablesApiProvider>\n </ShareablesCoreProvider>\n </div>\n );\n}\n\nexport const productsScreenPropertySchema: WidgetPropertySchema = {\n widgetType: \"ProductsScreen\",\n displayName: \"Products Screen\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [],\n} as const satisfies WidgetPropertySchema;\n"],"mappings":";;;;;;;;;;AAkCA,SAAgB,eAAe,EAE7B,YACA,WACA,aACA,SACA,cAEA,GAAG,YACsC;CACzC,MAAM,eAAeA,4BAAAA,cAAc;CACnC,MAAM,oBAAoBC,mCAAAA,yBAAyB;CACnD,MAAM,qBAAqBC,sBAAAA,uBAAuB;CAClD,MAAM,EAAE,MAAM,aAAaC,yBAAAA,gB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AM,YAAA,GAAA,MAAA,gBACG;EACL,MAAM,WACF;GACE,IAAI,SAAS;GACb,SAAS,SAAS,UACd,EAAE,UAAU,SAAS,QAAQ,UAAU,GACvC;GACL,GACD,KAAA;EACJ,UAAU;EACV,WAAW,SAAiB;AAC1B,YAAS,KAAK;;EAEhB,YAAY,SAGN;AACJ,WAAQ,IAAI,cAAc,KAAK,KAAK,IAAI,KAAK,QAAQ;;EAExD,GACD,CAAC,UAAU,SAAS,CACrB;AAED,QACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EAAK,GAAI;EAAU,WAAW,UAAU,SAAS,aAAa;YAC5D,iBAAA,GAAA,kBAAA,KAACC,4CAAAA,wBAAD;GAAwB,QAAQ;aAC9B,iBAAA,GAAA,kBAAA,KAACC,4CAAAA,uBAAD;IACE,OAAO;IACP,WAAW;IACX,eAAe;IACf,OAAO;IACP,cAAc;cAEd,iBAAA,GAAA,kBAAA,KAACC,4CAAAA,sBAAD;KAAsB,QAAQ;eAC5B,iBAAA,GAAA,kBAAA,KAACC,4CAAAA,aAAD;MACE,aAAa,UAAU,SAAS;MAChC,gBAAgB,UAAU,SAAS;MACpB;MACD;MACH;MACX,iBAAiB;MACjB,QAAQ;MACR,CAAA;KACmB,CAAA;IACD,CAAA;GACD,CAAA;EACrB,CAAA;;AAIV,MAAa,+BAAqD;CAChE,YAAY;CACZ,aAAa;CACb,YAAY,CAAC;EAAE,IAAI;EAAW,OAAO;EAAW,CAAC;CACjD,QAAQ,EAAE;CACX"}
|
|
@@ -36,7 +36,7 @@ import "./VideoWidget-D7xoMv5C.mjs";
|
|
|
36
36
|
import "./ScreenHeaderContext-CrdfLGKk.mjs";
|
|
37
37
|
import "./dist-CMGXkSgZ.mjs";
|
|
38
38
|
import "./dist-CayuD99K.mjs";
|
|
39
|
-
import "./
|
|
39
|
+
import "./portal-tenant-product-media-adapter-Co9Kw-US.mjs";
|
|
40
40
|
import "./sortable.esm-BzPsVjTI.mjs";
|
|
41
|
-
import { n as productsScreenPropertySchema, t as ProductsScreen } from "./ProductsScreen-
|
|
41
|
+
import { n as productsScreenPropertySchema, t as ProductsScreen } from "./ProductsScreen-Di6uVQCx.mjs";
|
|
42
42
|
export { ProductsScreen, productsScreenPropertySchema };
|
|
@@ -37,8 +37,8 @@ require("./ScreenHeaderContext-DpVOhFzT.cjs");
|
|
|
37
37
|
require("./dist-BbS_7TvS.cjs");
|
|
38
38
|
require("./es-BSkb3AZk.cjs");
|
|
39
39
|
require("./dist-DkYXiQQ1.cjs");
|
|
40
|
-
require("./
|
|
40
|
+
require("./portal-tenant-product-media-adapter-DM94zJXA.cjs");
|
|
41
41
|
require("./dist-BSbac3uh.cjs");
|
|
42
|
-
const require_ProductsScreen = require("./ProductsScreen-
|
|
42
|
+
const require_ProductsScreen = require("./ProductsScreen-C7cXqLN8.cjs");
|
|
43
43
|
exports.ProductsScreen = require_ProductsScreen.ProductsScreen;
|
|
44
44
|
exports.productsScreenPropertySchema = require_ProductsScreen.productsScreenPropertySchema;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { u as usePortalTenantClient } from "./FluidProvider-Dd2M4mMV.mjs";
|
|
2
|
+
import { n as useCurrentUser } from "./use-current-user-DxFplFVa.mjs";
|
|
3
|
+
import { n as useAppNavigation } from "./AppNavigationContext-Du3Qq0yc.mjs";
|
|
4
|
+
import { i as useSdkClient } from "./use-account-clients-Csy11_yq.mjs";
|
|
5
|
+
import { a as createPortalTenantPlaylistsShareablesAdapter, d as ProductsApp, h as ShareablesCoreProvider, m as ShareablesApiProvider, n as createPortalTenantSharesShareablesAdapter, o as createPortalTenantMediaShareablesAdapter, p as ShareablesUIProvider, r as createPortalTenantFilesShareablesAdapter, t as createPortalTenantProductMediaShareablesAdapter } from "./portal-tenant-product-media-adapter-Co9Kw-US.mjs";
|
|
6
|
+
import { t as usePortalProductsClient } from "./use-portal-products-client-BUTk8CR4.mjs";
|
|
7
|
+
import { useCallback, useMemo } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
//#region src/screens/ProductsScreen.tsx
|
|
10
|
+
function ProductsScreen({ background, textColor, accentColor, padding, borderRadius, ...divProps }) {
|
|
11
|
+
const domainClient = useSdkClient();
|
|
12
|
+
const portalProductsApi = usePortalProductsClient();
|
|
13
|
+
const portalTenantClient = usePortalTenantClient();
|
|
14
|
+
const { data: userData } = useCurrentUser();
|
|
15
|
+
const { currentSlug, navigate } = useAppNavigation();
|
|
16
|
+
const fetchProducts = useCallback(async (search, cursor, limit) => {
|
|
17
|
+
if (search) return portalProductsApi.searchProducts(search, {
|
|
18
|
+
cursor,
|
|
19
|
+
limit
|
|
20
|
+
});
|
|
21
|
+
return portalProductsApi.listProducts({
|
|
22
|
+
cursor,
|
|
23
|
+
limit
|
|
24
|
+
});
|
|
25
|
+
}, [portalProductsApi]);
|
|
26
|
+
const fetchProduct = useCallback(async (id) => portalProductsApi.getProduct(id), [portalProductsApi]);
|
|
27
|
+
const productId = useMemo(() => {
|
|
28
|
+
return currentSlug.match(/^products\/(.+)/)?.[1] ?? null;
|
|
29
|
+
}, [currentSlug]);
|
|
30
|
+
const handleSelectProduct = useCallback((id) => {
|
|
31
|
+
navigate(`products/${id}`);
|
|
32
|
+
}, [navigate]);
|
|
33
|
+
const handleBack = useCallback(() => {
|
|
34
|
+
navigate("products");
|
|
35
|
+
}, [navigate]);
|
|
36
|
+
const coreConfig = useMemo(() => ({
|
|
37
|
+
client: domainClient,
|
|
38
|
+
user: userData ? { id: userData.id } : null,
|
|
39
|
+
repContext: true
|
|
40
|
+
}), [domainClient, userData]);
|
|
41
|
+
const mediaAdapter = useMemo(() => createPortalTenantMediaShareablesAdapter(portalTenantClient), [portalTenantClient]);
|
|
42
|
+
const playlistsAdapter = useMemo(() => createPortalTenantPlaylistsShareablesAdapter(portalTenantClient), [portalTenantClient]);
|
|
43
|
+
const filesAdapter = useMemo(() => createPortalTenantFilesShareablesAdapter(portalTenantClient), [portalTenantClient]);
|
|
44
|
+
const sharesAdapter = useMemo(() => createPortalTenantSharesShareablesAdapter(portalTenantClient), [portalTenantClient]);
|
|
45
|
+
const productMediaAdapter = useMemo(() => createPortalTenantProductMediaShareablesAdapter(portalProductsApi), [portalProductsApi]);
|
|
46
|
+
const uiConfig = useMemo(() => ({
|
|
47
|
+
user: userData ? {
|
|
48
|
+
id: userData.id,
|
|
49
|
+
company: userData.company ? { logo_url: userData.company.logo_url } : null
|
|
50
|
+
} : void 0,
|
|
51
|
+
basePath: "",
|
|
52
|
+
navigate: (path) => {
|
|
53
|
+
navigate(path);
|
|
54
|
+
},
|
|
55
|
+
showToast: (opts) => {
|
|
56
|
+
console.log(`[Products] ${opts.type}: ${opts.title}`);
|
|
57
|
+
}
|
|
58
|
+
}), [userData, navigate]);
|
|
59
|
+
return /* @__PURE__ */ jsx("div", {
|
|
60
|
+
...divProps,
|
|
61
|
+
className: `h-full ${divProps.className ?? ""}`,
|
|
62
|
+
children: /* @__PURE__ */ jsx(ShareablesCoreProvider, {
|
|
63
|
+
config: coreConfig,
|
|
64
|
+
children: /* @__PURE__ */ jsx(ShareablesApiProvider, {
|
|
65
|
+
media: mediaAdapter,
|
|
66
|
+
playlists: playlistsAdapter,
|
|
67
|
+
fileResources: filesAdapter,
|
|
68
|
+
share: sharesAdapter,
|
|
69
|
+
productMedia: productMediaAdapter,
|
|
70
|
+
children: /* @__PURE__ */ jsx(ShareablesUIProvider, {
|
|
71
|
+
config: uiConfig,
|
|
72
|
+
children: /* @__PURE__ */ jsx(ProductsApp, {
|
|
73
|
+
countryCode: userData?.country?.iso,
|
|
74
|
+
companyLogoUrl: userData?.company?.logo_url,
|
|
75
|
+
fetchProducts,
|
|
76
|
+
fetchProduct,
|
|
77
|
+
productId,
|
|
78
|
+
onSelectProduct: handleSelectProduct,
|
|
79
|
+
onBack: handleBack
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const productsScreenPropertySchema = {
|
|
87
|
+
widgetType: "ProductsScreen",
|
|
88
|
+
displayName: "Products Screen",
|
|
89
|
+
tabsConfig: [{
|
|
90
|
+
id: "styling",
|
|
91
|
+
label: "Styling"
|
|
92
|
+
}],
|
|
93
|
+
fields: []
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { productsScreenPropertySchema as n, ProductsScreen as t };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=ProductsScreen-Di6uVQCx.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductsScreen-Di6uVQCx.mjs","names":[],"sources":["../src/screens/ProductsScreen.tsx"],"sourcesContent":["import { useCallback, useMemo, type ComponentProps } from \"react\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n ColorOptions,\n PaddingOptions,\n} from \"../types\";\nimport type { WidgetPropertySchema } from \"../registries/property-schema-types\";\nimport {\n ShareablesCoreProvider,\n ShareablesApiProvider,\n} from \"@fluid-app/shareables-core\";\nimport { ShareablesUIProvider, ProductsApp } from \"@fluid-app/shareables-ui\";\nimport {\n createPortalTenantMediaShareablesAdapter,\n createPortalTenantPlaylistsShareablesAdapter,\n createPortalTenantFilesShareablesAdapter,\n createPortalTenantSharesShareablesAdapter,\n createPortalTenantProductMediaShareablesAdapter,\n} from \"@fluid-app/shareables-api-client\";\nimport { useCurrentUser } from \"../hooks/use-current-user\";\nimport { useAppNavigation } from \"../shell/AppNavigationContext\";\nimport { useSdkClient } from \"../account/use-account-clients\";\nimport { usePortalTenantClient } from \"../providers/PortalTenantClientProvider\";\nimport { usePortalProductsClient } from \"../products/use-portal-products-client\";\n\ntype ProductsScreenProps = ComponentProps<\"div\"> & {\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n};\n\nexport function ProductsScreen({\n /* eslint-disable @typescript-eslint/no-unused-vars -- destructured to exclude from divProps spread */\n background,\n textColor,\n accentColor,\n padding,\n borderRadius,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n ...divProps\n}: ProductsScreenProps): React.JSX.Element {\n const domainClient = useSdkClient();\n const portalProductsApi = usePortalProductsClient();\n const portalTenantClient = usePortalTenantClient();\n const { data: userData } = useCurrentUser();\n const { currentSlug, navigate } = useAppNavigation();\n\n const fetchProducts = useCallback(\n async (search: string, cursor?: string, limit?: number) => {\n if (search) {\n return portalProductsApi.searchProducts(search, { cursor, limit });\n }\n return portalProductsApi.listProducts({ cursor, limit });\n },\n [portalProductsApi],\n );\n\n const fetchProduct = useCallback(\n async (id: string | number) => portalProductsApi.getProduct(id),\n [portalProductsApi],\n );\n\n // Extract product ID from slug: \"products/123\" → \"123\"\n const productId = useMemo(() => {\n const match = currentSlug.match(/^products\\/(.+)/);\n return match?.[1] ?? null;\n }, [currentSlug]);\n\n const handleSelectProduct = useCallback(\n (id: string) => {\n navigate(`products/${id}`);\n },\n [navigate],\n );\n\n const handleBack = useCallback(() => {\n navigate(\"products\");\n }, [navigate]);\n\n const coreConfig = useMemo(\n () => ({\n client: domainClient,\n user: userData ? { id: userData.id } : null,\n repContext: true,\n }),\n [domainClient, userData],\n );\n\n const mediaAdapter = useMemo(\n () => createPortalTenantMediaShareablesAdapter(portalTenantClient),\n [portalTenantClient],\n );\n const playlistsAdapter = useMemo(\n () => createPortalTenantPlaylistsShareablesAdapter(portalTenantClient),\n [portalTenantClient],\n );\n const filesAdapter = useMemo(\n () => createPortalTenantFilesShareablesAdapter(portalTenantClient),\n [portalTenantClient],\n );\n const sharesAdapter = useMemo(\n () => createPortalTenantSharesShareablesAdapter(portalTenantClient),\n [portalTenantClient],\n );\n const productMediaAdapter = useMemo(\n () => createPortalTenantProductMediaShareablesAdapter(portalProductsApi),\n [portalProductsApi],\n );\n\n const uiConfig = useMemo(\n () => ({\n user: userData\n ? {\n id: userData.id,\n company: userData.company\n ? { logo_url: userData.company.logo_url }\n : null,\n }\n : undefined,\n basePath: \"\",\n navigate: (path: string) => {\n navigate(path);\n },\n showToast: (opts: {\n title: string;\n type: \"success\" | \"error\" | \"warning\";\n }) => {\n console.log(`[Products] ${opts.type}: ${opts.title}`);\n },\n }),\n [userData, navigate],\n );\n\n return (\n <div {...divProps} className={`h-full ${divProps.className ?? \"\"}`}>\n <ShareablesCoreProvider config={coreConfig}>\n <ShareablesApiProvider\n media={mediaAdapter}\n playlists={playlistsAdapter}\n fileResources={filesAdapter}\n share={sharesAdapter}\n productMedia={productMediaAdapter}\n >\n <ShareablesUIProvider config={uiConfig}>\n <ProductsApp\n countryCode={userData?.country?.iso}\n companyLogoUrl={userData?.company?.logo_url}\n fetchProducts={fetchProducts}\n fetchProduct={fetchProduct}\n productId={productId}\n onSelectProduct={handleSelectProduct}\n onBack={handleBack}\n />\n </ShareablesUIProvider>\n </ShareablesApiProvider>\n </ShareablesCoreProvider>\n </div>\n );\n}\n\nexport const productsScreenPropertySchema: WidgetPropertySchema = {\n widgetType: \"ProductsScreen\",\n displayName: \"Products Screen\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [],\n} as const satisfies WidgetPropertySchema;\n"],"mappings":";;;;;;;;;AAkCA,SAAgB,eAAe,EAE7B,YACA,WACA,aACA,SACA,cAEA,GAAG,YACsC;CACzC,MAAM,eAAe,cAAc;CACnC,MAAM,oBAAoB,yBAAyB;CACnD,MAAM,qBAAqB,uBAAuB;CAClD,MAAM,EAAE,MAAM,aAAa,gBAAgB;CAC3C,MAAM,EAAE,aAAa,aAAa,kBAAkB;CAEpD,MAAM,gBAAgB,YACpB,OAAO,QAAgB,QAAiB,UAAmB;AACzD,MAAI,OACF,QAAO,kBAAkB,eAAe,QAAQ;GAAE;GAAQ;GAAO,CAAC;AAEpE,SAAO,kBAAkB,aAAa;GAAE;GAAQ;GAAO,CAAC;IAE1D,CAAC,kBAAkB,CACpB;CAED,MAAM,eAAe,YACnB,OAAO,OAAwB,kBAAkB,WAAW,GAAG,EAC/D,CAAC,kBAAkB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