{!isFullScreenPage &&
}
@@ -285,13 +214,4 @@ const App = () => {
);
};
-// Update Routes in AppWrapper to include /test-cache/:id
-// ...
-// We need to inject the route inside AppWrapper component defined above
-// Since ReplaceFileContent works on blocks, I'll target the Routes block in a separate call or try to merge.
-// Merging is safer if I can target the App component specifically.
-// But the Routes are in AppWrapper.
-// Let's split this into two edits.
-
-
export default App;
diff --git a/packages/ui/src/bundles/ecommerce.tsx b/packages/ui/src/bundles/ecommerce.tsx
new file mode 100644
index 00000000..9773f4d0
--- /dev/null
+++ b/packages/ui/src/bundles/ecommerce.tsx
@@ -0,0 +1,72 @@
+import React from "react";
+import { useNavigate } from "react-router-dom";
+import { useAuth } from "@/hooks/useAuth";
+
+const EcommerceBundle = React.lazy(() => import("@polymech/ecommerce").then(m => ({ default: m.EcommerceBundle })));
+
+export const EcommerceBundleWrapper = () => {
+ const { user } = useAuth();
+ const navigate = useNavigate();
+
+ // Memoize dependencies to prevent re-renders
+ const dependencies = React.useMemo(() => {
+ return {
+ user: user ? {
+ id: user.id,
+ email: user.email,
+ user_metadata: {
+ display_name: user.user_metadata?.display_name
+ }
+ } : null,
+ toast: {
+ success: (msg: string) => import('sonner').then(s => s.toast.success(msg)),
+ error: (msg: string) => import('sonner').then(s => s.toast.error(msg))
+ },
+ onFetchAddresses: async (userId: string) => {
+ const { getShippingAddresses } = await import('@/modules/user/client-user');
+ return getShippingAddresses(userId) as Promise
;
+ },
+ onSaveAddress: async (userId: string, addresses: any[]) => {
+ const { saveShippingAddresses } = await import('@/modules/user/client-user');
+ await saveShippingAddresses(userId, addresses);
+ },
+ onPlaceOrder: async (data: any) => {
+ const { useCartStore } = await import('@polymech/ecommerce');
+ const { createTransaction } = await import('@/modules/ecommerce/client-ecommerce');
+ const items = useCartStore.getState().items;
+ const subtotal = useCartStore.getState().subtotal;
+
+ await createTransaction({
+ shipping_info: data.shipping,
+ vendor_info: {},
+ product_info: items.map((i: any) => ({
+ id: i.id,
+ title: i.title,
+ image: i.image,
+ price: i.price,
+ quantity: i.quantity,
+ variant: i.variant,
+ vendorSlug: i.vendorSlug,
+ pageSlug: i.pageSlug,
+ })),
+ total_amount: subtotal,
+ payment_provider: data.paymentMethod,
+ });
+ useCartStore.getState().clearCart();
+ },
+ onFetchTransactions: async () => {
+ const { listTransactions } = await import('@/modules/ecommerce/client-ecommerce');
+ return listTransactions();
+ },
+ onNavigate: (path: string) => navigate(path),
+ siteName: "PolyMech",
+ contactEmail: "legal@polymech.org"
+ };
+ }, [user, navigate]);
+
+ return (
+ Loading... }>
+