ecommerce 3/3

This commit is contained in:
lovebird 2026-02-18 17:40:45 +01:00
parent 9618998670
commit 6397ab64f4
6 changed files with 1049 additions and 1876 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -69,9 +69,7 @@
"@radix-ui/react-toggle": "^1.1.9",
"@radix-ui/react-toggle-group": "^1.1.10",
"@radix-ui/react-tooltip": "^1.2.7",
"@supabase-cache-helpers/postgrest-swr": "^2.0.3",
"@supabase/supabase-js": "^2.58.0",
"@tanstack/react-query": "^5.83.0",
"@types/dompurify": "^3.2.0",
"@types/file-saver": "^2.0.7",
"@uppy/tus": "^5.0.2",
@ -98,34 +96,22 @@
"openai": "^6.0.0",
"playwright": "^1.55.1",
"prismjs": "^1.30.0",
"react": "^18.3.1",
"react-day-picker": "^8.10.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.61.1",
"react-intersection-observer": "^10.0.0",
"react-markdown": "^10.1.0",
"react-resizable-panels": "^2.1.9",
"react-router-dom": "^6.30.1",
"react-zoom-pan-pinch": "^3.7.0",
"recharts": "^2.15.4",
"replicate": "^1.2.0",
"rollup-plugin-visualizer": "^6.0.5",
"sonner": "^1.7.4",
"stream-browserify": "^3.0.0",
"swr": "^2.3.7",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"vaul": "^0.9.9",
"vite-bundle-analyzer": "^1.3.1",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-pwa": "^1.0.3",
"vue": "^3.5.22",
"workbox-core": "^7.4.0",
"zod": "^3.25.76",
"zod-to-json-schema": "^3.24.6",
"zod-to-json-schema": "^3.24.6"
},
"peerDependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.30.1",
"@tanstack/react-query": "^5.83.0",
"zustand": "^5.0.11"
},
"devDependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.30.1",
"@tanstack/react-query": "^5.83.0",
"zustand": "^5.0.11",
"@eslint/js": "^9.32.0",
"@tailwindcss/typography": "^0.5.16",
"@types/node": "^22.16.5",
@ -149,4 +135,4 @@
"workbox-routing": "^7.4.0",
"workbox-window": "^7.4.0"
}
}
}

View File

@ -1,8 +1,8 @@
import React from "react";
import { Routes, Route, Navigate } from "react-router-dom";
import { useLocation, matchPath, Navigate } from "react-router-dom";
import { CartPage } from "./cart/CartPage";
import { CheckoutFlow, CheckoutFlowProps } from "./checkout/CheckoutFlow";
import { PurchasesList, PurchasesListProps } from "./purchases/PurchasesList";
import { CheckoutFlow } from "./checkout/CheckoutFlow";
import { PurchasesList } from "./purchases/PurchasesList";
import { ShippingPage } from "./policies/ShippingPage";
import { ReturnsPage } from "./policies/ReturnsPage";
import { PrivacyPolicyPage } from "./policies/PrivacyPolicyPage";
@ -31,52 +31,42 @@ export interface EcommerceBundleDependencies {
}
export const EcommerceBundle: React.FC<EcommerceBundleDependencies> = (props) => {
const location = typeof window !== 'undefined' ? window.location : { pathname: '' };
const { pathname } = useLocation();
// Debug logging
React.useEffect(() => {
console.log("EcommerceBundle mounted at:", location.pathname);
}, [location.pathname]);
if (matchPath("/cart/*", pathname)) {
return <CartPage onCheckout={() => props.onNavigate('/checkout')} />;
}
return (
<div className="ecommerce-bundle-root border-2 border-red-500 p-4">
{/* Temporary debug border */}
<div className="bg-yellow-100 p-2 text-xs mb-4">
DEBUG: EcommerceBundle Active. Current Path: {location.pathname}
</div>
if (matchPath("/checkout/*", pathname)) {
return (
<CheckoutFlow
userId={props.user?.id}
userDisplayName={props.user?.user_metadata?.display_name}
userEmail={props.user?.email}
onFetchAddresses={props.onFetchAddresses}
onSaveAddress={props.onSaveAddress}
onPlaceOrder={props.onPlaceOrder}
onBackToCart={() => props.onNavigate('/cart')}
onOrderSuccess={() => props.onNavigate('/purchases')}
toast={props.toast}
/>
);
}
<Routes>
<Route path="/cart" element={<CartPage onCheckout={() => props.onNavigate('/checkout')} />} />
if (matchPath("/purchases/*", pathname)) {
return (
<PurchasesList
onFetchTransactions={props.onFetchTransactions}
onNavigate={props.onNavigate}
toast={props.toast}
/>
);
}
<Route path="/checkout" element={
<CheckoutFlow
userId={props.user?.id}
userDisplayName={props.user?.user_metadata?.display_name}
userEmail={props.user?.email}
onFetchAddresses={props.onFetchAddresses}
onSaveAddress={props.onSaveAddress}
onPlaceOrder={props.onPlaceOrder}
onBackToCart={() => props.onNavigate('/cart')}
onOrderSuccess={() => props.onNavigate('/purchases')}
toast={props.toast}
/>
} />
if (matchPath("/shipping/*", pathname)) return <ShippingPage />;
if (matchPath("/returns/*", pathname)) return <ReturnsPage />;
if (matchPath("/privacy/*", pathname)) return <PrivacyPolicyPage siteName={props.siteName || "PolyMech"} contactEmail={props.contactEmail || "privacy@polymech.org"} />;
if (matchPath("/terms/*", pathname)) return <TermsPage siteName={props.siteName || "PolyMech"} contactEmail={props.contactEmail || "legal@polymech.org"} />;
<Route path="/purchases" element={
<PurchasesList
onFetchTransactions={props.onFetchTransactions}
onNavigate={props.onNavigate}
toast={props.toast}
/>
} />
<Route path="/shipping" element={<ShippingPage />} />
<Route path="/returns" element={<ReturnsPage />} />
<Route path="/privacy" element={<PrivacyPolicyPage siteName={props.siteName || "PolyMech"} contactEmail={props.contactEmail || "privacy@polymech.org"} />} />
<Route path="/terms" element={<TermsPage siteName={props.siteName || "PolyMech"} contactEmail={props.contactEmail || "legal@polymech.org"} />} />
<Route path="*" element={<div className="p-8 text-red-500 font-bold">Ecommerce Bundle 404: No route matched for {location.pathname}</div>} />
</Routes>
</div>
);
return null; // Return null if no route matches (let App.tsx handle 404 if needed, though this component is usually mounted on specific routes)
};

View File

@ -2,7 +2,8 @@
"extends": "./tsconfig.app.json",
"compilerOptions": {
"composite": false,
"noEmit": false
"noEmit": false,
"sourceMap": true
},
"include": [
"src/lib-export.ts"

View File

@ -23,12 +23,17 @@ export default defineConfig({
rollupOptions: {
external: [
'react',
'react/jsx-runtime',
'react-dom',
'react-router-dom',
'@tanstack/react-query',
'@supabase/supabase-js',
'lucide-react', // Icons
'sonner' // Toast
'sonner', // Toast
'zustand',
'zustand/vanilla',
'zustand/react',
'zustand/middleware'
],
},
outDir: 'dist-lib',