Compare commits

..

7 Commits

Author SHA1 Message Date
Mihir Motiyani 4e81ee7774 Merge pull request 'feat: show product photos and let staff upload them' (#33) from feat/product-images into main
continuous-integration/drone/push Build is passing Details
Reviewed-on: #33
2026-11-26 13:12:02 +05:30
mihir 8cd2145f06 feat: show product photos and let staff upload them
continuous-integration/drone/push Build is passing Details
Catalog cards show each product's main photo and product pages show the gallery. Admin catalog adds a Photos panel to upload (JPEG/PNG/WebP, 2 MiB, up to 8) and remove photos. Nginx allows the upload size on the new route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 12:42:50 +05:30
Mihir Motiyani 10f795ebed Merge pull request 'feat: let customers create an account from the sign-in page' (#32) from feat/customer-registration into main
continuous-integration/drone/push Build is passing Details
Reviewed-on: #32
2026-11-26 01:15:00 +05:30
mihir bee6281dde feat: let customers create an account from the sign-in page
continuous-integration/drone/push Build is passing Details
Adds a sign-up mode to /workspace that calls POST /auth/register and adopts the returned session through the same checks as sign-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:41:25 +05:30
Mihir Motiyani 2d8c162834 Merge pull request 'fix/staging-hardening' (#31) from fix/staging-hardening into main
continuous-integration/drone/push Build is passing Details
Reviewed-on: #31
2026-11-24 15:58:10 +05:30
mihir 24b2686f7e test: allow slow CI runners 20s for multi-step UI workflows
continuous-integration/drone/push Build is passing Details
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 15:46:42 +05:30
mihir 9f644c2e15 fix: forward client IPs to the API and patch dependency advisories
continuous-integration/drone/push Build is failing Details
- Nginx appends X-Forwarded-For on /api so the backend can rate-limit
  per visitor instead of per proxy (requires backend TRUST_PROXY).
- Replace the placeholder Replit meta description.
- npm audit fix: zero reported vulnerabilities.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 15:30:22 +05:30
17 changed files with 503 additions and 279 deletions

View File

@ -27,9 +27,9 @@ docker run --rm -p 8080:80 manicandles-frontend:uat
After the one-time [server setup](docs/STATIC-DEPLOYMENT.md), main-branch Drone pushes upload the checked static build over SSH and activate it through the existing Nginx HTTPS site. Readiness failure restores the previous release. Drone requires the `manicandles_deploy_key` secret. Feature branches run validation without uploading or activating a release. After the one-time [server setup](docs/STATIC-DEPLOYMENT.md), main-branch Drone pushes upload the checked static build over SSH and activate it through the existing Nginx HTTPS site. Readiness failure restores the previous release. Drone requires the `manicandles_deploy_key` secret. Feature branches run validation without uploading or activating a release.
Storefront list returns only id/name/slug; details return prices/attributes/groups. The API has no product-media fields, so catalog cards use a generic branded placeholder rather than assigning local photos to unknown records. Existing marketing imagery remains intact. Storefront list returns id/name/slug and the main photo; details return prices/attributes/groups and all photos. Staff upload up to 8 JPEG/PNG/WebP photos per product (2 MiB each) under Admin catalog; products without photos show a branded placeholder. Existing marketing imagery remains intact.
Addresses, cart/checkout, orders, catalog, access, stock, coupons and pricing tools are available after sign-in. Public registration and procurement/production/B2B tools remain subsequent phases. There is no contact-message endpoint; simulated success was replaced with an availability notice. Newsletter signup awaits consent/messaging flows. Addresses, cart/checkout, orders, catalog, access, stock, coupons and pricing tools are available after sign-in. Customers can create their own account at `/workspace` (requires the backend `/auth/register` endpoint). There is no contact-message endpoint; simulated success was replaced with an availability notice. Newsletter signup awaits consent/messaging flows.
See [delivery phases](docs/PHASES.md) and [UAT evidence](docs/UAT-RESULTS.md). See [delivery phases](docs/PHASES.md) and [UAT evidence](docs/UAT-RESULTS.md).

View File

@ -16,12 +16,14 @@ location /api/ {
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt; proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
proxy_set_header Host manicandles-backend.midastix.com; proxy_set_header Host manicandles-backend.midastix.com;
proxy_set_header Authorization $http_authorization; proxy_set_header Authorization $http_authorization;
# The backend rate-limits per client IP; it trusts this hop via TRUST_PROXY.
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 10s; proxy_connect_timeout 10s;
proxy_read_timeout 20s; proxy_read_timeout 20s;
proxy_hide_header Access-Control-Allow-Origin; proxy_hide_header Access-Control-Allow-Origin;
proxy_hide_header Access-Control-Allow-Credentials; proxy_hide_header Access-Control-Allow-Credentials;
location ~ "^/api/v1/(?:supplier-documents|b2b/artworks)/[0-9a-fA-F-]{36}/versions$" { location ~ "^/api/v1/(?:(?:supplier-documents|b2b/artworks)/[0-9a-fA-F-]{36}/versions|products/[0-9a-fA-F-]{36}/images)$" {
client_max_body_size 3m; client_max_body_size 3m;
proxy_pass https://manicandles-backend.midastix.com; proxy_pass https://manicandles-backend.midastix.com;
} }

View File

@ -38,4 +38,4 @@ Record the active and previous build/commit release IDs before rollout. The SSH
## Operational limits ## Operational limits
Pending intents exist only within the active browser session; reloading signs out and discards them. After interruption, inspect orders or the stock ledger before beginning a new intent. The backend currently has no live gateway/carrier, public registration or contact delivery. Staff catalog/role writes follow the backend's existing concurrency policy; coordinate overlapping administration edits. Never reinterpret finalized merchandise as proof of payment or fulfillment. Pending intents exist only within the active browser session; reloading signs out and discards them. After interruption, inspect orders or the stock ledger before beginning a new intent. The backend currently has no live gateway/carrier or contact delivery; customer self-registration is available. Staff catalog/role writes follow the backend's existing concurrency policy; coordinate overlapping administration edits. Never reinterpret finalized merchandise as proof of payment or fulfillment.

View File

@ -4,14 +4,14 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
<title>Mani Candles Co.</title> <title>Mani Candles Co.</title>
<meta name="description" content="Mani Candles Co. — built on Replit. Update this description to reflect the app." /> <meta name="description" content="Handmade luxury candles from Mani Candles Co., poured in small batches." />
<meta name="robots" content="index, follow" /> <meta name="robots" content="index, follow" />
<meta property="og:title" content="Mani Candles Co." /> <meta property="og:title" content="Mani Candles Co." />
<meta property="og:description" content="Mani Candles Co. — built on Replit. Update this description to reflect the app." /> <meta property="og:description" content="Handmade luxury candles from Mani Candles Co., poured in small batches." />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Mani Candles Co." /> <meta name="twitter:title" content="Mani Candles Co." />
<meta name="twitter:description" content="Mani Candles Co. — built on Replit. Update this description to reflect the app." /> <meta name="twitter:description" content="Handmade luxury candles from Mani Candles Co., poured in small batches." />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

View File

@ -16,12 +16,14 @@ server {
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt; proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
proxy_set_header Host manicandles-backend.midastix.com; proxy_set_header Host manicandles-backend.midastix.com;
proxy_set_header Authorization $http_authorization; proxy_set_header Authorization $http_authorization;
# The backend rate-limits per client IP; it trusts this hop via TRUST_PROXY.
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 10s; proxy_connect_timeout 10s;
proxy_read_timeout 20s; proxy_read_timeout 20s;
proxy_hide_header Access-Control-Allow-Origin; proxy_hide_header Access-Control-Allow-Origin;
proxy_hide_header Access-Control-Allow-Credentials; proxy_hide_header Access-Control-Allow-Credentials;
location ~ "^/api/v1/(?:supplier-documents|b2b/artworks)/[0-9a-fA-F-]{36}/versions$" { location ~ "^/api/v1/(?:(?:supplier-documents|b2b/artworks)/[0-9a-fA-F-]{36}/versions|products/[0-9a-fA-F-]{36}/images)$" {
client_max_body_size 3m; client_max_body_size 3m;
proxy_pass https://manicandles-backend.midastix.com; proxy_pass https://manicandles-backend.midastix.com;
} }

178
package-lock.json generated
View File

@ -1265,15 +1265,15 @@
} }
}, },
"node_modules/@eslint/config-array": { "node_modules/@eslint/config-array": {
"version": "0.23.5", "version": "0.23.6",
"resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.5.tgz", "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.6.tgz",
"integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==", "integrity": "sha512-WrTH7nioI9QPY4NZGnsywmecswJdgeq4BCM76qok9VgjTO29ZgUzUvcuJLVPYVQM4uDbaPBU0M33R9DIxI8X3w==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@eslint/object-schema": "^3.0.5", "@eslint/object-schema": "^3.0.5",
"debug": "^4.3.1", "debug": "^4.3.1",
"minimatch": "^10.2.4" "minimatch": "^11.0.5"
}, },
"engines": { "engines": {
"node": "^20.19.0 || ^22.13.0 || >=24" "node": "^20.19.0 || ^22.13.0 || >=24"
@ -1486,6 +1486,13 @@
"url": "https://github.com/sponsors/nzakas" "url": "https://github.com/sponsors/nzakas"
} }
}, },
"node_modules/@isaacs/nonrecursive-glob-match": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz",
"integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==",
"dev": true,
"license": "BlueOak-1.0.0"
},
"node_modules/@jridgewell/gen-mapping": { "node_modules/@jridgewell/gen-mapping": {
"version": "0.3.13", "version": "0.3.13",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
@ -4283,17 +4290,17 @@
} }
}, },
"node_modules/@typescript-eslint/eslint-plugin": { "node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.72.2.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.74.0.tgz",
"integrity": "sha512-222PKFXKihmFpi/pS5njoBgdAqsPhj2/GBmFbrNw8Tq8gEG9Sv+kSlKFy4u2q+mJv9ZzJgM2Gkv/bUzRZwZw5g==", "integrity": "sha512-z3KXk1+Vm+d82ZRplOoC89ho4Rf1da5ju6sx8//92GnN532U62DGPjECXkkVqtYzIv0zoJlpO39SX2Z9tk6LVw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@eslint-community/regexpp": "^4.12.2", "@eslint-community/regexpp": "^4.12.2",
"@typescript-eslint/scope-manager": "8.72.2", "@typescript-eslint/scope-manager": "8.74.0",
"@typescript-eslint/type-utils": "8.72.2", "@typescript-eslint/type-utils": "8.74.0",
"@typescript-eslint/utils": "8.72.2", "@typescript-eslint/utils": "8.74.0",
"@typescript-eslint/visitor-keys": "8.72.2", "@typescript-eslint/visitor-keys": "8.74.0",
"ignore": "^7.0.5", "ignore": "^7.0.5",
"natural-compare": "^1.4.0", "natural-compare": "^1.4.0",
"ts-api-utils": "^2.5.0" "ts-api-utils": "^2.5.0"
@ -4306,15 +4313,15 @@
"url": "https://opencollective.com/typescript-eslint" "url": "https://opencollective.com/typescript-eslint"
}, },
"peerDependencies": { "peerDependencies": {
"@typescript-eslint/parser": "^8.72.2", "@typescript-eslint/parser": "^8.74.0",
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
"typescript": ">=4.8.4 <6.1.0" "typescript": ">=4.8.4 <6.1.0"
} }
}, },
"node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": {
"version": "7.0.14", "version": "7.0.16",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz", "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.16.tgz",
"integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==", "integrity": "sha512-52N+Y4HRMOJmbLmr+DqO4iSRyyB7N52gm7PWCT6h0p978+oKbqHCB7gIJIwZvBUsjlSdWbrBFqUSmIFNZMpn0A==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@ -4322,16 +4329,16 @@
} }
}, },
"node_modules/@typescript-eslint/parser": { "node_modules/@typescript-eslint/parser": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.72.2.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.74.0.tgz",
"integrity": "sha512-llP+T1YuJOLlxEciP6OyQGtz5SMxyn+9LA2BvZw5RmToGVa1y4beEDVQL6Gje7T5WFYh19WREjDCN9Ev4gm5AA==", "integrity": "sha512-ecr8AYdig7avVkxaHdQvxHnIJ/mOyliO4Gv/uWF8q69vBew/z3sexqBwHUZX5Vql+Ns0w4sH6gBLkICGbOvJkA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "8.72.2", "@typescript-eslint/scope-manager": "8.74.0",
"@typescript-eslint/types": "8.72.2", "@typescript-eslint/types": "8.74.0",
"@typescript-eslint/typescript-estree": "8.72.2", "@typescript-eslint/typescript-estree": "8.74.0",
"@typescript-eslint/visitor-keys": "8.72.2", "@typescript-eslint/visitor-keys": "8.74.0",
"debug": "^4.4.3" "debug": "^4.4.3"
}, },
"engines": { "engines": {
@ -4347,14 +4354,14 @@
} }
}, },
"node_modules/@typescript-eslint/project-service": { "node_modules/@typescript-eslint/project-service": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.72.2.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.74.0.tgz",
"integrity": "sha512-6y5dLTZdHhI8Eh3yIQ/bfQhRKwn5e+TpJj64o18Cngc0iW/BCrVvrr6zGYqXPnYH31u6YXAYiFh0+qxX5mybJw==", "integrity": "sha512-z/mymuE+JlEeSFIv3Mo70EvgG1Zz74Hl0IDfExfXutARAP834bt+MppTD7mVAwmZO0GdxdOAi0jbTam749eH6g==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/tsconfig-utils": "^8.72.2", "@typescript-eslint/tsconfig-utils": "^8.74.0",
"@typescript-eslint/types": "^8.72.2", "@typescript-eslint/types": "^8.74.0",
"debug": "^4.4.3" "debug": "^4.4.3"
}, },
"engines": { "engines": {
@ -4369,14 +4376,14 @@
} }
}, },
"node_modules/@typescript-eslint/scope-manager": { "node_modules/@typescript-eslint/scope-manager": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.72.2.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.74.0.tgz",
"integrity": "sha512-iIoMJ6/8c1/QpFNyFjU0d1YzPco4MsZjQw0k3V+vfzNWAFmUmvhlyMoYEoYYDQZXc+J6Gi1X5XcxlzW2taIIGQ==", "integrity": "sha512-kpOdpu4CpWN5U38ox3f727DwWRBtUAVhyUJtqTBYe5gf2wYoxac7PgKP14txrxN7ICVtcjlLdzjqfRgpSnDKvQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.72.2", "@typescript-eslint/types": "8.74.0",
"@typescript-eslint/visitor-keys": "8.72.2" "@typescript-eslint/visitor-keys": "8.74.0"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@ -4387,9 +4394,9 @@
} }
}, },
"node_modules/@typescript-eslint/tsconfig-utils": { "node_modules/@typescript-eslint/tsconfig-utils": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.72.2.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.74.0.tgz",
"integrity": "sha512-+h3iCgZXuTNtoLXcnnjP12ZUHLMqoUcIHPfQrFEXTUqvb9dF8QK9b5nv5VtSo5fLkdHuks8ehbTzZj3rImAm9w==", "integrity": "sha512-p07wAuaS6BjCYgOSXKJi4YhvTnAf7fiG37e9THcpnYaQEt2QiTTYZWKwUFNgeRiywiMudazhzgddAirZ0GgHtQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@ -4404,15 +4411,15 @@
} }
}, },
"node_modules/@typescript-eslint/type-utils": { "node_modules/@typescript-eslint/type-utils": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.72.2.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.74.0.tgz",
"integrity": "sha512-STfkR38qIdhfkLpgtXnUjAzsNy4xouqiBO0lrVc/Wpk9Kem5/aHXUx1J8dGC16zpdYN1+yc2ILQ28er1kXX7ag==", "integrity": "sha512-CV3Y3la8l3F9ANfxcfpgSSiQgJTe4IeLEoZV4O/gcW86Ugp8X6SKiQ0vm+QegXaRIbbDMokZZSF3A1CgiU/kPw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.72.2", "@typescript-eslint/types": "8.74.0",
"@typescript-eslint/typescript-estree": "8.72.2", "@typescript-eslint/typescript-estree": "8.74.0",
"@typescript-eslint/utils": "8.72.2", "@typescript-eslint/utils": "8.74.0",
"debug": "^4.4.3", "debug": "^4.4.3",
"ts-api-utils": "^2.5.0" "ts-api-utils": "^2.5.0"
}, },
@ -4429,9 +4436,9 @@
} }
}, },
"node_modules/@typescript-eslint/types": { "node_modules/@typescript-eslint/types": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.72.2.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.74.0.tgz",
"integrity": "sha512-Xfn37OLZx03+PCU7qWx9DTv2FCRh1E6fk2+wONeNY15HXIwtcwuveaSwVpGAUptkNmPQegRxW5JyRel9T7wrog==", "integrity": "sha512-MpnMrJCVNpP1iVL8NiHkQZgQqIMBH5ewDGUPBh1pqQXwFtMFjsl1M03QcYPXmv6stCKEiF0PN7CGbU1ZbXFzEA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {
@ -4443,18 +4450,18 @@
} }
}, },
"node_modules/@typescript-eslint/typescript-estree": { "node_modules/@typescript-eslint/typescript-estree": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.72.2.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.74.0.tgz",
"integrity": "sha512-pQEGqIK/cqEvKivVWaFLYpe7XYejFxfuAOi4mu1oAWFvIo36aRHI9esRFTUxcIy/z8N482RJyH+LpZB0ZIU7Ow==", "integrity": "sha512-wL348k6l92DNG+kPP5rVpKwNBoz7a3xRZy3TPKc1uymQttd7u7gcMv3eENmcuh4CjC4mO3FTM0DYstFXMyDLuw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/project-service": "8.72.2", "@typescript-eslint/project-service": "8.74.0",
"@typescript-eslint/tsconfig-utils": "8.72.2", "@typescript-eslint/tsconfig-utils": "8.74.0",
"@typescript-eslint/types": "8.72.2", "@typescript-eslint/types": "8.74.0",
"@typescript-eslint/visitor-keys": "8.72.2", "@typescript-eslint/visitor-keys": "8.74.0",
"debug": "^4.4.3", "debug": "^4.4.3",
"minimatch": "^10.2.2", "minimatch": "^11.0.1",
"semver": "^7.7.3", "semver": "^7.7.3",
"tinyglobby": "^0.2.15", "tinyglobby": "^0.2.15",
"ts-api-utils": "^2.5.0" "ts-api-utils": "^2.5.0"
@ -4467,7 +4474,13 @@
"url": "https://opencollective.com/typescript-eslint" "url": "https://opencollective.com/typescript-eslint"
}, },
"peerDependencies": { "peerDependencies": {
"@typescript/native": "npm:typescript@>=7.1.0-dev.20261009.1 || >=7.1.0-beta <7.1.0-dev",
"typescript": ">=4.8.4 <6.1.0" "typescript": ">=4.8.4 <6.1.0"
},
"peerDependenciesMeta": {
"@typescript/native": {
"optional": true
}
} }
}, },
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
@ -4484,16 +4497,16 @@
} }
}, },
"node_modules/@typescript-eslint/utils": { "node_modules/@typescript-eslint/utils": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.72.2.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.74.0.tgz",
"integrity": "sha512-hv3eRYbpPbbpezuax1EfGrzpa3C4ySgNZkPUkLOWOAjU8HsOKowEDAr8C7nsNl1C+SBSKDpvno6VKHnlhvp9iA==", "integrity": "sha512-IpWXPxXXomzxyTcvjhZJexgdvtTR1TooLAPpuxzaGqQ8BHll1lf4Ysp/BTE/l0U5TJ+x1j7B4bEM8pLRrvY+XA==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.9.1", "@eslint-community/eslint-utils": "^4.9.1",
"@typescript-eslint/scope-manager": "8.72.2", "@typescript-eslint/scope-manager": "8.74.0",
"@typescript-eslint/types": "8.72.2", "@typescript-eslint/types": "8.74.0",
"@typescript-eslint/typescript-estree": "8.72.2" "@typescript-eslint/typescript-estree": "8.74.0"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@ -4508,13 +4521,13 @@
} }
}, },
"node_modules/@typescript-eslint/visitor-keys": { "node_modules/@typescript-eslint/visitor-keys": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.72.2.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.74.0.tgz",
"integrity": "sha512-NAGrjn0Pitjqzq/GkgMC4kBYm233PQ8GffyQ9+kTA3AlNQYEzOf25EIM02BAHZv5FRJSpHpJk+OGUxVkOB93GQ==", "integrity": "sha512-XSZmOtMUbWCBIM+2BK134FyMFxmll1mW2mPLk/PSwYQYzGIPMgJAqL929U4qXVizLv7Xq5b7r41/o7Ombuwk0g==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/types": "8.72.2", "@typescript-eslint/types": "8.74.0",
"eslint-visitor-keys": "^5.0.0" "eslint-visitor-keys": "^5.0.0"
}, },
"engines": { "engines": {
@ -4753,9 +4766,9 @@
} }
}, },
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "5.0.12", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.1.0.tgz",
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", "integrity": "sha512-aa11Dv491GKnYqxaul3aRJ0szew7yMJMfZPnqD44NjGrZXoj62l41OEDDpdpC4eE2P88vBFfLuSyRhpG91NUvg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@ -5372,9 +5385,9 @@
} }
}, },
"node_modules/eslint": { "node_modules/eslint": {
"version": "10.14.0", "version": "10.15.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-10.14.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-10.15.0.tgz",
"integrity": "sha512-T0pNsxkb9IKmtQjhpK3d7nWOpFv+YHuMbTJnSVMoQblF0onvXfErrtp4V1jHtsQPan7dKaGVD0q1WCXnzMF31A==", "integrity": "sha512-+5Wg4p+ze3sG1WErYgUO/3H1IQIfFBymVUA0Fo/XTeBOLS6UQIUekpSJ8sdRkn7O7wjh84b55w/roqavH2aScg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"workspaces": [ "workspaces": [
@ -5383,7 +5396,7 @@
"dependencies": { "dependencies": {
"@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/eslint-utils": "^4.8.0",
"@eslint-community/regexpp": "^4.12.2", "@eslint-community/regexpp": "^4.12.2",
"@eslint/config-array": "^0.23.5", "@eslint/config-array": "^0.23.6",
"@eslint/config-helpers": "^0.7.0", "@eslint/config-helpers": "^0.7.0",
"@eslint/core": "^1.2.1", "@eslint/core": "^1.2.1",
"@eslint/plugin-kit": "^0.7.3", "@eslint/plugin-kit": "^0.7.3",
@ -5408,7 +5421,7 @@
"imurmurhash": "^0.1.4", "imurmurhash": "^0.1.4",
"is-glob": "^4.0.0", "is-glob": "^4.0.0",
"json-stable-stringify-without-jsonify": "^1.0.1", "json-stable-stringify-without-jsonify": "^1.0.1",
"minimatch": "^10.2.6", "minimatch": "^11.0.5",
"natural-compare": "^1.4.0", "natural-compare": "^1.4.0",
"optionator": "^0.9.3" "optionator": "^0.9.3"
}, },
@ -6469,16 +6482,17 @@
"license": "CC0-1.0" "license": "CC0-1.0"
}, },
"node_modules/minimatch": { "node_modules/minimatch": {
"version": "10.2.6", "version": "11.0.9",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz",
"integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", "integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==",
"dev": true, "dev": true,
"license": "BlueOak-1.0.0", "license": "BlueOak-1.0.0",
"dependencies": { "dependencies": {
"brace-expansion": "^5.0.8" "@isaacs/nonrecursive-glob-match": "^1.1.0",
"brace-expansion": "^5.0.12"
}, },
"engines": { "engines": {
"node": "18 || 20 || >=22" "node": "20 || >=22"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/isaacs" "url": "https://github.com/sponsors/isaacs"
@ -7510,16 +7524,16 @@
} }
}, },
"node_modules/typescript-eslint": { "node_modules/typescript-eslint": {
"version": "8.72.2", "version": "8.74.0",
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.72.2.tgz", "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.74.0.tgz",
"integrity": "sha512-c/+AKMW1KB81r28Sp0AAdcyXj5dzNmAsZFcsrxKbZTKmcBK2xIwBR31dcSYSDu3bKmzXe8GKrSxO+eDQ401Uzg==", "integrity": "sha512-OsWQlsedt1ZpZXfZZMNK3m4SoQONFFcy4h/uRznsCeRfVuEic3gh4KGUs2pJJ5o0Jj0Jr7keUHQGN1Ns9aDw7Q==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@typescript-eslint/eslint-plugin": "8.72.2", "@typescript-eslint/eslint-plugin": "8.74.0",
"@typescript-eslint/parser": "8.72.2", "@typescript-eslint/parser": "8.74.0",
"@typescript-eslint/typescript-estree": "8.72.2", "@typescript-eslint/typescript-estree": "8.74.0",
"@typescript-eslint/utils": "8.72.2" "@typescript-eslint/utils": "8.74.0"
}, },
"engines": { "engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"

View File

@ -4,7 +4,7 @@ import Alert from "@mui/material/Alert";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import Skeleton from "@mui/material/Skeleton"; import Skeleton from "@mui/material/Skeleton";
import { Flame } from "lucide-react"; import { Flame } from "lucide-react";
import { listProducts } from "@/lib/api"; import { listProducts, productImageUrl } from "@/lib/api";
import { usePlatform } from "@/lib/platform"; import { usePlatform } from "@/lib/platform";
import { ApiNotice } from "./ApiNotice"; import { ApiNotice } from "./ApiNotice";
import "@/pages/products.css"; import "@/pages/products.css";
@ -75,11 +75,21 @@ export function Catalog({
<article className="prod-card" key={product.id}> <article className="prod-card" key={product.id}>
<Link <Link
href={`/products/${product.id}`} href={`/products/${product.id}`}
className="prod-img-wrap catalog-placeholder" className={`prod-img-wrap${product.images[0] ? "" : " catalog-placeholder"}`}
aria-label={`View ${product.name}`} aria-label={`View ${product.name}`}
> >
<Flame size={48} aria-hidden="true" /> {product.images[0] ? (
<span>Mani Candles</span> <img
src={productImageUrl(organization, product.id, product.images[0].id)}
alt=""
loading="lazy"
/>
) : (
<>
<Flame size={48} aria-hidden="true" />
<span>Mani Candles</span>
</>
)}
</Link> </Link>
<div className="prod-info"> <div className="prod-info">
<h3 className="prod-name"> <h3 className="prod-name">

View File

@ -5,7 +5,15 @@ const productSummarySchema = z.object({
id: z.string().uuid(), id: z.string().uuid(),
name: z.string(), name: z.string(),
slug: z.string(), slug: z.string(),
images: z.array(z.object({ id: z.string().uuid() })).default([]),
}); });
export function productImageUrl(
organization: string,
productId: string,
imageId: string,
) {
return `/api/v1/storefront/${organization}/products/${productId}/images/${imageId}`;
}
export const productSchema = productSummarySchema.extend({ export const productSchema = productSummarySchema.extend({
description: z.string(), description: z.string(),
variants: z.array( variants: z.array(
@ -235,6 +243,21 @@ export async function login(
}), }),
); );
} }
export async function register(
organizationId: string,
name: string,
email: string,
password: string,
) {
const organization = organizationSchema.parse(organizationId);
return parse(
sessionSchema,
await apiRequest("/auth/register", {
method: "POST",
body: { organizationId: organization, name, email, password },
}),
);
}
export async function getPrincipal(token: string) { export async function getPrincipal(token: string) {
return parse(principalSchema, await apiRequest("/auth/me", { token })); return parse(principalSchema, await apiRequest("/auth/me", { token }));
} }

View File

@ -154,8 +154,26 @@ export const adminProductSummary = productInput
.pick({ name: true, slug: true }) .pick({ name: true, slug: true })
.extend({ id: uuid, status: z.enum(["DRAFT", "PUBLISHED", "ARCHIVED"]) }) .extend({ id: uuid, status: z.enum(["DRAFT", "PUBLISHED", "ARCHIVED"]) })
.strip(); .strip();
export const productImage = z
.object({
id: uuid,
mimeType: z.enum(["image/jpeg", "image/png", "image/webp"]),
size: z.number().int().positive(),
})
.strip();
export const productImageAccept = "image/jpeg,image/png,image/webp";
export function prepareProductImage(file: FormDataEntryValue | null) {
if (!(file instanceof File) || !file.size) throw new Error("Choose a JPEG, PNG or WebP photo.");
if (file.size > 2 * 1024 * 1024) throw new Error("Choose a photo up to 2 MiB.");
if (!productImageAccept.split(",").includes(file.type))
throw new Error("Use a JPEG, PNG or WebP photo.");
const body = new FormData();
body.append("file", file);
return body;
}
export const adminProduct = adminProductSummary.extend({ export const adminProduct = adminProductSummary.extend({
description: z.string(), description: z.string(),
images: z.array(productImage).default([]),
variants: z.array(variant), variants: z.array(variant),
groups: z.array(z.object({ group })), groups: z.array(z.object({ group })),
}); });

View File

@ -18,6 +18,7 @@ import {
login, login,
organizationSchema, organizationSchema,
parse, parse,
register,
type Principal, type Principal,
type Session, type Session,
} from "./api"; } from "./api";
@ -29,6 +30,7 @@ const PlatformContext = createContext<{
principal: Principal | null; principal: Principal | null;
scope: string; scope: string;
signIn: (email: string, password: string) => Promise<void>; signIn: (email: string, password: string) => Promise<void>;
signUp: (name: string, email: string, password: string) => Promise<void>;
signOut: () => Promise<void>; signOut: () => Promise<void>;
notice: string; notice: string;
clearSession: (notice?: string) => void; clearSession: (notice?: string) => void;
@ -110,9 +112,15 @@ export function PlatformProvider({ children }: { children: ReactNode }) {
/* The in-memory setting still works. */ /* The in-memory setting still works. */
} }
} }
async function signIn(email: string, password: string) { function signIn(email: string, password: string) {
return adopt(() => login(organization, email, password));
}
function signUp(name: string, email: string, password: string) {
return adopt(() => register(organization, name, email, password));
}
async function adopt(start: () => ReturnType<typeof login>) {
const version = ++generation.current; const version = ++generation.current;
const next = await login(organization, email, password); const next = await start();
try { try {
const me = await getPrincipal(next.accessToken); const me = await getPrincipal(next.accessToken);
if ( if (
@ -247,6 +255,7 @@ export function PlatformProvider({ children }: { children: ReactNode }) {
principal, principal,
scope: principal ? `${principal.sessionId}:${accessRevision}` : "", scope: principal ? `${principal.sessionId}:${accessRevision}` : "",
signIn, signIn,
signUp,
signOut, signOut,
notice, notice,
clearSession, clearSession,

View File

@ -12,6 +12,9 @@ import {
group, group,
groupInput, groupInput,
money, money,
prepareProductImage,
productImage,
productImageAccept,
type AdminProduct, type AdminProduct,
uuid, uuid,
} from "@/lib/commerce"; } from "@/lib/commerce";
@ -31,6 +34,8 @@ import {
} from "@/components/WorkspaceTools"; } from "@/components/WorkspaceTools";
import { RecordSelection } from "@/components/RecordSelection"; import { RecordSelection } from "@/components/RecordSelection";
import { ConfirmAction } from "@/components/ConfirmAction"; import { ConfirmAction } from "@/components/ConfirmAction";
import { productImageUrl } from "@/lib/api";
import "./products.css";
function ProductForm({ function ProductForm({
item, item,
onSave, onSave,
@ -323,8 +328,10 @@ function Products() {
); );
} }
function ProductEditor({ id }: { id: string }) { function ProductEditor({ id }: { id: string }) {
const { request, can } = usePlatform(); const { request, can, organization } = usePlatform();
const query = usePrivateQuery(`/products/${id}`, adminProduct); const query = usePrivateQuery(`/products/${id}`, adminProduct);
const editable = (item: AdminProduct) =>
can("catalog.manage") && item.status !== "ARCHIVED";
const [editingVariant, setEditingVariant] = useState< const [editingVariant, setEditingVariant] = useState<
z.infer<typeof variant> | undefined z.infer<typeof variant> | undefined
>(); >();
@ -373,6 +380,53 @@ function ProductEditor({ id }: { id: string }) {
</> </>
)} )}
</Panel> </Panel>
<Panel title="Photos">
{!item.images.length && <p>No photos yet. The first photo is shown on the catalog card.</p>}
{item.status !== "PUBLISHED" && item.images.length > 0 && (
<Alert severity="info">Previews appear after the product is published.</Alert>
)}
<div className="product-gallery">
{item.images.map((image, index) => (
<figure key={image.id}>
{item.status === "PUBLISHED" ? (
<img src={productImageUrl(organization, id, image.id)} alt={`${item.name}, photo ${index + 1}`} />
) : (
<p>Photo {index + 1}</p>
)}
<figcaption>
{index === 0 ? "Main photo · " : ""}
{image.mimeType.replace("image/", "").toUpperCase()}, {Math.ceil(image.size / 1024)} KB
{editable(item) && (
<ConfirmAction
label="Remove"
message={`Remove photo ${index + 1}? This cannot be undone.`}
onConfirm={async () => {
await request(`/products/${id}/images/${image.id}`, z.unknown(), { method: "DELETE" });
await query.refetch();
}}
/>
)}
</figcaption>
</figure>
))}
</div>
{editable(item) && item.images.length < 8 && (
<ActionForm
label="Upload photo"
read={(data) => prepareProductImage(data.get("file"))}
submit={async (body) => {
try {
await request(`/products/${id}/images`, productImage, { method: "POST", body });
} finally {
await query.refetch();
}
}}
>
<label htmlFor={`photo-${id}`}>Photo (JPEG, PNG or WebP, up to 2 MiB)</label>
<input id={`photo-${id}`} name="file" type="file" accept={productImageAccept} required />
</ActionForm>
)}
</Panel>
<Panel title="Variants"> <Panel title="Variants">
<Table <Table
head={["Variant", "SKU", "Price", "Active", "ID", "Action"]} head={["Variant", "SKU", "Price", "Active", "ID", "Action"]}

View File

@ -5,7 +5,7 @@ import Alert from "@mui/material/Alert";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import Skeleton from "@mui/material/Skeleton"; import Skeleton from "@mui/material/Skeleton";
import Chip from "@mui/material/Chip"; import Chip from "@mui/material/Chip";
import { getProduct } from "@/lib/api"; import { getProduct, productImageUrl } from "@/lib/api";
import { usePlatform } from "@/lib/platform"; import { usePlatform } from "@/lib/platform";
import { ApiNotice } from "@/components/ApiNotice"; import { ApiNotice } from "@/components/ApiNotice";
import "./products.css"; import "./products.css";
@ -43,6 +43,18 @@ export default function ProductPage({ id }: { id: string }) {
</> </>
) : ( ) : (
<div className="product-detail"> <div className="product-detail">
{query.data.images.length > 0 && (
<div className="product-gallery">
{query.data.images.map((image, index) => (
<img
key={image.id}
src={productImageUrl(organization, id, image.id)}
alt={`${query.data.name}, photo ${index + 1}`}
loading={index ? "lazy" : "eager"}
/>
))}
</div>
)}
<h1>{query.data.name}</h1> <h1>{query.data.name}</h1>
<p className="product-description"> <p className="product-description">
{query.data.description || {query.data.description ||

View File

@ -11,20 +11,25 @@ import "./workspace.css";
import { WorkspaceNavigation } from "@/components/WorkspaceShell"; import { WorkspaceNavigation } from "@/components/WorkspaceShell";
export default function WorkspacePage() { export default function WorkspacePage() {
const { organization, principal, signIn, signOut, notice } = usePlatform(); const { organization, principal, signIn, signUp, signOut, notice } =
usePlatform();
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
const [error, setError] = useState<unknown>(null); const [error, setError] = useState<unknown>(null);
const [creating, setCreating] = useState(false);
async function submit(event: FormEvent<HTMLFormElement>) { async function submit(event: FormEvent<HTMLFormElement>) {
event.preventDefault(); event.preventDefault();
const form = event.currentTarget; const form = event.currentTarget;
const fields = new FormData(form); const fields = new FormData(form);
setBusy(true); setBusy(true);
setError(null); setError(null);
const name = String(fields.get("name") ?? "");
const email = String(fields.get("email")); const email = String(fields.get("email"));
const password = String(fields.get("password")); const password = String(fields.get("password"));
form.reset(); form.reset();
try { try {
await signIn(email, password); await (creating
? signUp(name, email, password)
: signIn(email, password));
} catch (error) { } catch (error) {
setError(error); setError(error);
} finally { } finally {
@ -47,7 +52,7 @@ export default function WorkspacePage() {
<Container maxWidth="md"> <Container maxWidth="md">
<h1>Account Workspace</h1> <h1>Account Workspace</h1>
<p className="workspace-intro"> <p className="workspace-intro">
Sign in with your approved Mani Candles account. Sign in, or create a customer account to shop.
</p> </p>
<Paper variant="outlined" className="workspace-panel"> <Paper variant="outlined" className="workspace-panel">
<ApiNotice error={error} /> <ApiNotice error={error} />
@ -68,7 +73,7 @@ export default function WorkspacePage() {
))} ))}
</ul> </ul>
) : ( ) : (
<p>No permissions assigned. Contact your administrator.</p> <p>Customer account. Use your cart, addresses and orders below.</p>
)} )}
<p className="workspace-intro"> <p className="workspace-intro">
Open a customer or administration tool below. Open a customer or administration tool below.
@ -89,11 +94,20 @@ export default function WorkspacePage() {
backend. backend.
</Alert> </Alert>
)} )}
{creating && (
<TextField
label="Full name"
name="name"
autoComplete="name"
required
inputProps={{ maxLength: 160 }}
/>
)}
<TextField <TextField
label="Email address" label="Email address"
name="email" name="email"
type="email" type="email"
autoComplete="username" autoComplete={creating ? "email" : "username"}
required required
inputProps={{ maxLength: 254 }} inputProps={{ maxLength: 254 }}
/> />
@ -101,16 +115,36 @@ export default function WorkspacePage() {
label="Password" label="Password"
name="password" name="password"
type="password" type="password"
autoComplete="current-password" autoComplete={creating ? "new-password" : "current-password"}
required required
inputProps={{ maxLength: 128 }} helperText={creating ? "At least 15 characters." : undefined}
inputProps={{ minLength: creating ? 15 : 1, maxLength: 128 }}
/> />
<Button <Button
variant="contained" variant="contained"
type="submit" type="submit"
disabled={busy || !organization} disabled={busy || !organization}
> >
{busy ? "Signing in…" : "Sign in"} {creating
? busy
? "Creating account…"
: "Create account"
: busy
? "Signing in…"
: "Sign in"}
</Button>
<Button
variant="text"
type="button"
disabled={busy}
onClick={() => {
setCreating(!creating);
setError(null);
}}
>
{creating
? "Already have an account? Sign in"
: "New customer? Create an account"}
</Button> </Button>
<small> <small>
Sessions stay in memory. Reloading or closing this page requires Sessions stay in memory. Reloading or closing this page requires

View File

@ -189,3 +189,7 @@
.variant-list dl>div { display:flex; flex-wrap:wrap; gap:.5rem; font-size:.9rem; } .variant-list dl>div { display:flex; flex-wrap:wrap; gap:.5rem; font-size:.9rem; }
.variant-list dt { font-weight:600; } .variant-list dt { font-weight:600; }
@media(max-width:480px) { .variant-list li { flex-direction:column; } .products-body { padding:3rem .5rem; } .catalog-search { flex-direction:column; } } @media(max-width:480px) { .variant-list li { flex-direction:column; } .products-body { padding:3rem .5rem; } .catalog-search { flex-direction:column; } }
.product-gallery { display:grid; grid-template-columns:repeat(auto-fill, minmax(200px, 1fr)); gap:1rem; margin:1.5rem 0; }
.product-gallery img { width:100%; aspect-ratio:4 / 5; object-fit:cover; border:1px solid var(--brand-border); }
.product-gallery img:first-child { grid-column:1 / -1; max-height:520px; }

View File

@ -0,0 +1,24 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { productImageUrl, productSchema } from "../src/lib/api.ts";
import { adminProduct, prepareProductImage } from "../src/lib/commerce.ts";
const id = "d66c798a-f764-4b88-8d13-ace328ff1010";
const product = { id, name: "Rose", slug: "rose", description: "", variants: [], groups: [] };
test("product images default to none and keep their storefront order", () => {
assert.deepEqual(productSchema.parse(product).images, []);
assert.deepEqual(productSchema.parse({ ...product, images: [{ id }] }).images, [{ id }]);
assert.throws(() => productSchema.parse({ ...product, images: [{ id: "../x" }] }));
assert.equal(productImageUrl(id, id, id), `/api/v1/storefront/${id}/products/${id}/images/${id}`);
const admin = adminProduct.parse({ ...product, status: "DRAFT", images: [{ id, mimeType: "image/webp", size: 10 }] });
assert.equal(admin.images[0].mimeType, "image/webp");
});
test("photo uploads accept only JPEG, PNG or WebP up to 2 MiB", () => {
const body = prepareProductImage(new File(["x"], "a.jpg", { type: "image/jpeg" }));
assert.ok(body.get("file") instanceof File);
assert.throws(() => prepareProductImage(new File(["<svg/>"], "a.svg", { type: "image/svg+xml" })), /JPEG, PNG or WebP/);
assert.throws(() => prepareProductImage(new File([new Uint8Array(2 * 1024 * 1024 + 1)], "a.png", { type: "image/png" })), /2 MiB/);
assert.throws(() => prepareProductImage(null), /Choose/);
});

View File

@ -332,3 +332,19 @@ test("organization change cancels private scope and removes cached data", async
await waitFor(() => expect(h.result.current.scope).toBe("")); await waitFor(() => expect(h.result.current.scope).toBe(""));
expect(h.client.getQueriesData({ queryKey: ["private"] })).toEqual([]); expect(h.client.getQueriesData({ queryKey: ["private"] })).toEqual([]);
}); });
test("sign-up registers in the configured organization and adopts the new session", async () => {
const bodies: unknown[] = [];
vi.stubGlobal("fetch", vi.fn(async (url: string, options?: RequestInit) => {
if (url.endsWith("/auth/register")) {
bodies.push(JSON.parse(String(options?.body)));
return json(session, 201);
}
if (url.endsWith("/auth/me")) return json({ ...me, permissions: [] });
throw new Error(`Unexpected request ${url}`);
}));
const h = harness();
await act(() => h.result.current.signUp("Asha Buyer", "buyer@example.com", "a long enough password"));
expect(bodies).toEqual([{ organizationId: id, name: "Asha Buyer", email: "buyer@example.com", password: "a long enough password" }]);
expect(h.result.current.principal).toMatchObject({ userId: id, permissions: [] });
});

View File

@ -7,5 +7,7 @@ export default defineConfig({
include: ["test/*.ui.test.tsx"], include: ["test/*.ui.test.tsx"],
setupFiles: ["test/setup.ts"], setupFiles: ["test/setup.ts"],
restoreMocks: true, restoreMocks: true,
// Multi-step MUI workflows take ~1.5s locally but exceed 5s on the single-worker Drone runner.
testTimeout: 20000,
}, },
}); });