Compare commits
16 Commits
fix/ssh-st
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
4e81ee7774 | |
|
|
8cd2145f06 | |
|
|
10f795ebed | |
|
|
bee6281dde | |
|
|
2d8c162834 | |
|
|
24b2686f7e | |
|
|
9f644c2e15 | |
|
|
5361413492 | |
|
|
2992c9e8f2 | |
|
|
f4dd351f87 | |
|
|
6bd1940f5e | |
|
|
cdcf0d9898 | |
|
|
4a5cac2593 | |
|
|
524b371927 | |
|
|
f2bb9f912d | |
|
|
4740eb2a57 |
19
.drone.yml
19
.drone.yml
|
|
@ -3,25 +3,6 @@ type: docker
|
|||
name: Validate and deploy frontend
|
||||
|
||||
steps:
|
||||
- name: Check deployment access
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host: server1.midastix.com
|
||||
username: mihir
|
||||
key:
|
||||
from_secret: manicandles_deploy_key
|
||||
port: 22
|
||||
script_stop: true
|
||||
script:
|
||||
- test -w /var/www/manicandles/releases && test -w /var/www/manicandles/incoming
|
||||
- test -r /etc/nginx/snippets/manicandles.conf
|
||||
- command -v flock && command -v curl
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
|
||||
- name: Validate Nginx configuration
|
||||
image: nginx:alpine
|
||||
commands:
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
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).
|
||||
|
||||
|
|
|
|||
|
|
@ -12,15 +12,18 @@ location /api/ {
|
|||
proxy_pass https://manicandles-backend.midastix.com;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_verify on;
|
||||
proxy_ssl_verify_depth 3;
|
||||
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
||||
proxy_set_header Host manicandles-backend.midastix.com;
|
||||
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_read_timeout 20s;
|
||||
proxy_hide_header Access-Control-Allow-Origin;
|
||||
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;
|
||||
proxy_pass https://manicandles-backend.midastix.com;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,4 +62,6 @@ Customer and administration screens are implemented, with recovery, pricing, sto
|
|||
- Artwork UAT should use separate uploader, reviewer, and reader accounts. Exercise the 2 MiB upload limit through ingress, approval and rejection, download permissions, and preservation of prior approved versions.
|
||||
- Partner orders support conversion from accepted, unexpired quotations, immutable merchandise snapshots, and reasoned cancellation.
|
||||
- Partner order UAT should verify expired quotes, duplicate references and quote conversion, exact retries, and cancellation blocked by an active payment receipt.
|
||||
- Partner payments, custom requests and reporting remain open.
|
||||
- Partner payments support manual external receipts, exact paid and outstanding merchandise balances, receipt details, and confirmed reasoned reversals. Read and manage permissions are separate, and payment readers can open an order's payment history without order-read permission.
|
||||
- Partner payment UAT should exercise partial and full receipts, duplicate references, overpayments, cancelled orders, exact retries for recording and reversal, restored balances, and cancellation after reversing all active receipts. References normalize to uppercase and remain reserved after reversal.
|
||||
- Custom requests and reporting remain open.
|
||||
|
|
|
|||
|
|
@ -38,4 +38,4 @@ Record the active and previous build/commit release IDs before rollout. The SSH
|
|||
|
||||
## 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.
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ overwrite a published release. A file lock
|
|||
serializes activation. An older build cannot replace a newer active build.
|
||||
The `current` symlink changes atomically. HTTPS checks use the real hostname
|
||||
resolved to loopback and verify the certificate, release marker, homepage,
|
||||
`/workspace`, `/cart`, and `/api/v1/health/ready`. Failure restores the previous
|
||||
`/workspace`, `/cart`, and `/api/v1/health/ready`. Readiness must return the backend's
|
||||
`{"status":"ok"}` response. An HTML fallback fails verification. Failure restores the previous
|
||||
current symlink, or removes the first activation if no release existed before it.
|
||||
The last successful release is also retained at `previous`. Its assets can serve
|
||||
requests from browser tabs opened before the update. Failed first deployments
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
|
||||
<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 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 name="twitter:card" content="summary_large_image" />
|
||||
<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="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
|
|
|
|||
|
|
@ -12,15 +12,18 @@ server {
|
|||
proxy_pass https://manicandles-backend.midastix.com;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_verify on;
|
||||
proxy_ssl_verify_depth 3;
|
||||
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
||||
proxy_set_header Host manicandles-backend.midastix.com;
|
||||
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_read_timeout 20s;
|
||||
proxy_hide_header Access-Control-Allow-Origin;
|
||||
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;
|
||||
proxy_pass https://manicandles-backend.midastix.com;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1265,15 +1265,15 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@eslint/config-array": {
|
||||
"version": "0.23.5",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.5.tgz",
|
||||
"integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==",
|
||||
"version": "0.23.6",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.23.6.tgz",
|
||||
"integrity": "sha512-WrTH7nioI9QPY4NZGnsywmecswJdgeq4BCM76qok9VgjTO29ZgUzUvcuJLVPYVQM4uDbaPBU0M33R9DIxI8X3w==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@eslint/object-schema": "^3.0.5",
|
||||
"debug": "^4.3.1",
|
||||
"minimatch": "^10.2.4"
|
||||
"minimatch": "^11.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.13.0 || >=24"
|
||||
|
|
@ -1486,6 +1486,13 @@
|
|||
"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": {
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||
|
|
@ -4283,17 +4290,17 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.72.2.tgz",
|
||||
"integrity": "sha512-222PKFXKihmFpi/pS5njoBgdAqsPhj2/GBmFbrNw8Tq8gEG9Sv+kSlKFy4u2q+mJv9ZzJgM2Gkv/bUzRZwZw5g==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.74.0.tgz",
|
||||
"integrity": "sha512-z3KXk1+Vm+d82ZRplOoC89ho4Rf1da5ju6sx8//92GnN532U62DGPjECXkkVqtYzIv0zoJlpO39SX2Z9tk6LVw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.12.2",
|
||||
"@typescript-eslint/scope-manager": "8.72.2",
|
||||
"@typescript-eslint/type-utils": "8.72.2",
|
||||
"@typescript-eslint/utils": "8.72.2",
|
||||
"@typescript-eslint/visitor-keys": "8.72.2",
|
||||
"@typescript-eslint/scope-manager": "8.74.0",
|
||||
"@typescript-eslint/type-utils": "8.74.0",
|
||||
"@typescript-eslint/utils": "8.74.0",
|
||||
"@typescript-eslint/visitor-keys": "8.74.0",
|
||||
"ignore": "^7.0.5",
|
||||
"natural-compare": "^1.4.0",
|
||||
"ts-api-utils": "^2.5.0"
|
||||
|
|
@ -4306,15 +4313,15 @@
|
|||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/parser": "^8.72.2",
|
||||
"@typescript-eslint/parser": "^8.74.0",
|
||||
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
||||
"typescript": ">=4.8.4 <6.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": {
|
||||
"version": "7.0.14",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz",
|
||||
"integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==",
|
||||
"version": "7.0.16",
|
||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.16.tgz",
|
||||
"integrity": "sha512-52N+Y4HRMOJmbLmr+DqO4iSRyyB7N52gm7PWCT6h0p978+oKbqHCB7gIJIwZvBUsjlSdWbrBFqUSmIFNZMpn0A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
|
@ -4322,16 +4329,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.72.2.tgz",
|
||||
"integrity": "sha512-llP+T1YuJOLlxEciP6OyQGtz5SMxyn+9LA2BvZw5RmToGVa1y4beEDVQL6Gje7T5WFYh19WREjDCN9Ev4gm5AA==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.74.0.tgz",
|
||||
"integrity": "sha512-ecr8AYdig7avVkxaHdQvxHnIJ/mOyliO4Gv/uWF8q69vBew/z3sexqBwHUZX5Vql+Ns0w4sH6gBLkICGbOvJkA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.72.2",
|
||||
"@typescript-eslint/types": "8.72.2",
|
||||
"@typescript-eslint/typescript-estree": "8.72.2",
|
||||
"@typescript-eslint/visitor-keys": "8.72.2",
|
||||
"@typescript-eslint/scope-manager": "8.74.0",
|
||||
"@typescript-eslint/types": "8.74.0",
|
||||
"@typescript-eslint/typescript-estree": "8.74.0",
|
||||
"@typescript-eslint/visitor-keys": "8.74.0",
|
||||
"debug": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
|
|
@ -4347,14 +4354,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/project-service": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.72.2.tgz",
|
||||
"integrity": "sha512-6y5dLTZdHhI8Eh3yIQ/bfQhRKwn5e+TpJj64o18Cngc0iW/BCrVvrr6zGYqXPnYH31u6YXAYiFh0+qxX5mybJw==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.74.0.tgz",
|
||||
"integrity": "sha512-z/mymuE+JlEeSFIv3Mo70EvgG1Zz74Hl0IDfExfXutARAP834bt+MppTD7mVAwmZO0GdxdOAi0jbTam749eH6g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/tsconfig-utils": "^8.72.2",
|
||||
"@typescript-eslint/types": "^8.72.2",
|
||||
"@typescript-eslint/tsconfig-utils": "^8.74.0",
|
||||
"@typescript-eslint/types": "^8.74.0",
|
||||
"debug": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
|
|
@ -4369,14 +4376,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.72.2.tgz",
|
||||
"integrity": "sha512-iIoMJ6/8c1/QpFNyFjU0d1YzPco4MsZjQw0k3V+vfzNWAFmUmvhlyMoYEoYYDQZXc+J6Gi1X5XcxlzW2taIIGQ==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.74.0.tgz",
|
||||
"integrity": "sha512-kpOdpu4CpWN5U38ox3f727DwWRBtUAVhyUJtqTBYe5gf2wYoxac7PgKP14txrxN7ICVtcjlLdzjqfRgpSnDKvQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.72.2",
|
||||
"@typescript-eslint/visitor-keys": "8.72.2"
|
||||
"@typescript-eslint/types": "8.74.0",
|
||||
"@typescript-eslint/visitor-keys": "8.74.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
|
|
@ -4387,9 +4394,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/tsconfig-utils": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.72.2.tgz",
|
||||
"integrity": "sha512-+h3iCgZXuTNtoLXcnnjP12ZUHLMqoUcIHPfQrFEXTUqvb9dF8QK9b5nv5VtSo5fLkdHuks8ehbTzZj3rImAm9w==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.74.0.tgz",
|
||||
"integrity": "sha512-p07wAuaS6BjCYgOSXKJi4YhvTnAf7fiG37e9THcpnYaQEt2QiTTYZWKwUFNgeRiywiMudazhzgddAirZ0GgHtQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
|
@ -4404,15 +4411,15 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.72.2.tgz",
|
||||
"integrity": "sha512-STfkR38qIdhfkLpgtXnUjAzsNy4xouqiBO0lrVc/Wpk9Kem5/aHXUx1J8dGC16zpdYN1+yc2ILQ28er1kXX7ag==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.74.0.tgz",
|
||||
"integrity": "sha512-CV3Y3la8l3F9ANfxcfpgSSiQgJTe4IeLEoZV4O/gcW86Ugp8X6SKiQ0vm+QegXaRIbbDMokZZSF3A1CgiU/kPw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.72.2",
|
||||
"@typescript-eslint/typescript-estree": "8.72.2",
|
||||
"@typescript-eslint/utils": "8.72.2",
|
||||
"@typescript-eslint/types": "8.74.0",
|
||||
"@typescript-eslint/typescript-estree": "8.74.0",
|
||||
"@typescript-eslint/utils": "8.74.0",
|
||||
"debug": "^4.4.3",
|
||||
"ts-api-utils": "^2.5.0"
|
||||
},
|
||||
|
|
@ -4429,9 +4436,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.72.2.tgz",
|
||||
"integrity": "sha512-Xfn37OLZx03+PCU7qWx9DTv2FCRh1E6fk2+wONeNY15HXIwtcwuveaSwVpGAUptkNmPQegRxW5JyRel9T7wrog==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.74.0.tgz",
|
||||
"integrity": "sha512-MpnMrJCVNpP1iVL8NiHkQZgQqIMBH5ewDGUPBh1pqQXwFtMFjsl1M03QcYPXmv6stCKEiF0PN7CGbU1ZbXFzEA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
|
@ -4443,18 +4450,18 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.72.2.tgz",
|
||||
"integrity": "sha512-pQEGqIK/cqEvKivVWaFLYpe7XYejFxfuAOi4mu1oAWFvIo36aRHI9esRFTUxcIy/z8N482RJyH+LpZB0ZIU7Ow==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.74.0.tgz",
|
||||
"integrity": "sha512-wL348k6l92DNG+kPP5rVpKwNBoz7a3xRZy3TPKc1uymQttd7u7gcMv3eENmcuh4CjC4mO3FTM0DYstFXMyDLuw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/project-service": "8.72.2",
|
||||
"@typescript-eslint/tsconfig-utils": "8.72.2",
|
||||
"@typescript-eslint/types": "8.72.2",
|
||||
"@typescript-eslint/visitor-keys": "8.72.2",
|
||||
"@typescript-eslint/project-service": "8.74.0",
|
||||
"@typescript-eslint/tsconfig-utils": "8.74.0",
|
||||
"@typescript-eslint/types": "8.74.0",
|
||||
"@typescript-eslint/visitor-keys": "8.74.0",
|
||||
"debug": "^4.4.3",
|
||||
"minimatch": "^10.2.2",
|
||||
"minimatch": "^11.0.1",
|
||||
"semver": "^7.7.3",
|
||||
"tinyglobby": "^0.2.15",
|
||||
"ts-api-utils": "^2.5.0"
|
||||
|
|
@ -4467,7 +4474,13 @@
|
|||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@typescript/native": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
|
||||
|
|
@ -4484,16 +4497,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.72.2.tgz",
|
||||
"integrity": "sha512-hv3eRYbpPbbpezuax1EfGrzpa3C4ySgNZkPUkLOWOAjU8HsOKowEDAr8C7nsNl1C+SBSKDpvno6VKHnlhvp9iA==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.74.0.tgz",
|
||||
"integrity": "sha512-IpWXPxXXomzxyTcvjhZJexgdvtTR1TooLAPpuxzaGqQ8BHll1lf4Ysp/BTE/l0U5TJ+x1j7B4bEM8pLRrvY+XA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.9.1",
|
||||
"@typescript-eslint/scope-manager": "8.72.2",
|
||||
"@typescript-eslint/types": "8.72.2",
|
||||
"@typescript-eslint/typescript-estree": "8.72.2"
|
||||
"@typescript-eslint/scope-manager": "8.74.0",
|
||||
"@typescript-eslint/types": "8.74.0",
|
||||
"@typescript-eslint/typescript-estree": "8.74.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
|
|
@ -4508,13 +4521,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.72.2.tgz",
|
||||
"integrity": "sha512-NAGrjn0Pitjqzq/GkgMC4kBYm233PQ8GffyQ9+kTA3AlNQYEzOf25EIM02BAHZv5FRJSpHpJk+OGUxVkOB93GQ==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.74.0.tgz",
|
||||
"integrity": "sha512-XSZmOtMUbWCBIM+2BK134FyMFxmll1mW2mPLk/PSwYQYzGIPMgJAqL929U4qXVizLv7Xq5b7r41/o7Ombuwk0g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.72.2",
|
||||
"@typescript-eslint/types": "8.74.0",
|
||||
"eslint-visitor-keys": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
|
|
@ -4753,9 +4766,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "5.0.12",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz",
|
||||
"integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==",
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.1.0.tgz",
|
||||
"integrity": "sha512-aa11Dv491GKnYqxaul3aRJ0szew7yMJMfZPnqD44NjGrZXoj62l41OEDDpdpC4eE2P88vBFfLuSyRhpG91NUvg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
@ -5372,9 +5385,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/eslint": {
|
||||
"version": "10.14.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-10.14.0.tgz",
|
||||
"integrity": "sha512-T0pNsxkb9IKmtQjhpK3d7nWOpFv+YHuMbTJnSVMoQblF0onvXfErrtp4V1jHtsQPan7dKaGVD0q1WCXnzMF31A==",
|
||||
"version": "10.15.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-10.15.0.tgz",
|
||||
"integrity": "sha512-+5Wg4p+ze3sG1WErYgUO/3H1IQIfFBymVUA0Fo/XTeBOLS6UQIUekpSJ8sdRkn7O7wjh84b55w/roqavH2aScg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
|
|
@ -5383,7 +5396,7 @@
|
|||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.8.0",
|
||||
"@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/core": "^1.2.1",
|
||||
"@eslint/plugin-kit": "^0.7.3",
|
||||
|
|
@ -5408,7 +5421,7 @@
|
|||
"imurmurhash": "^0.1.4",
|
||||
"is-glob": "^4.0.0",
|
||||
"json-stable-stringify-without-jsonify": "^1.0.1",
|
||||
"minimatch": "^10.2.6",
|
||||
"minimatch": "^11.0.5",
|
||||
"natural-compare": "^1.4.0",
|
||||
"optionator": "^0.9.3"
|
||||
},
|
||||
|
|
@ -6469,16 +6482,17 @@
|
|||
"license": "CC0-1.0"
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "10.2.6",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
|
||||
"integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
|
||||
"version": "11.0.9",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz",
|
||||
"integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^5.0.8"
|
||||
"@isaacs/nonrecursive-glob-match": "^1.1.0",
|
||||
"brace-expansion": "^5.0.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
"node": "20 || >=22"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
|
|
@ -7510,16 +7524,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/typescript-eslint": {
|
||||
"version": "8.72.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.72.2.tgz",
|
||||
"integrity": "sha512-c/+AKMW1KB81r28Sp0AAdcyXj5dzNmAsZFcsrxKbZTKmcBK2xIwBR31dcSYSDu3bKmzXe8GKrSxO+eDQ401Uzg==",
|
||||
"version": "8.74.0",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.74.0.tgz",
|
||||
"integrity": "sha512-OsWQlsedt1ZpZXfZZMNK3m4SoQONFFcy4h/uRznsCeRfVuEic3gh4KGUs2pJJ5o0Jj0Jr7keUHQGN1Ns9aDw7Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "8.72.2",
|
||||
"@typescript-eslint/parser": "8.72.2",
|
||||
"@typescript-eslint/typescript-estree": "8.72.2",
|
||||
"@typescript-eslint/utils": "8.72.2"
|
||||
"@typescript-eslint/eslint-plugin": "8.74.0",
|
||||
"@typescript-eslint/parser": "8.74.0",
|
||||
"@typescript-eslint/typescript-estree": "8.74.0",
|
||||
"@typescript-eslint/utils": "8.74.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
|
|
|
|||
|
|
@ -80,8 +80,11 @@ mv -Tf "$temporary" current
|
|||
served=$(curl --fail --silent --show-error --max-time 20 \
|
||||
--resolve "$host:443:127.0.0.1" "https://$host/release.txt")
|
||||
test "$served" = "$release_id"
|
||||
for path in / /workspace /cart /api/v1/health/ready; do
|
||||
for path in / /workspace /cart; do
|
||||
curl --fail --silent --show-error --output /dev/null --max-time 20 \
|
||||
--resolve "$host:443:127.0.0.1" "https://$host$path"
|
||||
done
|
||||
ready=$(curl --fail --silent --show-error --max-time 20 \
|
||||
--resolve "$host:443:127.0.0.1" "https://$host/api/v1/health/ready")
|
||||
test "$(printf '%s' "$ready" | tr -d '[:space:]')" = '{"status":"ok"}'
|
||||
echo "Activated $release_id on $host"
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ const CreditPoliciesPage = lazy(() => import("@/pages/CreditPoliciesPage"));
|
|||
const SamplesPage = lazy(() => import("@/pages/SamplesPage"));
|
||||
const ArtworkPage = lazy(() => import("@/pages/ArtworkPage"));
|
||||
const PartnerOrdersPage = lazy(() => import("@/pages/PartnerOrdersPage"));
|
||||
const PartnerPaymentsPage = lazy(() => import("@/pages/PartnerPaymentsPage"));
|
||||
const MaterialCostRatesPage = lazy(() => import("@/pages/MaterialCostRatesPage"));
|
||||
const ProcurementPage = lazy(() => import("@/pages/ProcurementPage"));
|
||||
const BomPage = lazy(() => import("@/pages/BomPage"));
|
||||
|
|
@ -130,6 +131,10 @@ function Router() {
|
|||
<Route path="/admin/b2b-artwork/:id">
|
||||
{(params) => <ArtworkPage id={params.id} />}
|
||||
</Route>
|
||||
<Route path="/admin/b2b-payments">{() => <PartnerPaymentsPage />}</Route>
|
||||
<Route path="/admin/b2b-partner-orders/:orderId/payments">
|
||||
{(params) => <PartnerPaymentsPage orderId={params.orderId} />}
|
||||
</Route>
|
||||
<Route path="/admin/b2b-partner-orders">{() => <PartnerOrdersPage />}</Route>
|
||||
<Route path="/admin/b2b-partner-orders/new">{() => <PartnerOrdersPage create />}</Route>
|
||||
<Route path="/admin/b2b-partner-orders/new/:quoteId">
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import Alert from "@mui/material/Alert";
|
|||
import Button from "@mui/material/Button";
|
||||
import Skeleton from "@mui/material/Skeleton";
|
||||
import { Flame } from "lucide-react";
|
||||
import { listProducts } from "@/lib/api";
|
||||
import { listProducts, productImageUrl } from "@/lib/api";
|
||||
import { usePlatform } from "@/lib/platform";
|
||||
import { ApiNotice } from "./ApiNotice";
|
||||
import "@/pages/products.css";
|
||||
|
|
@ -75,11 +75,21 @@ export function Catalog({
|
|||
<article className="prod-card" key={product.id}>
|
||||
<Link
|
||||
href={`/products/${product.id}`}
|
||||
className="prod-img-wrap catalog-placeholder"
|
||||
className={`prod-img-wrap${product.images[0] ? "" : " catalog-placeholder"}`}
|
||||
aria-label={`View ${product.name}`}
|
||||
>
|
||||
<Flame size={48} aria-hidden="true" />
|
||||
<span>Mani Candles</span>
|
||||
{product.images[0] ? (
|
||||
<img
|
||||
src={productImageUrl(organization, product.id, product.images[0].id)}
|
||||
alt=""
|
||||
loading="lazy"
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<Flame size={48} aria-hidden="true" />
|
||||
<span>Mani Candles</span>
|
||||
</>
|
||||
)}
|
||||
</Link>
|
||||
<div className="prod-info">
|
||||
<h3 className="prod-name">
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ export function WorkspaceNavigation() {
|
|||
{ label: "B2B samples", path: "/admin/b2b-samples", permission: "b2b.sample.read" },
|
||||
{ label: "B2B artwork", path: "/admin/b2b-artwork", permission: "b2b.artwork.read" },
|
||||
{ label: "B2B partner orders", path: "/admin/b2b-partner-orders", permission: "b2b.order.read" },
|
||||
{ label: "B2B partner payments", path: "/admin/b2b-payments", permission: "b2b.payment.read" },
|
||||
];
|
||||
return (
|
||||
<nav className="workspace-links" aria-label="Workspace navigation">
|
||||
|
|
|
|||
|
|
@ -5,7 +5,15 @@ const productSummarySchema = z.object({
|
|||
id: z.string().uuid(),
|
||||
name: 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({
|
||||
description: z.string(),
|
||||
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) {
|
||||
return parse(principalSchema, await apiRequest("/auth/me", { token }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,8 +154,26 @@ export const adminProductSummary = productInput
|
|||
.pick({ name: true, slug: true })
|
||||
.extend({ id: uuid, status: z.enum(["DRAFT", "PUBLISHED", "ARCHIVED"]) })
|
||||
.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({
|
||||
description: z.string(),
|
||||
images: z.array(productImage).default([]),
|
||||
variants: z.array(variant),
|
||||
groups: z.array(z.object({ group })),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
import { z } from "zod";
|
||||
import { currency, uuid } from "./commerce.ts";
|
||||
import { paymentMethods } from "./supplier-finance.ts";
|
||||
|
||||
const amount = z.string().regex(/^(0|[1-9]\d{0,15})\.\d{2}$/, "Use two decimal places");
|
||||
const reason = z.string().trim().min(3).max(500)
|
||||
.regex(/^[^<>\u0000-\u001f\u007f]*$/, "Use plain text");
|
||||
const timestamp = z.string().datetime({ offset: true });
|
||||
|
||||
export const partnerPaymentInput = z.object({
|
||||
idempotencyKey: uuid,
|
||||
reference: z.string().trim().min(1).max(80).regex(/^[A-Za-z0-9][A-Za-z0-9._/-]*$/).toUpperCase(),
|
||||
method: paymentMethods,
|
||||
amount: amount.refine((value) => value !== "0.00", "Amount must be positive"),
|
||||
receivedOn: z.string().date(),
|
||||
}).strict();
|
||||
|
||||
export const reversePartnerPaymentInput = z.object({ reason, idempotencyKey: uuid }).strict();
|
||||
export const partnerPayment = z.object({
|
||||
id: uuid, orderId: uuid, recordedById: uuid,
|
||||
reference: z.string(), method: paymentMethods, currency, amount,
|
||||
receivedOn: timestamp, createdAt: timestamp,
|
||||
reversal: z.object({ reason, reversedById: uuid, createdAt: timestamp }).nullable(),
|
||||
});
|
||||
|
||||
export const partnerPaymentHistory = z.object({
|
||||
orderId: uuid, currency, merchandiseTotal: amount, paidTotal: amount, outstandingTotal: amount,
|
||||
payments: z.array(partnerPayment),
|
||||
});
|
||||
|
|
@ -18,6 +18,7 @@ import {
|
|||
login,
|
||||
organizationSchema,
|
||||
parse,
|
||||
register,
|
||||
type Principal,
|
||||
type Session,
|
||||
} from "./api";
|
||||
|
|
@ -29,6 +30,7 @@ const PlatformContext = createContext<{
|
|||
principal: Principal | null;
|
||||
scope: string;
|
||||
signIn: (email: string, password: string) => Promise<void>;
|
||||
signUp: (name: string, email: string, password: string) => Promise<void>;
|
||||
signOut: () => Promise<void>;
|
||||
notice: string;
|
||||
clearSession: (notice?: string) => void;
|
||||
|
|
@ -110,9 +112,15 @@ export function PlatformProvider({ children }: { children: ReactNode }) {
|
|||
/* 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 next = await login(organization, email, password);
|
||||
const next = await start();
|
||||
try {
|
||||
const me = await getPrincipal(next.accessToken);
|
||||
if (
|
||||
|
|
@ -247,6 +255,7 @@ export function PlatformProvider({ children }: { children: ReactNode }) {
|
|||
principal,
|
||||
scope: principal ? `${principal.sessionId}:${accessRevision}` : "",
|
||||
signIn,
|
||||
signUp,
|
||||
signOut,
|
||||
notice,
|
||||
clearSession,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ import {
|
|||
group,
|
||||
groupInput,
|
||||
money,
|
||||
prepareProductImage,
|
||||
productImage,
|
||||
productImageAccept,
|
||||
type AdminProduct,
|
||||
uuid,
|
||||
} from "@/lib/commerce";
|
||||
|
|
@ -31,6 +34,8 @@ import {
|
|||
} from "@/components/WorkspaceTools";
|
||||
import { RecordSelection } from "@/components/RecordSelection";
|
||||
import { ConfirmAction } from "@/components/ConfirmAction";
|
||||
import { productImageUrl } from "@/lib/api";
|
||||
import "./products.css";
|
||||
function ProductForm({
|
||||
item,
|
||||
onSave,
|
||||
|
|
@ -323,8 +328,10 @@ function Products() {
|
|||
);
|
||||
}
|
||||
function ProductEditor({ id }: { id: string }) {
|
||||
const { request, can } = usePlatform();
|
||||
const { request, can, organization } = usePlatform();
|
||||
const query = usePrivateQuery(`/products/${id}`, adminProduct);
|
||||
const editable = (item: AdminProduct) =>
|
||||
can("catalog.manage") && item.status !== "ARCHIVED";
|
||||
const [editingVariant, setEditingVariant] = useState<
|
||||
z.infer<typeof variant> | undefined
|
||||
>();
|
||||
|
|
@ -373,6 +380,53 @@ function ProductEditor({ id }: { id: string }) {
|
|||
</>
|
||||
)}
|
||||
</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">
|
||||
<Table
|
||||
head={["Variant", "SKU", "Price", "Active", "ID", "Action"]}
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ function PartnerOrderDetail({ id }: { id: string }) {
|
|||
<p>Recorded {new Date(order.createdAt).toLocaleString()} by {order.createdById}</p>
|
||||
{order.note && <p>{order.note}</p>}
|
||||
<WorkspaceLink href={`${route}/account/${order.accountId}`}>All orders for this business</WorkspaceLink>
|
||||
{can("b2b.payment.read") && <p><WorkspaceLink href={`${route}/${id}/payments`}>Partner receipts and balance</WorkspaceLink></p>}
|
||||
{can("b2b.quote.read") && <p><WorkspaceLink href={`/admin/b2b-quotes/${order.quoteId}`}>Source quotation</WorkspaceLink></p>}
|
||||
<BusinessSnapshot account={order.accountSnapshot} />
|
||||
<Table head={["Variant", "Quantity", "Minimum", "Unit price", "Line total"]}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,114 @@
|
|||
import { useState } from "react";
|
||||
import { useLocation } from "wouter";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import Alert from "@mui/material/Alert";
|
||||
import Button from "@mui/material/Button";
|
||||
import { WorkspaceShell } from "@/components/WorkspaceShell";
|
||||
import { ActionForm, Check, Field, Pager, Panel, QueryView, Table, WorkspaceLink, readText, usePrivateQuery } from "@/components/WorkspaceTools";
|
||||
import { uuid } from "@/lib/commerce";
|
||||
import { partnerPayment, partnerPaymentHistory, partnerPaymentInput, reversePartnerPaymentInput } from "@/lib/partner-payments";
|
||||
import { paymentMethods } from "@/lib/supplier-finance";
|
||||
import { usePlatform } from "@/lib/platform";
|
||||
import { useIdempotentCommand } from "@/lib/use-idempotent-command";
|
||||
|
||||
const route = "/admin/b2b-partner-orders";
|
||||
|
||||
export default function PartnerPaymentsPage({ orderId }: { orderId?: string }) {
|
||||
const [, navigate] = useLocation();
|
||||
const id = uuid.safeParse(orderId);
|
||||
return <WorkspaceShell title="B2B Partner Payments" permission="b2b.payment.read">
|
||||
{orderId ? id.success ? <PaymentHistory key={id.data} orderId={id.data} /> :
|
||||
<Alert severity="warning">Invalid partner order ID.</Alert> :
|
||||
<Panel title="Find partner receipts">
|
||||
<ActionForm label="View partner payments" read={(form) => uuid.parse(readText(form, "orderId").trim())}
|
||||
submit={async (value) => { navigate(`${route}/${uuid.parse(value)}/payments`); }}>
|
||||
<Field name="orderId" label="Partner order ID" maxLength={36} />
|
||||
</ActionForm>
|
||||
</Panel>}
|
||||
</WorkspaceShell>;
|
||||
}
|
||||
|
||||
function PaymentHistory({ orderId }: { orderId: string }) {
|
||||
const { can } = usePlatform();
|
||||
const [offset, setOffset] = useState(0);
|
||||
const [selected, select] = useState("");
|
||||
const path = `/b2b/partner-orders/${orderId}/payments`;
|
||||
const query = usePrivateQuery(`${path}?limit=25&offset=${offset}`, partnerPaymentHistory);
|
||||
const command = useIdempotentCommand(path, partnerPaymentInput, partnerPayment, orderId);
|
||||
|
||||
return <>
|
||||
{can("b2b.order.read") && <WorkspaceLink href={`${route}/${orderId}`}>View partner order</WorkspaceLink>}
|
||||
<Panel title="Partner receipt history">
|
||||
<p className="workspace-id">Partner order {orderId}</p>
|
||||
<QueryView query={query}>{(data) => <>
|
||||
<dl>
|
||||
<dt>Merchandise total</dt><dd>{data.currency} {data.merchandiseTotal}</dd>
|
||||
<dt>Paid total</dt><dd>{data.currency} {data.paidTotal}</dd>
|
||||
<dt>Outstanding total</dt><dd>{data.currency} {data.outstandingTotal}</dd>
|
||||
</dl>
|
||||
<Table head={["Reference", "Received", "Method", "Amount", "Status", "Actions"]}
|
||||
rowKeys={data.payments.map((payment) => payment.id)} rows={data.payments.map((payment) => [
|
||||
payment.reference, payment.receivedOn.slice(0, 10), payment.method.replaceAll("_", " "),
|
||||
`${payment.currency} ${payment.amount}`, payment.reversal ? "Reversed" : "Recorded",
|
||||
<Button onClick={() => select(payment.id)} aria-pressed={selected === payment.id}>View receipt {payment.reference}</Button>,
|
||||
])} />
|
||||
<Pager offset={offset} count={data.payments.length} onPage={setOffset} />
|
||||
{can("b2b.payment.manage") && (command.pending || data.outstandingTotal !== "0.00") &&
|
||||
<ActionForm key={command.pending ? "retry" : "record"}
|
||||
label={command.pending ? "Retry partner receipt" : "Record partner receipt"}
|
||||
read={(form) => command.pending ? {} : Object.fromEntries(form)}
|
||||
submit={async (input) => {
|
||||
await command.run(input);
|
||||
if (offset) setOffset(0);
|
||||
await query.refetch();
|
||||
}}>
|
||||
{command.pending ? <Alert severity="warning">
|
||||
The server may have recorded this receipt. Retrying reuses reference {command.pending.reference},
|
||||
amount {data.currency} {command.pending.amount}, and the original key.
|
||||
</Alert> : <>
|
||||
<p>Record an external payment after verifying the receipt. The server checks the remaining merchandise balance.</p>
|
||||
<Field name="reference" label="Payment reference" maxLength={80} />
|
||||
<Field name="method" label="Payment method" options={paymentMethods.options.map((value) => ({ value, label: value.replaceAll("_", " ") }))} />
|
||||
<Field name="amount" label={`Receipt amount (${data.currency})`} helper="Use two decimal places." maxLength={19} />
|
||||
<Field name="receivedOn" label="Received on (YYYY-MM-DD)" maxLength={10} />
|
||||
</>}
|
||||
</ActionForm>}
|
||||
</>}</QueryView>
|
||||
</Panel>
|
||||
{selected && <ReceiptDetails key={selected} path={`${path}/${selected}`} refresh={query.refetch} />}
|
||||
</>;
|
||||
}
|
||||
|
||||
function ReceiptDetails({ path, refresh }: { path: string; refresh: () => Promise<unknown> }) {
|
||||
const { can, scope } = usePlatform();
|
||||
const client = useQueryClient();
|
||||
const query = usePrivateQuery(path, partnerPayment);
|
||||
const command = useIdempotentCommand(`${path}/reverse`, reversePartnerPaymentInput, partnerPayment, path);
|
||||
return <QueryView query={query}>{(payment) => <Panel title={`Receipt ${payment.reference}`}>
|
||||
<p>{payment.currency} {payment.amount} · {payment.method.replaceAll("_", " ")} · Received {payment.receivedOn.slice(0, 10)}</p>
|
||||
<p className="workspace-id">Recorded by {payment.recordedById} on {new Date(payment.createdAt).toLocaleString()}</p>
|
||||
{payment.reversal && <>
|
||||
<Alert severity="info">Receipt reversed.</Alert>
|
||||
<p>{payment.reversal.reason}</p>
|
||||
<p className="workspace-id">Reversed by {payment.reversal.reversedById} on {new Date(payment.reversal.createdAt).toLocaleString()}</p>
|
||||
</>}
|
||||
{can("b2b.payment.manage") && (command.pending || !payment.reversal) &&
|
||||
<ActionForm key={command.pending ? "retry" : "reverse"}
|
||||
label={command.pending ? "Retry receipt reversal" : "Reverse partner receipt"}
|
||||
read={(form) => {
|
||||
if (command.pending) return {};
|
||||
if (!form.has("confirmed")) throw new Error("Confirm the receipt reversal before continuing.");
|
||||
return { reason: readText(form, "reason") };
|
||||
}} submit={async (input) => {
|
||||
const saved = await command.run(input);
|
||||
client.setQueryData(["private", scope, path], saved);
|
||||
await refresh();
|
||||
}}>
|
||||
{command.pending ? <Alert severity="warning">The server may have reversed this receipt. Retrying uses the original reason and key.</Alert> : <>
|
||||
<p>Reversal corrects the recorded receipt. Arrange any external refund through your payment provider.</p>
|
||||
<Field name="reason" label="Reversal reason" maxLength={500} />
|
||||
<Check name="confirmed" label={`Confirm reversal of ${payment.reference}`} />
|
||||
</>}
|
||||
</ActionForm>}
|
||||
</Panel>}</QueryView>;
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ import Alert from "@mui/material/Alert";
|
|||
import Button from "@mui/material/Button";
|
||||
import Skeleton from "@mui/material/Skeleton";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import { getProduct } from "@/lib/api";
|
||||
import { getProduct, productImageUrl } from "@/lib/api";
|
||||
import { usePlatform } from "@/lib/platform";
|
||||
import { ApiNotice } from "@/components/ApiNotice";
|
||||
import "./products.css";
|
||||
|
|
@ -43,6 +43,18 @@ export default function ProductPage({ id }: { id: string }) {
|
|||
</>
|
||||
) : (
|
||||
<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>
|
||||
<p className="product-description">
|
||||
{query.data.description ||
|
||||
|
|
|
|||
|
|
@ -11,20 +11,25 @@ import "./workspace.css";
|
|||
import { WorkspaceNavigation } from "@/components/WorkspaceShell";
|
||||
|
||||
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 [error, setError] = useState<unknown>(null);
|
||||
const [creating, setCreating] = useState(false);
|
||||
async function submit(event: FormEvent<HTMLFormElement>) {
|
||||
event.preventDefault();
|
||||
const form = event.currentTarget;
|
||||
const fields = new FormData(form);
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
const name = String(fields.get("name") ?? "");
|
||||
const email = String(fields.get("email"));
|
||||
const password = String(fields.get("password"));
|
||||
form.reset();
|
||||
try {
|
||||
await signIn(email, password);
|
||||
await (creating
|
||||
? signUp(name, email, password)
|
||||
: signIn(email, password));
|
||||
} catch (error) {
|
||||
setError(error);
|
||||
} finally {
|
||||
|
|
@ -47,7 +52,7 @@ export default function WorkspacePage() {
|
|||
<Container maxWidth="md">
|
||||
<h1>Account Workspace</h1>
|
||||
<p className="workspace-intro">
|
||||
Sign in with your approved Mani Candles account.
|
||||
Sign in, or create a customer account to shop.
|
||||
</p>
|
||||
<Paper variant="outlined" className="workspace-panel">
|
||||
<ApiNotice error={error} />
|
||||
|
|
@ -68,7 +73,7 @@ export default function WorkspacePage() {
|
|||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p>No permissions assigned. Contact your administrator.</p>
|
||||
<p>Customer account. Use your cart, addresses and orders below.</p>
|
||||
)}
|
||||
<p className="workspace-intro">
|
||||
Open a customer or administration tool below.
|
||||
|
|
@ -89,11 +94,20 @@ export default function WorkspacePage() {
|
|||
backend.
|
||||
</Alert>
|
||||
)}
|
||||
{creating && (
|
||||
<TextField
|
||||
label="Full name"
|
||||
name="name"
|
||||
autoComplete="name"
|
||||
required
|
||||
inputProps={{ maxLength: 160 }}
|
||||
/>
|
||||
)}
|
||||
<TextField
|
||||
label="Email address"
|
||||
name="email"
|
||||
type="email"
|
||||
autoComplete="username"
|
||||
autoComplete={creating ? "email" : "username"}
|
||||
required
|
||||
inputProps={{ maxLength: 254 }}
|
||||
/>
|
||||
|
|
@ -101,16 +115,36 @@ export default function WorkspacePage() {
|
|||
label="Password"
|
||||
name="password"
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
autoComplete={creating ? "new-password" : "current-password"}
|
||||
required
|
||||
inputProps={{ maxLength: 128 }}
|
||||
helperText={creating ? "At least 15 characters." : undefined}
|
||||
inputProps={{ minLength: creating ? 15 : 1, maxLength: 128 }}
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
type="submit"
|
||||
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>
|
||||
<small>
|
||||
Sessions stay in memory. Reloading or closing this page requires
|
||||
|
|
|
|||
|
|
@ -1,176 +1,176 @@
|
|||
/* ─── products.css ───────────────────────────────────────── */
|
||||
|
||||
/* HERO */
|
||||
.products-hero {
|
||||
padding: 6rem 1.5rem;
|
||||
background: var(--brand-card);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.products-hero h1 {
|
||||
font-family: var(--font-serif);
|
||||
font-size: clamp(2.5rem, 6vw, 4rem);
|
||||
color: var(--brand-purple);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.products-hero p {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 1.05rem;
|
||||
color: var(--brand-muted);
|
||||
line-height: 1.8;
|
||||
max-width: 640px;
|
||||
margin: 0 auto 2rem;
|
||||
}
|
||||
|
||||
/* FILTERS */
|
||||
.products-body {
|
||||
padding: 5rem 1.5rem;
|
||||
background: var(--brand-light-lavender);
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 1rem;
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
|
||||
.filter-btn {
|
||||
font-family: var(--font-display);
|
||||
font-size: 0.72rem;
|
||||
letter-spacing: 0.2em;
|
||||
text-transform: uppercase;
|
||||
padding: 0.5rem 1.5rem;
|
||||
background: none;
|
||||
border: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
color: var(--brand-muted);
|
||||
cursor: pointer;
|
||||
transition: color 0.3s ease, border-color 0.3s ease;
|
||||
}
|
||||
|
||||
.filter-btn:hover {
|
||||
color: var(--brand-purple);
|
||||
}
|
||||
|
||||
.filter-btn.active {
|
||||
color: var(--brand-purple);
|
||||
border-bottom-color: var(--brand-gold);
|
||||
}
|
||||
|
||||
/* PRODUCT GRID */
|
||||
.products-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 3rem 2rem;
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
@media (min-width: 640px) { .products-grid { grid-template-columns: 1fr 1fr; } }
|
||||
@media (min-width: 1024px) { .products-grid { grid-template-columns: repeat(4, 1fr); } }
|
||||
|
||||
.prod-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.prod-img-wrap {
|
||||
position: relative;
|
||||
aspect-ratio: 4 / 5;
|
||||
overflow: hidden;
|
||||
background: var(--brand-card);
|
||||
border: 1px solid var(--brand-border);
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.prod-img-wrap img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform 1s ease;
|
||||
}
|
||||
|
||||
.prod-card:hover .prod-img-wrap img {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.prod-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(91,30,140,0.3);
|
||||
opacity: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
backdrop-filter: blur(2px);
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
.prod-card:hover .prod-overlay {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.prod-overlay-btn {
|
||||
padding: 0.75rem 2rem;
|
||||
background: var(--brand-light-lavender);
|
||||
color: var(--brand-purple);
|
||||
font-family: var(--font-display);
|
||||
font-size: 0.72rem;
|
||||
letter-spacing: 0.18em;
|
||||
text-transform: uppercase;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transform: translateY(32px);
|
||||
transition: transform 0.5s ease, background 0.3s ease, color 0.3s ease;
|
||||
box-shadow: 0 4px 16px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.prod-card:hover .prod-overlay-btn {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.prod-overlay-btn:hover {
|
||||
background: var(--brand-gold);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.prod-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.prod-name {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 1.4rem;
|
||||
color: var(--brand-purple);
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.prod-scent {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 0.85rem;
|
||||
color: var(--brand-muted);
|
||||
line-height: 1.5;
|
||||
margin-bottom: 0.75rem;
|
||||
/* two-line clamp */
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.prod-price {
|
||||
font-family: var(--font-sans);
|
||||
font-weight: 500;
|
||||
font-size: 1.05rem;
|
||||
color: var(--brand-gold);
|
||||
}
|
||||
/* ─── products.css ───────────────────────────────────────── */
|
||||
|
||||
/* HERO */
|
||||
.products-hero {
|
||||
padding: 6rem 1.5rem;
|
||||
background: var(--brand-card);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.products-hero h1 {
|
||||
font-family: var(--font-serif);
|
||||
font-size: clamp(2.5rem, 6vw, 4rem);
|
||||
color: var(--brand-purple);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.products-hero p {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 1.05rem;
|
||||
color: var(--brand-muted);
|
||||
line-height: 1.8;
|
||||
max-width: 640px;
|
||||
margin: 0 auto 2rem;
|
||||
}
|
||||
|
||||
/* FILTERS */
|
||||
.products-body {
|
||||
padding: 5rem 1.5rem;
|
||||
background: var(--brand-light-lavender);
|
||||
}
|
||||
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 1rem;
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
|
||||
.filter-btn {
|
||||
font-family: var(--font-display);
|
||||
font-size: 0.72rem;
|
||||
letter-spacing: 0.2em;
|
||||
text-transform: uppercase;
|
||||
padding: 0.5rem 1.5rem;
|
||||
background: none;
|
||||
border: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
color: var(--brand-muted);
|
||||
cursor: pointer;
|
||||
transition: color 0.3s ease, border-color 0.3s ease;
|
||||
}
|
||||
|
||||
.filter-btn:hover {
|
||||
color: var(--brand-purple);
|
||||
}
|
||||
|
||||
.filter-btn.active {
|
||||
color: var(--brand-purple);
|
||||
border-bottom-color: var(--brand-gold);
|
||||
}
|
||||
|
||||
/* PRODUCT GRID */
|
||||
.products-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 3rem 2rem;
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
@media (min-width: 640px) { .products-grid { grid-template-columns: 1fr 1fr; } }
|
||||
@media (min-width: 1024px) { .products-grid { grid-template-columns: repeat(4, 1fr); } }
|
||||
|
||||
.prod-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.prod-img-wrap {
|
||||
position: relative;
|
||||
aspect-ratio: 4 / 5;
|
||||
overflow: hidden;
|
||||
background: var(--brand-card);
|
||||
border: 1px solid var(--brand-border);
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.prod-img-wrap img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform 1s ease;
|
||||
}
|
||||
|
||||
.prod-card:hover .prod-img-wrap img {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.prod-overlay {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(91,30,140,0.3);
|
||||
opacity: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
backdrop-filter: blur(2px);
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
.prod-card:hover .prod-overlay {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.prod-overlay-btn {
|
||||
padding: 0.75rem 2rem;
|
||||
background: var(--brand-light-lavender);
|
||||
color: var(--brand-purple);
|
||||
font-family: var(--font-display);
|
||||
font-size: 0.72rem;
|
||||
letter-spacing: 0.18em;
|
||||
text-transform: uppercase;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transform: translateY(32px);
|
||||
transition: transform 0.5s ease, background 0.3s ease, color 0.3s ease;
|
||||
box-shadow: 0 4px 16px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.prod-card:hover .prod-overlay-btn {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.prod-overlay-btn:hover {
|
||||
background: var(--brand-gold);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.prod-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.prod-name {
|
||||
font-family: var(--font-serif);
|
||||
font-size: 1.4rem;
|
||||
color: var(--brand-purple);
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.prod-scent {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 0.85rem;
|
||||
color: var(--brand-muted);
|
||||
line-height: 1.5;
|
||||
margin-bottom: 0.75rem;
|
||||
/* two-line clamp */
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.prod-price {
|
||||
font-family: var(--font-sans);
|
||||
font-weight: 500;
|
||||
font-size: 1.05rem;
|
||||
color: var(--brand-gold);
|
||||
}
|
||||
|
||||
.catalog-placeholder { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1rem; color:var(--brand-purple); background:var(--brand-card); }
|
||||
.catalog-placeholder span { font-family:var(--font-script); font-size:2rem; }
|
||||
|
|
@ -189,3 +189,7 @@
|
|||
.variant-list dl>div { display:flex; flex-wrap:wrap; gap:.5rem; font-size:.9rem; }
|
||||
.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; } }
|
||||
|
||||
.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; }
|
||||
|
|
|
|||
|
|
@ -15,11 +15,17 @@ case "$*" in
|
|||
else
|
||||
cat "$DEPLOY_TEST_ROOT/current/release.txt"
|
||||
fi ;;
|
||||
*health/ready*) test ! -f "$DEPLOY_TEST_ROOT/fail-health" ;;
|
||||
*health/ready*)
|
||||
test ! -f "$DEPLOY_TEST_ROOT/fail-health" || exit 1
|
||||
if [ -f "$DEPLOY_TEST_ROOT/html-readiness" ]; then
|
||||
echo '<html>Page not found</html>'
|
||||
else
|
||||
echo '{"status":"ok"}'
|
||||
fi ;;
|
||||
esac
|
||||
MOCK
|
||||
chmod +x "$fixture/bin/curl"
|
||||
for release in 1-aaa 2-bbb 3-ccc; do
|
||||
for release in 1-aaa 2-bbb 3-ccc 4-ddd; do
|
||||
mkdir -p "$fixture/site/incoming/$release/dist"
|
||||
printf '%s\n' "$release" > "$fixture/site/incoming/$release/dist/release.txt"
|
||||
printf '<html>Test</html>\n' > "$fixture/site/incoming/$release/dist/index.html"
|
||||
|
|
@ -62,4 +68,7 @@ test "$(cat "$fixture/site/current/index.html")" = legacy
|
|||
rm "$fixture/site/fail-health"
|
||||
deploy 3-ccc
|
||||
test "$(cat "$fixture/site/previous/index.html")" = legacy
|
||||
touch "$fixture/site/html-readiness"
|
||||
if deploy 4-ddd; then echo 'Expected rollback when readiness serves HTML' >&2; exit 1; fi
|
||||
test "$(cat "$fixture/site/current/release.txt")" = 3-ccc
|
||||
printf 'Deployment activation, rollback and stale-build checks passed.\n'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { partnerPaymentInput, partnerPaymentHistory, reversePartnerPaymentInput } from "../src/lib/partner-payments.ts";
|
||||
|
||||
const idempotencyKey = "d66c798a-f764-4b88-8d13-ace328ff1010";
|
||||
const receipt = { idempotencyKey, reference: " utr-123 ", method: "BANK_TRANSFER", amount: "9007199254740993.25", receivedOn: "2026-11-20" };
|
||||
|
||||
test("partner receipt input normalizes references and preserves the backend's full decimal range", () => {
|
||||
assert.deepEqual(partnerPaymentInput.parse(receipt), { ...receipt, reference: "UTR-123" });
|
||||
for (const amount of ["0.00", "1", "1.001", "01.00", "-1.00", "10000000000000000.00"]) {
|
||||
assert.equal(partnerPaymentInput.safeParse({ ...receipt, amount }).success, false);
|
||||
}
|
||||
assert.equal(partnerPaymentInput.safeParse({ ...receipt, receivedOn: "2026-02-30" }).success, false);
|
||||
assert.equal(partnerPaymentInput.safeParse({ ...receipt, orderId: idempotencyKey }).success, false);
|
||||
});
|
||||
|
||||
test("partner payment reversals require a plain-text reason and a replay key", () => {
|
||||
assert.deepEqual(reversePartnerPaymentInput.parse({ reason: " Wrong receipt ", idempotencyKey }), { reason: "Wrong receipt", idempotencyKey });
|
||||
for (const reason of ["", "ab", "<script>", "bad\nreason"]) {
|
||||
assert.equal(reversePartnerPaymentInput.safeParse({ reason, idempotencyKey }).success, false);
|
||||
}
|
||||
});
|
||||
|
||||
test("partner payment history retains exact authoritative balances and strips command metadata", () => {
|
||||
const result = partnerPaymentHistory.parse({
|
||||
orderId: idempotencyKey, currency: "INR", merchandiseTotal: "9999999999999999.99",
|
||||
paidTotal: "9007199254740993.25", outstandingTotal: "992800745259006.74", payments: [], requestHash: "private",
|
||||
});
|
||||
assert.equal(result.paidTotal, receipt.amount);
|
||||
assert.equal(result.outstandingTotal, "992800745259006.74");
|
||||
assert.equal("requestHash" in result, false);
|
||||
});
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
import { afterEach, expect, test, vi } from "vitest";
|
||||
import axe from "axe-core";
|
||||
import { PlatformProvider, usePlatform } from "../src/lib/platform";
|
||||
import PartnerPaymentsPage from "../src/pages/PartnerPaymentsPage";
|
||||
import theme from "../src/theme";
|
||||
|
||||
const orderId = "d66c798a-f764-4b88-8d13-ace328ff1010";
|
||||
const userId = "d66c798a-f764-4b88-8d13-ace328ff1011";
|
||||
const paymentId = "d66c798a-f764-4b88-8d13-ace328ff1012";
|
||||
const timestamp = "2026-11-20T00:00:00.000Z";
|
||||
const path = `/b2b/partner-orders/${orderId}/payments`;
|
||||
const payment = {
|
||||
id: paymentId, orderId, recordedById: userId, reference: "UTR-123", method: "BANK_TRANSFER",
|
||||
currency: "INR", amount: "100.25", receivedOn: timestamp, createdAt: timestamp, reversal: null,
|
||||
};
|
||||
const history = {
|
||||
orderId, currency: "INR", merchandiseTotal: "1000.00", paidTotal: "0.00", outstandingTotal: "1000.00", payments: [],
|
||||
};
|
||||
const json = (body: unknown, status = 200) => new Response(JSON.stringify(body), { status });
|
||||
function Login() {
|
||||
const { signIn } = usePlatform();
|
||||
return <button onClick={() => signIn("staff@example.com", "test password")}>Test login</button>;
|
||||
}
|
||||
function show(permissions: string[], handle: (url: string, options?: RequestInit) => Promise<Response>, id = orderId) {
|
||||
const fetch = vi.fn(async (url: string, options?: RequestInit) => {
|
||||
if (url.endsWith("/auth/login")) return json({ accessToken: "opaque", tokenType: "Bearer", expiresAt: new Date(Date.now() + 3600000).toISOString() });
|
||||
if (url.endsWith("/auth/me")) return json({ userId, organizationId: orderId, sessionId: userId, permissions });
|
||||
return handle(url, options);
|
||||
});
|
||||
vi.stubGlobal("fetch", fetch);
|
||||
localStorage.setItem("mani.organization", orderId);
|
||||
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
render(<ThemeProvider theme={theme}><QueryClientProvider client={client}>
|
||||
<PlatformProvider><Login /><PartnerPaymentsPage orderId={id} /></PlatformProvider>
|
||||
</QueryClientProvider></ThemeProvider>);
|
||||
return fetch;
|
||||
}
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
|
||||
test("recording a lost-response receipt replays the exact normalized body and refreshes authoritative balances", async () => {
|
||||
const attempts: unknown[] = [];
|
||||
let saved = false;
|
||||
const fetch = show(["b2b.payment.read", "b2b.payment.manage"], async (url, options) => {
|
||||
if (url.endsWith(path) && options?.method === "POST") {
|
||||
attempts.push(JSON.parse(String(options.body)));
|
||||
if (attempts.length === 1) throw new Error("Response lost");
|
||||
saved = true;
|
||||
return json(payment);
|
||||
}
|
||||
if (url.includes(`${path}?`)) return json(saved ? { ...history, paidTotal: "100.25", outstandingTotal: "899.75", payments: [payment] } : history);
|
||||
throw new Error(`Unexpected request ${url}`);
|
||||
});
|
||||
expect(fetch).not.toHaveBeenCalled();
|
||||
const user = userEvent.setup();
|
||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||
fireEvent.change(await screen.findByRole("textbox", { name: "Payment reference" }), { target: { value: " utr-123 " } });
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Receipt amount (INR)" }), { target: { value: "100.25" } });
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Received on (YYYY-MM-DD)" }), { target: { value: "2026-11-20" } });
|
||||
await user.click(screen.getByRole("button", { name: "Record partner receipt" }));
|
||||
await user.click(await screen.findByRole("button", { name: "Retry partner receipt" }));
|
||||
await screen.findByText("INR 899.75");
|
||||
expect(attempts[0]).toEqual({ reference: "UTR-123", method: "BANK_TRANSFER", amount: "100.25", receivedOn: "2026-11-20", idempotencyKey: expect.any(String) });
|
||||
expect(attempts).toEqual([attempts[0], attempts[0]]);
|
||||
});
|
||||
|
||||
test("reversal requires confirmation and replays its reason and key after a lost response", async () => {
|
||||
const attempts: unknown[] = [];
|
||||
const reason = "Receipt recorded against wrong bank entry";
|
||||
let current: object = payment;
|
||||
const user = userEvent.setup();
|
||||
show(["b2b.payment.read", "b2b.payment.manage"], async (url, options) => {
|
||||
if (url.endsWith(`${path}/${paymentId}/reverse`)) {
|
||||
attempts.push(JSON.parse(String(options?.body)));
|
||||
if (attempts.length === 1) throw new Error("Response lost");
|
||||
current = { ...payment, reversal: { reason, reversedById: userId, createdAt: timestamp } };
|
||||
return json(current);
|
||||
}
|
||||
if (url.endsWith(`${path}/${paymentId}`)) return json(current);
|
||||
if (url.includes(`${path}?`)) return json({ ...history, payments: [current] });
|
||||
throw new Error(`Unexpected request ${url}`);
|
||||
});
|
||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||
await user.click(await screen.findByRole("button", { name: "View receipt UTR-123" }));
|
||||
fireEvent.change(await screen.findByRole("textbox", { name: "Reversal reason" }), { target: { value: reason } });
|
||||
await user.click(screen.getByRole("button", { name: "Reverse partner receipt" }));
|
||||
expect(attempts).toEqual([]);
|
||||
await screen.findByText("Confirm the receipt reversal before continuing.");
|
||||
await user.click(screen.getByRole("checkbox", { name: "Confirm reversal of UTR-123" }));
|
||||
await user.click(screen.getByRole("button", { name: "Reverse partner receipt" }));
|
||||
await user.click(await screen.findByRole("button", { name: "Retry receipt reversal" }));
|
||||
await screen.findByText(reason, { exact: true });
|
||||
expect(attempts).toEqual([{ reason, idempotencyKey: expect.any(String) }, { reason, idempotencyKey: expect.any(String) }]);
|
||||
expect(attempts[1]).toEqual(attempts[0]);
|
||||
expect(screen.queryByRole("button", { name: "Reverse partner receipt" })).toBeNull();
|
||||
});
|
||||
|
||||
test("payment readers can inspect history without order permissions or mutation controls", async () => {
|
||||
show(["b2b.payment.read"], async () => json({ ...history, paidTotal: "9007199254740993.25", payments: [payment] }));
|
||||
const user = userEvent.setup();
|
||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||
await screen.findByText("INR 9007199254740993.25");
|
||||
expect(screen.queryByRole("button", { name: "Record partner receipt" })).toBeNull();
|
||||
});
|
||||
|
||||
test("missing payment permission and invalid order IDs never issue a payment request", async () => {
|
||||
const handle = vi.fn(async () => json(history));
|
||||
show(["b2b.order.read"], handle, "invalid");
|
||||
const user = userEvent.setup();
|
||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||
await screen.findByText("Your account does not have permission to view this page.");
|
||||
expect(handle).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("invalid order IDs are rejected before querying even for payment readers", async () => {
|
||||
const handle = vi.fn(async () => json(history));
|
||||
show(["b2b.payment.read"], handle, "invalid");
|
||||
await userEvent.setup().click(screen.getByRole("button", { name: "Test login" }));
|
||||
await screen.findByText("Invalid partner order ID.");
|
||||
expect(handle).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("a confirmed overpayment conflict displays the backend reason and permits correction", async () => {
|
||||
let attempts = 0;
|
||||
show(["b2b.payment.read", "b2b.payment.manage"], async (_url, options) => {
|
||||
if (options?.method === "POST") {
|
||||
attempts++;
|
||||
return json({ message: "Payment exceeds the partner order balance", code: "B2B_PAYMENT_AMOUNT_LIMIT" }, 409);
|
||||
}
|
||||
return json(history);
|
||||
});
|
||||
const user = userEvent.setup();
|
||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||
fireEvent.change(await screen.findByRole("textbox", { name: "Payment reference" }), { target: { value: "UTR-123" } });
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Receipt amount (INR)" }), { target: { value: "1001.00" } });
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Received on (YYYY-MM-DD)" }), { target: { value: "2026-11-20" } });
|
||||
await user.click(screen.getByRole("button", { name: "Record partner receipt" }));
|
||||
await screen.findByText("Payment exceeds the partner order balance");
|
||||
expect(attempts).toBe(1);
|
||||
expect(screen.queryByRole("button", { name: "Retry partner receipt" })).toBeNull();
|
||||
expect(screen.getByRole("textbox", { name: "Receipt amount (INR)" })).toHaveProperty("value", "1001.00");
|
||||
});
|
||||
|
||||
test("fully paid orders keep their receipt history and hide new recording controls", async () => {
|
||||
show(["b2b.payment.read", "b2b.payment.manage"], async () => json({ ...history, paidTotal: "1000.00", outstandingTotal: "0.00", payments: [payment] }));
|
||||
await userEvent.setup().click(screen.getByRole("button", { name: "Test login" }));
|
||||
await screen.findByRole("button", { name: "View receipt UTR-123" });
|
||||
expect(screen.queryByRole("button", { name: "Record partner receipt" })).toBeNull();
|
||||
});
|
||||
|
||||
test("the populated receipt form has no serious or critical axe violations", async () => {
|
||||
show(["b2b.payment.read", "b2b.payment.manage"], async () => json(history));
|
||||
await userEvent.setup().click(screen.getByRole("button", { name: "Test login" }));
|
||||
await screen.findByRole("textbox", { name: "Payment reference" });
|
||||
const result = await axe.run(document.body, { rules: { "color-contrast": { enabled: false } } });
|
||||
expect(result.violations.filter(({ impact }) => impact === "serious" || impact === "critical")).toEqual([]);
|
||||
});
|
||||
|
|
@ -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/);
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { type ReactNode } from "react";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
|
|
@ -92,11 +92,9 @@ test("an uncertain sample request retries with its original account, variant, qu
|
|||
|
||||
const user = userEvent.setup();
|
||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||
await user.type(await screen.findByRole("textbox", { name: /Variant ID/ }), variantId);
|
||||
const quantity = screen.getByRole("spinbutton", { name: /Sample quantity/ });
|
||||
await user.clear(quantity);
|
||||
await user.type(quantity, "4");
|
||||
await user.type(screen.getByRole("textbox", { name: /Sample purpose/ }), sample.purpose);
|
||||
fireEvent.change(await screen.findByRole("textbox", { name: /Variant ID/ }), { target: { value: variantId } });
|
||||
fireEvent.change(screen.getByRole("spinbutton", { name: /Sample quantity/ }), { target: { value: "4" } });
|
||||
fireEvent.change(screen.getByRole("textbox", { name: /Sample purpose/ }), { target: { value: sample.purpose } });
|
||||
await user.click(screen.getByRole("button", { name: "Request samples" }));
|
||||
await user.click(await screen.findByRole("button", { name: "Retry sample request" }));
|
||||
await screen.findByText(sample.purpose);
|
||||
|
|
@ -157,10 +155,11 @@ test("an independent reviewer can approve a request and retry a manual dispatch"
|
|||
const user = userEvent.setup();
|
||||
await user.click(screen.getByRole("button", { name: "Test login" }));
|
||||
await user.selectOptions(await screen.findByRole("combobox", { name: /Review decision/ }), "APPROVED");
|
||||
await user.type(screen.getByRole("textbox", { name: /Review note/ }), approved.note);
|
||||
fireEvent.change(screen.getByRole("textbox", { name: /Review note/ }), { target: { value: approved.note } });
|
||||
await user.click(screen.getByRole("button", { name: "Record sample decision" }));
|
||||
await user.type(await screen.findByRole("textbox", { name: /Dispatch reference/ }), dispatched.dispatchReference);
|
||||
await user.type(screen.getByRole("textbox", { name: /Dispatch note/ }), dispatched.note);
|
||||
expect(decision).toEqual({ decision: "APPROVED", note: approved.note, idempotencyKey: expect.any(String) });
|
||||
fireEvent.change(await screen.findByRole("textbox", { name: /Dispatch reference/ }), { target: { value: dispatched.dispatchReference } });
|
||||
fireEvent.change(screen.getByRole("textbox", { name: /Dispatch note/ }), { target: { value: dispatched.note } });
|
||||
await user.click(screen.getByRole("button", { name: "Record dispatch" }));
|
||||
await user.click(await screen.findByRole("button", { name: "Retry dispatch" }));
|
||||
await screen.findByRole("cell", { name: dispatched.dispatchReference });
|
||||
|
|
|
|||
|
|
@ -332,3 +332,19 @@ test("organization change cancels private scope and removes cached data", async
|
|||
await waitFor(() => expect(h.result.current.scope).toBe(""));
|
||||
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: [] });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { type ReactNode } from "react";
|
||||
import { act, render, screen, waitFor, within } from "@testing-library/react";
|
||||
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
|
||||
import { Table } from "../src/components/WorkspaceTools";
|
||||
import { ConfirmAction } from "../src/components/ConfirmAction";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
|
@ -722,19 +722,17 @@ test("a production batch starts, safely retries usage and completes with reconci
|
|||
await user.click(await screen.findByRole("button", { name: "Start batch" }));
|
||||
await user.click(screen.getByRole("button", { name: "Confirm" }));
|
||||
await user.selectOptions(await screen.findByRole("combobox", { name: /Usage type/ }), "WASTED");
|
||||
await user.type(screen.getByRole("textbox", { name: /Actual quantity/ }), "0.125");
|
||||
await user.type(screen.getByRole("textbox", { name: /Usage reason/ }), "Spill");
|
||||
fireEvent.change(screen.getByRole("textbox", { name: /Actual quantity/ }), { target: { value: "0.125" } });
|
||||
fireEvent.change(screen.getByRole("textbox", { name: /Usage reason/ }), { target: { value: "Spill" } });
|
||||
await user.click(screen.getByRole("button", { name: "Record material usage" }));
|
||||
await user.click(await screen.findByRole("button", { name: "Retry material usage" }));
|
||||
await screen.findByRole("cell", { name: "199.875" });
|
||||
expect(attempts).toHaveLength(2);
|
||||
expect(attempts[0]).toEqual({ bomLineId: id, kind: "WASTED", quantity: "0.125", reason: "Spill", idempotencyKey: expect.any(String) });
|
||||
expect(attempts[1]).toEqual(attempts[0]);
|
||||
await user.type(screen.getByRole("spinbutton", { name: /Good pieces/ }), "18");
|
||||
const rejected = screen.getByRole("spinbutton", { name: /Rejected pieces/ });
|
||||
await user.clear(rejected);
|
||||
await user.type(rejected, "2");
|
||||
await user.type(screen.getByRole("textbox", { name: /Rejection reason/ }), "Surface defects");
|
||||
fireEvent.change(screen.getByRole("spinbutton", { name: /Good pieces/ }), { target: { value: "18" } });
|
||||
fireEvent.change(screen.getByRole("spinbutton", { name: /Rejected pieces/ }), { target: { value: "2" } });
|
||||
fireEvent.change(screen.getByRole("textbox", { name: /Rejection reason/ }), { target: { value: "Surface defects" } });
|
||||
await user.click(screen.getByRole("button", { name: "Complete batch" }));
|
||||
await screen.findByText(/18 good · 2 rejected · Surface defects/);
|
||||
expect(screen.queryByRole("button", { name: "Record material usage" })).toBeNull();
|
||||
|
|
|
|||
|
|
@ -7,5 +7,7 @@ export default defineConfig({
|
|||
include: ["test/*.ui.test.tsx"],
|
||||
setupFiles: ["test/setup.ts"],
|
||||
restoreMocks: true,
|
||||
// Multi-step MUI workflows take ~1.5s locally but exceed 5s on the single-worker Drone runner.
|
||||
testTimeout: 20000,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue