Merge pull request 'feat: connect existing storefront to Mani Candles backend' (#8) from feat/backend-phase1 into main
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
Reviewed-on: #8
This commit is contained in:
commit
d2860790f5
|
|
@ -6,4 +6,6 @@ build
|
||||||
Dockerfile
|
Dockerfile
|
||||||
.dockerignore
|
.dockerignore
|
||||||
README.md
|
README.md
|
||||||
.env
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
VITE_ORGANIZATION_ID=
|
||||||
|
|
@ -11,3 +11,5 @@ dist/
|
||||||
|
|
||||||
*.log
|
*.log
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.env*
|
||||||
|
!.env.example
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
nodeLinker: node-modules
|
|
||||||
15
Dockerfile
15
Dockerfile
|
|
@ -1,19 +1,22 @@
|
||||||
FROM node:20-alpine AS build
|
FROM node:24-alpine AS build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
RUN npm install
|
RUN npm ci
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run typecheck && npm test && npm run build
|
||||||
|
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Mani Candles frontend
|
||||||
|
|
||||||
|
The existing ManiCandles site upgraded against the deployed Nest API. Its purple/gold design, branding, and marketing pages are retained. Phase 1 connects catalog discovery, variants, staff sessions, organization setup and health checks.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
Use Node 24 and npm 11. The canonical lockfile is package-lock.json, matching the Docker npm workflow; the outdated Yarn lock/config were removed.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm ci
|
||||||
|
npm run dev
|
||||||
|
npm run typecheck
|
||||||
|
npm test
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
Open the printed local URL. Set your organization UUID on `/connection`, or set VITE_ORGANIZATION_ID in `.env.local`. Only the UUID is persisted; passwords and session tokens remain in memory. Existing approved staff sign in at `/workspace`. Navigation preserves the session; reloads discard it. Logout revokes the backend session.
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
Development proxies `/api` to `https://manicandles-backend.midastix.com`. Docker Nginx provides the same HTTPS upstream with certificate verification, Authorization forwarding, and SPA deep-link fallback. HTTPS must terminate at the deployment ingress. `vite preview` is static preview only and does not provide the development API proxy.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker build -t manicandles-frontend:uat .
|
||||||
|
docker run --rm -p 8080:80 manicandles-frontend:uat
|
||||||
|
```
|
||||||
|
|
||||||
|
The existing main-branch Drone pipeline deploys automatically on push. Work is on a feature branch; a local build is not deployment verification. Docker was unavailable locally for container verification.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Cart/checkout, registration and admin/operations tools are subsequent phases. 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).
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Frontend phases
|
||||||
|
|
||||||
|
Canonical implementation: this checkout from ssh://git@git.midastix.com:2212/internal/ManiCandles.git. The standalone frontend created earlier is superseded for ongoing development.
|
||||||
|
|
||||||
|
| Phase | Scope | Acceptance gate |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 1 — Existing-site foundation | Preserve branding, connect home/catalog/search/pagination/variants, staff login/me/logout/expiry, organization setup, health checks, API proxy and SPA routing | Real published records and approved account; loading/empty/failure states; keyboard and responsive verification |
|
||||||
|
| 2 — Commerce and administration | Users/roles/audit, products/groups/variants/stock, addresses/cart/coupons/checkout/orders, recovery | Permission failures, conflicts, exact totals and expiry; no simulated live payment |
|
||||||
|
| 3 — Procurement and production | Suppliers/materials, POs/receipts/QC, invoices/payments/documents, BOMs/batches/usage/packaging/costing, warehouse stock | Supplier-to-finished-goods journey; independent review; partials/idempotency; stock invariants |
|
||||||
|
| 4 — B2B | Verification, price lists/MOQ, quotes/credit/samples/artwork, partner orders/payments, custom requests/reports | Independent approvals, expiry, reversals and currency/account boundaries |
|
||||||
|
| 5 — Growth and reporting | Wishlist/reviews, campaigns/discounts, recovery/consent, blog/segments/forum, analytics/forecast/accounting | Publication/moderation, consent, private data and report verification |
|
||||||
|
| 6 — Complete UAT and release | Dedicated deployment, disposable fixtures, role matrix, end-to-end scripts, accessibility/security review, defect retests and release/rollback runbook | Critical journeys pass; no critical/high defects; owner acceptance |
|
||||||
|
|
||||||
|
## Phase 1 setup
|
||||||
|
|
||||||
|
No UAT organization/account has been provisioned in this session. On the deployed backend host with its intended UAT database, securely set ORGANIZATION_NAME, OWNER_NAME, OWNER_EMAIL and OWNER_PASSWORD (15–128 characters); run `pnpm bootstrap:owner`; record organizationId; remove bootstrap secrets. This is a one-time operation. If an owner already exists, retrieve that organization and provision approved staff instead. Never put database credentials or owner secrets in frontend environment files.
|
||||||
|
|
||||||
|
Enter the UUID at `/connection`, then credentials at `/workspace`. Published products and active variants are required for catalog checks. Phase 2 enables admin fixture setup. Live authenticated acceptance remains pending until provisioning.
|
||||||
|
|
||||||
|
## Contract and quality
|
||||||
|
|
||||||
|
Reference: deployed `/api/docs-json` and backend source API guides. Storefront lists are arrays; detail includes decimal price strings, currency, attributes and nested groups. Zod validates returned shapes. Errors preserve code/requestId. React escapes API content; request timeout is 15 seconds. Session tokens/passwords are not persisted. UUID is configuration, not an authorization boundary; backend permissions remain authoritative.
|
||||||
|
|
||||||
|
Use existing MUI theme and React Query. Query keys include organization. Search is bounded to 100 characters; catalog pages contain 12 records and respect the API offset cap. No product-image mapping is invented. Nginx forwards `/api/` to the known HTTPS upstream, verifies TLS and handles SPA deep links. No public owner/account creation is exposed.
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Existing-site Phase 1 verification — 11 October 2026
|
||||||
|
|
||||||
|
| Check | Result | Evidence |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| API contract/client | Passed | 8 automated tests for organization validation, query encoding/list shape, decimal variants, login/me, 204/logout/errors, network/cancel, malformed responses/diagnostics |
|
||||||
|
| TypeScript | Passed | npm run typecheck |
|
||||||
|
| Production compilation | Passed | npm run build; retained MUI/Framer Motion bundle triggers Vite's 500 kB advisory |
|
||||||
|
| Dependency audit | Passed | 0 vulnerabilities after patched Vite and unused typography plugin removal |
|
||||||
|
| Browser service checks | Passed | Service liveness and database readiness both showed Passed through /api proxy |
|
||||||
|
| Malformed organization | Passed | Invalid UUID produced a local validation error |
|
||||||
|
| Unconfigured catalog/staff | Passed | Setup guidance visible; staff sign-in disabled without UUID |
|
||||||
|
| Mobile navigation | Passed | Expanded menu exposes Workspace/Connection; navigation closes menu |
|
||||||
|
| Keyboard skip link | Passed | Enter moved document focus to main-content |
|
||||||
|
| Catalog responsive shell | Passed | Tested 320, 768, 1024, 1440 widths; document width did not exceed viewport |
|
||||||
|
| Browser console | Passed for observed setup/health flow | No captured error messages |
|
||||||
|
| Published catalog/search/pagination/detail with live fixtures | Pending | Requires provisioned organization and published products |
|
||||||
|
| Login/me/logout/expiry across navigation with a real account | Pending | Requires approved account |
|
||||||
|
| Nginx container/ingress/deep-link deployment | Pending | Docker runtime unavailable locally; config/source reviewed only |
|
||||||
|
| Full-platform acceptance | Pending | Remaining frontend phases and UAT fixture/role matrix required |
|
||||||
|
|
||||||
|
No account was created, no production data was seeded, and no deployment was performed. The existing Drone pipeline deploys main on push, so the upgrade remains on a feature branch. API fixture tests validate client behavior and do not prove authenticated live acceptance.
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
|
|
@ -0,0 +1,25 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
add_header X-Content-Type-Options nosniff always;
|
||||||
|
add_header Referrer-Policy strict-origin-when-cross-origin always;
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass https://manicandles-backend.midastix.com;
|
||||||
|
proxy_ssl_server_name on;
|
||||||
|
proxy_ssl_verify on;
|
||||||
|
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
||||||
|
proxy_set_header Host manicandles-backend.midastix.com;
|
||||||
|
proxy_set_header Authorization $http_authorization;
|
||||||
|
proxy_connect_timeout 10s;
|
||||||
|
proxy_read_timeout 20s;
|
||||||
|
proxy_hide_header Access-Control-Allow-Origin;
|
||||||
|
proxy_hide_header Access-Control-Allow-Credentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
|
|
@ -7,8 +7,13 @@
|
||||||
"dev": "vite --config vite.config.ts",
|
"dev": "vite --config vite.config.ts",
|
||||||
"build": "vite build --config vite.config.ts",
|
"build": "vite build --config vite.config.ts",
|
||||||
"serve": "vite preview --config vite.config.ts",
|
"serve": "vite preview --config vite.config.ts",
|
||||||
"typecheck": "tsc -p tsconfig.json --noEmit"
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||||
|
"test": "node --test test/*.test.ts"
|
||||||
},
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=24 <25"
|
||||||
|
},
|
||||||
|
"packageManager": "npm@11.17.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@emotion/react": "^11.11.4",
|
"@emotion/react": "^11.11.4",
|
||||||
"@emotion/styled": "^11.11.5",
|
"@emotion/styled": "^11.11.5",
|
||||||
|
|
@ -42,13 +47,12 @@
|
||||||
"@radix-ui/react-toggle": "^1.1.3",
|
"@radix-ui/react-toggle": "^1.1.3",
|
||||||
"@radix-ui/react-toggle-group": "^1.1.3",
|
"@radix-ui/react-toggle-group": "^1.1.3",
|
||||||
"@radix-ui/react-tooltip": "^1.2.0",
|
"@radix-ui/react-tooltip": "^1.2.0",
|
||||||
"@tailwindcss/typography": "^0.5.15",
|
|
||||||
"@tailwindcss/vite": "^4.1.6",
|
"@tailwindcss/vite": "^4.1.6",
|
||||||
"@tanstack/react-query": "^5.56.2",
|
"@tanstack/react-query": "^5.56.2",
|
||||||
"@types/node": "^22.5.5",
|
"@types/node": "^22.5.5",
|
||||||
"@types/react": "^18.3.5",
|
"@types/react": "^18.3.5",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react-dom": "^18.3.0",
|
||||||
"@vitejs/plugin-react": "^4.3.1",
|
"@vitejs/plugin-react": "^4.7.0",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cmdk": "^1.1.1",
|
"cmdk": "^1.1.1",
|
||||||
|
|
@ -71,7 +75,7 @@
|
||||||
"tw-animate-css": "^1.4.0",
|
"tw-animate-css": "^1.4.0",
|
||||||
"typescript": "^6.0.3",
|
"typescript": "^6.0.3",
|
||||||
"vaul": "^1.1.2",
|
"vaul": "^1.1.2",
|
||||||
"vite": "^5.4.14",
|
"vite": "^6.4.4",
|
||||||
"wouter": "^3.3.5",
|
"wouter": "^3.3.5",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
82
src/App.tsx
82
src/App.tsx
|
|
@ -1,32 +1,50 @@
|
||||||
import { Switch, Route, Router as WouterRouter } from "wouter";
|
import { Switch, Route, Router as WouterRouter } from "wouter";
|
||||||
import NotFound from "@/pages/not-found";
|
import NotFound from "@/pages/not-found";
|
||||||
|
|
||||||
import { Layout } from "@/components/Layout";
|
import { Layout } from "@/components/Layout";
|
||||||
import Home from "@/pages/home";
|
import Home from "@/pages/home";
|
||||||
import ProductsPage from "@/pages/ProductsPage";
|
import ProductsPage from "@/pages/ProductsPage";
|
||||||
import AboutPage from "@/pages/AboutPage";
|
import AboutPage from "@/pages/AboutPage";
|
||||||
import ContactPage from "@/pages/ContactPage";
|
import ContactPage from "@/pages/ContactPage";
|
||||||
|
import ProductPage from "@/pages/ProductPage";
|
||||||
function Router() {
|
import WorkspacePage from "@/pages/WorkspacePage";
|
||||||
return (
|
import ConnectionPage from "@/pages/ConnectionPage";
|
||||||
<Switch>
|
import { PlatformProvider } from "@/lib/platform";
|
||||||
<Route path="/" component={Home} />
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
<Route path="/products" component={ProductsPage} />
|
|
||||||
<Route path="/about" component={AboutPage} />
|
const queryClient = new QueryClient({
|
||||||
<Route path="/contact" component={ContactPage} />
|
defaultOptions: { queries: { retry: false } },
|
||||||
<Route component={NotFound} />
|
});
|
||||||
</Switch>
|
|
||||||
);
|
function Router() {
|
||||||
}
|
return (
|
||||||
|
<Switch>
|
||||||
function App() {
|
<Route path="/" component={Home} />
|
||||||
return (
|
<Route path="/products" component={ProductsPage} />
|
||||||
<WouterRouter base={import.meta.env.BASE_URL.replace(/\/$/, "")}>
|
<Route path="/products/:id">
|
||||||
<Layout>
|
{(params) => <ProductPage id={params.id} />}
|
||||||
<Router />
|
</Route>
|
||||||
</Layout>
|
<Route path="/workspace" component={WorkspacePage} />
|
||||||
</WouterRouter>
|
<Route path="/connection" component={ConnectionPage} />
|
||||||
);
|
<Route path="/about" component={AboutPage} />
|
||||||
}
|
<Route path="/contact" component={ContactPage} />
|
||||||
|
<Route component={NotFound} />
|
||||||
export default App;
|
</Switch>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function App() {
|
||||||
|
return (
|
||||||
|
<QueryClientProvider client={queryClient}>
|
||||||
|
<PlatformProvider>
|
||||||
|
<WouterRouter base={import.meta.env.BASE_URL.replace(/\/$/, "")}>
|
||||||
|
<Layout>
|
||||||
|
<Router />
|
||||||
|
</Layout>
|
||||||
|
</WouterRouter>
|
||||||
|
</PlatformProvider>
|
||||||
|
</QueryClientProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import Alert from "@mui/material/Alert";
|
||||||
|
import { ApiError } from "@/lib/api";
|
||||||
|
export function ApiNotice({ error }: { error: unknown }) {
|
||||||
|
if (!error) return null;
|
||||||
|
return (
|
||||||
|
<Alert severity="error" sx={{ my: 2, overflowWrap: "anywhere" }}>
|
||||||
|
{error instanceof Error ? error.message : "An unexpected error occurred."}
|
||||||
|
{error instanceof ApiError && (
|
||||||
|
<div>
|
||||||
|
<small>
|
||||||
|
{error.code}
|
||||||
|
{error.requestId && ` · Reference: ${error.requestId}`}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Alert>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
import { Link } from "wouter";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
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 { usePlatform } from "@/lib/platform";
|
||||||
|
import { ApiNotice } from "./ApiNotice";
|
||||||
|
import "@/pages/products.css";
|
||||||
|
|
||||||
|
export function Catalog({
|
||||||
|
search = "",
|
||||||
|
offset = 0,
|
||||||
|
limit = 12,
|
||||||
|
onNext,
|
||||||
|
onPrevious,
|
||||||
|
}: {
|
||||||
|
search?: string;
|
||||||
|
offset?: number;
|
||||||
|
limit?: number;
|
||||||
|
onNext?: () => void;
|
||||||
|
onPrevious?: () => void;
|
||||||
|
}) {
|
||||||
|
const { organization } = usePlatform();
|
||||||
|
const query = useQuery({
|
||||||
|
queryKey: ["catalog", organization, search, offset, limit],
|
||||||
|
queryFn: ({ signal }) =>
|
||||||
|
listProducts(organization, search, offset, limit, signal),
|
||||||
|
enabled: Boolean(organization),
|
||||||
|
retry: false,
|
||||||
|
});
|
||||||
|
if (!organization)
|
||||||
|
return (
|
||||||
|
<Alert severity="info">
|
||||||
|
Configure your organization on the{" "}
|
||||||
|
<Link href="/connection">
|
||||||
|
<u>Connection page</u>
|
||||||
|
</Link>{" "}
|
||||||
|
to view the published collection.
|
||||||
|
</Alert>
|
||||||
|
);
|
||||||
|
if (query.isPending)
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="products-grid"
|
||||||
|
aria-busy="true"
|
||||||
|
aria-label="Loading collection"
|
||||||
|
>
|
||||||
|
{Array.from({ length: Math.min(limit, 4) }, (_, i) => (
|
||||||
|
<Skeleton key={i} variant="rectangular" height={280} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
if (query.isError)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ApiNotice error={query.error} />
|
||||||
|
<Button variant="outlined" onClick={() => query.refetch()}>
|
||||||
|
Try again
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{!query.data.length ? (
|
||||||
|
<Alert severity="info">
|
||||||
|
{search
|
||||||
|
? "No candles match your search. Try another name."
|
||||||
|
: "No published candles are available yet."}
|
||||||
|
</Alert>
|
||||||
|
) : (
|
||||||
|
<div className="products-grid">
|
||||||
|
{query.data.map((product) => (
|
||||||
|
<article className="prod-card" key={product.id}>
|
||||||
|
<Link
|
||||||
|
href={`/products/${product.id}`}
|
||||||
|
className="prod-img-wrap catalog-placeholder"
|
||||||
|
aria-label={`View ${product.name}`}
|
||||||
|
>
|
||||||
|
<Flame size={48} aria-hidden="true" />
|
||||||
|
<span>Mani Candles</span>
|
||||||
|
</Link>
|
||||||
|
<div className="prod-info">
|
||||||
|
<h3 className="prod-name">
|
||||||
|
<Link href={`/products/${product.id}`}>{product.name}</Link>
|
||||||
|
</h3>
|
||||||
|
<p className="prod-scent">
|
||||||
|
View available variants and pricing.
|
||||||
|
</p>
|
||||||
|
<Link
|
||||||
|
className="catalog-details"
|
||||||
|
href={`/products/${product.id}`}
|
||||||
|
>
|
||||||
|
View candle →
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{onNext && onPrevious && (
|
||||||
|
<div className="catalog-pagination">
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
disabled={offset === 0}
|
||||||
|
onClick={onPrevious}
|
||||||
|
>
|
||||||
|
Previous
|
||||||
|
</Button>
|
||||||
|
<span>Page {offset / limit + 1}</span>
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
disabled={query.data.length < limit || offset + limit > 10000}
|
||||||
|
onClick={onNext}
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -364,3 +364,10 @@
|
||||||
color: rgba(255,255,255,0.4);
|
color: rgba(255,255,255,0.4);
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nav-item:focus-within .nav-dropdown { opacity:1; pointer-events:auto; transform:translateX(-50%) translateY(0); }
|
||||||
|
.skip-link { position:fixed; top:-100px; left:1rem; z-index:1500; background:white; color:var(--brand-purple); padding:1rem; }
|
||||||
|
.skip-link:focus { top:.5rem; }
|
||||||
|
a:focus-visible,button:focus-visible { outline:3px solid var(--brand-purple); outline-offset:4px; }
|
||||||
|
.nav-link:focus-visible,.mobile-nav-link:focus-visible { outline-color:var(--brand-gold-light); }
|
||||||
|
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none!important; transition:none!important; scroll-behavior:auto!important; } }
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@ const logoPath = "/opengraph.jpg";
|
||||||
|
|
||||||
// ── Ticker messages ──────────────────────────────────────
|
// ── Ticker messages ──────────────────────────────────────
|
||||||
const TICKER_ITEMS = [
|
const TICKER_ITEMS = [
|
||||||
{ icon: <Flame size={12} />, text: "Free shipping on orders over $50" },
|
{ icon: <Flame size={12} />, text: "UAT — catalog and staff access" },
|
||||||
{ icon: <Sparkles size={12} />, text: "New Collection — Summer Solstice" },
|
{ icon: <Sparkles size={12} />, text: "Explore the published collection" },
|
||||||
{ icon: <Star size={12} />, text: "Handpoured in small batches" },
|
{ icon: <Star size={12} />, text: "Handpoured in small batches" },
|
||||||
{ icon: <Flame size={12} />, text: "100% Natural Soy Wax" },
|
{ icon: <Flame size={12} />, text: "100% Natural Soy Wax" },
|
||||||
{ icon: <Sparkles size={12} />, text: "Phthalate-free fragrance oils" },
|
{ icon: <Sparkles size={12} />, text: "Phthalate-free fragrance oils" },
|
||||||
{ icon: <Star size={12} />, text: "Gift wrapping available at checkout" },
|
{ icon: <Star size={12} />, text: "Ordering arrives in the commerce phase" },
|
||||||
];
|
];
|
||||||
|
|
||||||
// ── Nav structure with dropdowns ─────────────────────────
|
// ── Nav structure with dropdowns ─────────────────────────
|
||||||
|
|
@ -28,14 +28,7 @@ const NAV_LINKS = [
|
||||||
{
|
{
|
||||||
name: "Products",
|
name: "Products",
|
||||||
path: "/products",
|
path: "/products",
|
||||||
dropdown: [
|
dropdown: null,
|
||||||
{ label: "All Collections", path: "/products" },
|
|
||||||
null, // divider
|
|
||||||
{ label: "Floral Scents", path: "/products" },
|
|
||||||
{ label: "Fresh Scents", path: "/products" },
|
|
||||||
{ label: "Woody Scents", path: "/products" },
|
|
||||||
{ label: "Sweet Scents", path: "/products" },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "About",
|
name: "About",
|
||||||
|
|
@ -46,8 +39,8 @@ const NAV_LINKS = [
|
||||||
{ label: "Meet the Maker", path: "/about" },
|
{ label: "Meet the Maker", path: "/about" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Contact",
|
name: "Contact",
|
||||||
path: "/contact",
|
path: "/contact",
|
||||||
dropdown: [
|
dropdown: [
|
||||||
{ label: "Send a Message", path: "/contact" },
|
{ label: "Send a Message", path: "/contact" },
|
||||||
|
|
@ -55,7 +48,9 @@ const NAV_LINKS = [
|
||||||
null,
|
null,
|
||||||
{ label: "Follow on Instagram", path: "/contact" },
|
{ label: "Follow on Instagram", path: "/contact" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{ name: "Workspace", path: "/workspace", dropdown: null },
|
||||||
|
{ name: "Connection", path: "/connection", dropdown: null },
|
||||||
];
|
];
|
||||||
|
|
||||||
export function Layout({ children }: { children: React.ReactNode }) {
|
export function Layout({ children }: { children: React.ReactNode }) {
|
||||||
|
|
@ -80,7 +75,8 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
||||||
const allTickerItems = [...TICKER_ITEMS, ...TICKER_ITEMS];
|
const allTickerItems = [...TICKER_ITEMS, ...TICKER_ITEMS];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ minHeight: "100vh", display: "flex", flexDirection: "column" }}>
|
<Box sx={{ minHeight: "100vh", display: "flex", flexDirection: "column" }}>
|
||||||
|
<a className="skip-link" href="#main-content">Skip to content</a>
|
||||||
|
|
||||||
{/* ── Ticker Bar ── */}
|
{/* ── Ticker Bar ── */}
|
||||||
<Box
|
<Box
|
||||||
|
|
@ -138,7 +134,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
||||||
component="nav"
|
component="nav"
|
||||||
sx={{
|
sx={{
|
||||||
display: { xs: "none", md: "flex" },
|
display: { xs: "none", md: "flex" },
|
||||||
gap: 4,
|
gap: 2,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
overflow: "visible",
|
overflow: "visible",
|
||||||
position: "relative",
|
position: "relative",
|
||||||
|
|
@ -173,7 +169,10 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{/* Mobile Toggle */}
|
{/* Mobile Toggle */}
|
||||||
<IconButton
|
<IconButton
|
||||||
|
aria-label={mobileMenuOpen ? "Close navigation" : "Open navigation"}
|
||||||
|
aria-expanded={mobileMenuOpen}
|
||||||
|
aria-controls="mobile-navigation"
|
||||||
sx={{ display: { md: "none" }, color: "#ffffff" }}
|
sx={{ display: { md: "none" }, color: "#ffffff" }}
|
||||||
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
|
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
|
||||||
>
|
>
|
||||||
|
|
@ -189,7 +188,8 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
||||||
initial={{ opacity: 0, height: 0 }}
|
initial={{ opacity: 0, height: 0 }}
|
||||||
animate={{ opacity: 1, height: "auto" }}
|
animate={{ opacity: 1, height: "auto" }}
|
||||||
exit={{ opacity: 0, height: 0 }}
|
exit={{ opacity: 0, height: 0 }}
|
||||||
className="mobile-menu"
|
className="mobile-menu"
|
||||||
|
id="mobile-navigation"
|
||||||
>
|
>
|
||||||
{NAV_LINKS.map((link) => (
|
{NAV_LINKS.map((link) => (
|
||||||
<div className="mobile-nav-section" key={link.name}>
|
<div className="mobile-nav-section" key={link.name}>
|
||||||
|
|
@ -198,7 +198,8 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
||||||
<button
|
<button
|
||||||
className={`mobile-nav-link${location === link.path ? " active" : ""}`}
|
className={`mobile-nav-link${location === link.path ? " active" : ""}`}
|
||||||
style={{ background: "none", border: "none", textAlign: "left", cursor: "pointer", width: "100%", display: "flex", justifyContent: "space-between", alignItems: "center" }}
|
style={{ background: "none", border: "none", textAlign: "left", cursor: "pointer", width: "100%", display: "flex", justifyContent: "space-between", alignItems: "center" }}
|
||||||
onClick={() => setMobileOpenSection(mobileOpenSection === link.name ? null : link.name)}
|
onClick={() => setMobileOpenSection(mobileOpenSection === link.name ? null : link.name)}
|
||||||
|
aria-expanded={mobileOpenSection === link.name}
|
||||||
>
|
>
|
||||||
{link.name}
|
{link.name}
|
||||||
<ChevronDown
|
<ChevronDown
|
||||||
|
|
@ -247,7 +248,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
||||||
</AppBar>
|
</AppBar>
|
||||||
|
|
||||||
{/* ── Page Content — offset for ticker + appbar ── */}
|
{/* ── Page Content — offset for ticker + appbar ── */}
|
||||||
<Box component="main" sx={{ flexGrow: 1, pt: "112px" }}>
|
<Box component="main" id="main-content" tabIndex={-1} sx={{ flexGrow: 1, pt: "112px" }}>
|
||||||
<AnimatePresence mode="wait">
|
<AnimatePresence mode="wait">
|
||||||
<motion.div
|
<motion.div
|
||||||
key={location}
|
key={location}
|
||||||
|
|
@ -295,9 +296,9 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
||||||
<div className="footer-col">
|
<div className="footer-col">
|
||||||
<h4 className="footer-heading">Connect</h4>
|
<h4 className="footer-heading">Connect</h4>
|
||||||
<div style={{ display: "flex", gap: "0.75rem" }}>
|
<div style={{ display: "flex", gap: "0.75rem" }}>
|
||||||
<a href="#" className="social-btn"><Instagram size={18} /></a>
|
<span className="social-btn" aria-label="Instagram link pending"><Instagram size={18} /></span>
|
||||||
<a href="#" className="social-btn"><Facebook size={18} /></a>
|
<span className="social-btn" aria-label="Facebook link pending"><Facebook size={18} /></span>
|
||||||
<a href="#" className="social-btn"><Twitter size={18} /></a>
|
<span className="social-btn" aria-label="Twitter link pending"><Twitter size={18} /></span>
|
||||||
</div>
|
</div>
|
||||||
<p className="footer-copy">
|
<p className="footer-copy">
|
||||||
© {new Date().getFullYear()} Mani Candles Co. All rights reserved.
|
© {new Date().getFullYear()} Mani Candles Co. All rights reserved.
|
||||||
|
|
@ -307,4 +308,4 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
||||||
</footer>
|
</footer>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,185 @@
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
export const organizationSchema = z.string().uuid();
|
||||||
|
const productSummarySchema = z.object({
|
||||||
|
id: z.string().uuid(),
|
||||||
|
name: z.string(),
|
||||||
|
slug: z.string(),
|
||||||
|
});
|
||||||
|
export const productSchema = productSummarySchema.extend({
|
||||||
|
description: z.string(),
|
||||||
|
variants: z.array(
|
||||||
|
z.object({
|
||||||
|
id: z.string().uuid(),
|
||||||
|
sku: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
price: z.string().regex(/^\d+\.\d{2}$/),
|
||||||
|
currency: z.string(),
|
||||||
|
attributes: z.record(z.string()),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
groups: z.array(
|
||||||
|
z.object({
|
||||||
|
group: z.object({
|
||||||
|
id: z.string().uuid(),
|
||||||
|
name: z.string(),
|
||||||
|
slug: z.string(),
|
||||||
|
kind: z.enum(["CATEGORY", "COLLECTION"]),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
export type ProductSummary = z.infer<typeof productSummarySchema>;
|
||||||
|
export type Product = z.infer<typeof productSchema>;
|
||||||
|
const sessionSchema = z.object({
|
||||||
|
accessToken: z.string().min(1),
|
||||||
|
tokenType: z.literal("Bearer"),
|
||||||
|
expiresAt: z.string().datetime(),
|
||||||
|
});
|
||||||
|
export type Session = z.infer<typeof sessionSchema>;
|
||||||
|
const principalSchema = z.object({
|
||||||
|
userId: z.string().uuid(),
|
||||||
|
organizationId: z.string().uuid(),
|
||||||
|
sessionId: z.string().uuid(),
|
||||||
|
permissions: z.array(z.string()),
|
||||||
|
});
|
||||||
|
export type Principal = z.infer<typeof principalSchema>;
|
||||||
|
|
||||||
|
export class ApiError extends Error {
|
||||||
|
status: number;
|
||||||
|
code?: string;
|
||||||
|
requestId?: string;
|
||||||
|
constructor(
|
||||||
|
message: string,
|
||||||
|
status: number,
|
||||||
|
code?: string,
|
||||||
|
requestId?: string,
|
||||||
|
) {
|
||||||
|
super(message);
|
||||||
|
this.name = "ApiError";
|
||||||
|
this.status = status;
|
||||||
|
this.code = code;
|
||||||
|
this.requestId = requestId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiRequest(
|
||||||
|
path: string,
|
||||||
|
{
|
||||||
|
token,
|
||||||
|
body,
|
||||||
|
method = "GET",
|
||||||
|
signal,
|
||||||
|
}: {
|
||||||
|
token?: string;
|
||||||
|
body?: unknown;
|
||||||
|
method?: string;
|
||||||
|
signal?: AbortSignal;
|
||||||
|
} = {},
|
||||||
|
): Promise<unknown> {
|
||||||
|
let response: Response;
|
||||||
|
try {
|
||||||
|
const timeout = AbortSignal.timeout(15000);
|
||||||
|
response = await fetch(`/api/v1${path}`, {
|
||||||
|
method,
|
||||||
|
signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
|
||||||
|
headers: {
|
||||||
|
...(body === undefined ? {} : { "Content-Type": "application/json" }),
|
||||||
|
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||||
|
},
|
||||||
|
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof Error && error.name === "AbortError") throw error;
|
||||||
|
throw new ApiError(
|
||||||
|
"The service could not be reached. Check your connection and try again.",
|
||||||
|
0,
|
||||||
|
"NETWORK_ERROR",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (response.status === 204) return null;
|
||||||
|
const data = await response.json().catch(() => null);
|
||||||
|
if (!response.ok)
|
||||||
|
throw new ApiError(
|
||||||
|
typeof data?.message === "string"
|
||||||
|
? data.message
|
||||||
|
: "The service could not complete this request.",
|
||||||
|
response.status,
|
||||||
|
typeof data?.code === "string" ? data.code : undefined,
|
||||||
|
typeof data?.requestId === "string"
|
||||||
|
? data.requestId
|
||||||
|
: (response.headers.get("x-request-id") ?? undefined),
|
||||||
|
);
|
||||||
|
if (data === null)
|
||||||
|
throw new ApiError(
|
||||||
|
"The service returned an unexpected response.",
|
||||||
|
response.status,
|
||||||
|
"INVALID_RESPONSE",
|
||||||
|
);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
function parse<T>(schema: z.ZodType<T>, data: unknown): T {
|
||||||
|
const result = schema.safeParse(data);
|
||||||
|
if (!result.success)
|
||||||
|
throw new ApiError(
|
||||||
|
"The service returned an unexpected response.",
|
||||||
|
200,
|
||||||
|
"INVALID_RESPONSE",
|
||||||
|
);
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
|
export async function listProducts(
|
||||||
|
organization: string,
|
||||||
|
search = "",
|
||||||
|
offset = 0,
|
||||||
|
limit = 12,
|
||||||
|
signal?: AbortSignal,
|
||||||
|
) {
|
||||||
|
organizationSchema.parse(organization);
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
limit: String(limit),
|
||||||
|
offset: String(offset),
|
||||||
|
...(search ? { search } : {}),
|
||||||
|
});
|
||||||
|
return parse(
|
||||||
|
z.array(productSummarySchema),
|
||||||
|
await apiRequest(`/storefront/${organization}/products?${params}`, {
|
||||||
|
signal,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export async function getProduct(
|
||||||
|
organization: string,
|
||||||
|
id: string,
|
||||||
|
signal?: AbortSignal,
|
||||||
|
) {
|
||||||
|
organizationSchema.parse(organization);
|
||||||
|
z.string().uuid().parse(id);
|
||||||
|
return parse(
|
||||||
|
productSchema,
|
||||||
|
await apiRequest(`/storefront/${organization}/products/${id}`, { signal }),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export async function login(
|
||||||
|
organizationId: string,
|
||||||
|
email: string,
|
||||||
|
password: string,
|
||||||
|
) {
|
||||||
|
organizationSchema.parse(organizationId);
|
||||||
|
return parse(
|
||||||
|
sessionSchema,
|
||||||
|
await apiRequest("/auth/login", {
|
||||||
|
method: "POST",
|
||||||
|
body: { organizationId, email, password },
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export async function getPrincipal(token: string) {
|
||||||
|
return parse(principalSchema, await apiRequest("/auth/me", { token }));
|
||||||
|
}
|
||||||
|
export async function healthCheck(kind: "live" | "ready") {
|
||||||
|
return parse(
|
||||||
|
z.object({ status: z.literal("ok") }),
|
||||||
|
await apiRequest(`/health/${kind}`),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
import {
|
||||||
|
createContext,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
|
import {
|
||||||
|
apiRequest,
|
||||||
|
ApiError,
|
||||||
|
getPrincipal,
|
||||||
|
login,
|
||||||
|
organizationSchema,
|
||||||
|
type Principal,
|
||||||
|
type Session,
|
||||||
|
} from "./api";
|
||||||
|
|
||||||
|
const PlatformContext = createContext<{
|
||||||
|
organization: string;
|
||||||
|
setOrganization: (value: string) => void;
|
||||||
|
principal: Principal | null;
|
||||||
|
signIn: (email: string, password: string) => Promise<void>;
|
||||||
|
signOut: () => Promise<void>;
|
||||||
|
notice: string;
|
||||||
|
} | null>(null);
|
||||||
|
function initialOrganization() {
|
||||||
|
let value = import.meta.env.VITE_ORGANIZATION_ID || "";
|
||||||
|
try {
|
||||||
|
value = localStorage.getItem("mani.organization") || value;
|
||||||
|
} catch {
|
||||||
|
/* Storage can be disabled. */
|
||||||
|
}
|
||||||
|
return organizationSchema.safeParse(value).success ? value : "";
|
||||||
|
}
|
||||||
|
export function PlatformProvider({ children }: { children: ReactNode }) {
|
||||||
|
const [organization, updateOrganization] = useState(initialOrganization);
|
||||||
|
const [session, setSession] = useState<Session | null>(null);
|
||||||
|
const [principal, setPrincipal] = useState<Principal | null>(null);
|
||||||
|
const [notice, setNotice] = useState("");
|
||||||
|
const loginVersion = useRef(0);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!session) return;
|
||||||
|
const timer = setTimeout(
|
||||||
|
() => {
|
||||||
|
setSession(null);
|
||||||
|
setPrincipal(null);
|
||||||
|
setNotice("Your session expired. Sign in again.");
|
||||||
|
},
|
||||||
|
Math.max(0, Date.parse(session.expiresAt) - Date.now()),
|
||||||
|
);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [session]);
|
||||||
|
function setOrganization(value: string) {
|
||||||
|
organizationSchema.parse(value);
|
||||||
|
if (value !== organization) {
|
||||||
|
loginVersion.current += 1;
|
||||||
|
setSession(null);
|
||||||
|
setPrincipal(null);
|
||||||
|
}
|
||||||
|
updateOrganization(value);
|
||||||
|
setNotice("");
|
||||||
|
try {
|
||||||
|
localStorage.setItem("mani.organization", value);
|
||||||
|
} catch {
|
||||||
|
/* The in-memory setting still works. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function signIn(email: string, password: string) {
|
||||||
|
const version = ++loginVersion.current;
|
||||||
|
const next = await login(organization, email, password);
|
||||||
|
try {
|
||||||
|
const me = await getPrincipal(next.accessToken);
|
||||||
|
if (version !== loginVersion.current)
|
||||||
|
throw new Error(
|
||||||
|
"The connection changed during sign-in. Please try again.",
|
||||||
|
);
|
||||||
|
if (me.organizationId !== organization)
|
||||||
|
throw new Error(
|
||||||
|
"The session organization does not match the configured organization.",
|
||||||
|
);
|
||||||
|
setSession(next);
|
||||||
|
setPrincipal(me);
|
||||||
|
setNotice("");
|
||||||
|
} catch (error) {
|
||||||
|
await apiRequest("/auth/logout", {
|
||||||
|
method: "POST",
|
||||||
|
token: next.accessToken,
|
||||||
|
}).catch(() => {});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function signOut() {
|
||||||
|
loginVersion.current += 1;
|
||||||
|
if (!session) return;
|
||||||
|
try {
|
||||||
|
await apiRequest("/auth/logout", {
|
||||||
|
method: "POST",
|
||||||
|
token: session.accessToken,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (!(error instanceof ApiError && error.status === 401)) throw error;
|
||||||
|
}
|
||||||
|
setSession(null);
|
||||||
|
setPrincipal(null);
|
||||||
|
setNotice("");
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<PlatformContext.Provider
|
||||||
|
value={{
|
||||||
|
organization,
|
||||||
|
setOrganization,
|
||||||
|
principal,
|
||||||
|
signIn,
|
||||||
|
signOut,
|
||||||
|
notice,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</PlatformContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function usePlatform() {
|
||||||
|
const context = useContext(PlatformContext);
|
||||||
|
if (!context) throw new Error("PlatformProvider is missing");
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,128 @@
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Link } from "wouter";
|
||||||
|
import Container from "@mui/material/Container";
|
||||||
|
import Paper from "@mui/material/Paper";
|
||||||
|
import TextField from "@mui/material/TextField";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
import Alert from "@mui/material/Alert";
|
||||||
|
import { healthCheck, organizationSchema } from "@/lib/api";
|
||||||
|
import { usePlatform } from "@/lib/platform";
|
||||||
|
import { ApiNotice } from "@/components/ApiNotice";
|
||||||
|
import "./workspace.css";
|
||||||
|
|
||||||
|
export default function ConnectionPage() {
|
||||||
|
const { organization, setOrganization, principal, signOut } = usePlatform();
|
||||||
|
const [draft, setDraft] = useState(organization);
|
||||||
|
const [error, setError] = useState<unknown>(null);
|
||||||
|
const [saved, setSaved] = useState(false);
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
const [checks, setChecks] = useState<PromiseSettledResult<unknown>[] | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
const [checking, setChecking] = useState(false);
|
||||||
|
async function check() {
|
||||||
|
setChecking(true);
|
||||||
|
setChecks(null);
|
||||||
|
setChecks(
|
||||||
|
await Promise.allSettled([healthCheck("live"), healthCheck("ready")]),
|
||||||
|
);
|
||||||
|
setChecking(false);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<section className="workspace-page">
|
||||||
|
<Container maxWidth="md">
|
||||||
|
<h1>Platform Connection</h1>
|
||||||
|
<p className="workspace-intro">
|
||||||
|
Connect to your organization on the deployed Mani Candles backend.
|
||||||
|
</p>
|
||||||
|
<Paper variant="outlined" className="workspace-panel">
|
||||||
|
<h2>Organization</h2>
|
||||||
|
<p>
|
||||||
|
Use the organization UUID returned by the backend owner bootstrap.
|
||||||
|
Public account registration is not available.
|
||||||
|
</p>
|
||||||
|
<form
|
||||||
|
className="workspace-form"
|
||||||
|
onSubmit={async (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
setSaved(false);
|
||||||
|
setError(null);
|
||||||
|
const result = organizationSchema.safeParse(draft.trim());
|
||||||
|
if (!result.success) {
|
||||||
|
setError(new Error("Enter a valid organization UUID."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
if (principal && result.data !== organization) await signOut();
|
||||||
|
setOrganization(result.data);
|
||||||
|
setSaved(true);
|
||||||
|
} catch (error) {
|
||||||
|
setError(error);
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextField
|
||||||
|
label="Organization UUID"
|
||||||
|
required
|
||||||
|
value={draft}
|
||||||
|
onChange={(event) => {
|
||||||
|
setDraft(event.target.value);
|
||||||
|
setSaved(false);
|
||||||
|
}}
|
||||||
|
helperText="Only the organization ID is saved locally; credentials are not."
|
||||||
|
/>
|
||||||
|
<ApiNotice error={error} />
|
||||||
|
<Button type="submit" variant="contained" disabled={busy}>
|
||||||
|
{busy ? "Saving…" : "Save connection"}
|
||||||
|
</Button>
|
||||||
|
{saved && (
|
||||||
|
<Alert severity="success">
|
||||||
|
Connection saved.{" "}
|
||||||
|
<Link href="/products">
|
||||||
|
<u>Browse candles</u>
|
||||||
|
</Link>{" "}
|
||||||
|
or{" "}
|
||||||
|
<Link href="/workspace">
|
||||||
|
<u>sign in</u>
|
||||||
|
</Link>
|
||||||
|
.
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
</form>
|
||||||
|
<hr />
|
||||||
|
<h2>Service checks</h2>
|
||||||
|
<Button variant="outlined" disabled={checking} onClick={check}>
|
||||||
|
{checking ? "Checking…" : "Run health checks"}
|
||||||
|
</Button>
|
||||||
|
<div aria-live="polite">
|
||||||
|
{checks?.map((result, index) => (
|
||||||
|
<div className="health-result" key={index}>
|
||||||
|
<Alert
|
||||||
|
severity={result.status === "fulfilled" ? "success" : "error"}
|
||||||
|
>
|
||||||
|
{index ? "Database readiness" : "Service liveness"}:{" "}
|
||||||
|
{result.status === "fulfilled" ? "Passed" : "Failed"}
|
||||||
|
</Alert>
|
||||||
|
{result.status === "rejected" && (
|
||||||
|
<ApiNotice error={result.reason} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<p className="workspace-intro">
|
||||||
|
<a
|
||||||
|
href="https://manicandles-backend.midastix.com/api/docs"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
<u>Open API documentation ↗</u>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</Paper>
|
||||||
|
</Container>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
import { Mail, MapPin, Phone, Instagram } from "lucide-react";
|
import { Mail, MapPin, Phone, Instagram } from "lucide-react";
|
||||||
import { HeartHandshake } from "lucide-react";
|
|
||||||
import { useState } from "react";
|
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Container from "@mui/material/Container";
|
import Container from "@mui/material/Container";
|
||||||
import "./contact.css";
|
import "./contact.css";
|
||||||
|
|
@ -12,14 +12,6 @@ const fadeInUp = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ContactPage() {
|
export default function ContactPage() {
|
||||||
const [formStatus, setFormStatus] = useState<"idle" | "submitting" | "success">("idle");
|
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent) => {
|
|
||||||
e.preventDefault();
|
|
||||||
setFormStatus("submitting");
|
|
||||||
setTimeout(() => setFormStatus("success"), 1500);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
{/* ── Hero ── */}
|
{/* ── Hero ── */}
|
||||||
|
|
@ -47,9 +39,9 @@ export default function ContactPage() {
|
||||||
<h2>Contact Information</h2>
|
<h2>Contact Information</h2>
|
||||||
<div className="contact-info-list">
|
<div className="contact-info-list">
|
||||||
{[
|
{[
|
||||||
{ Icon: Mail, label: "Email", value: <a href="mailto:hello@manicandles.co">hello@manicandles.co</a> },
|
{ Icon: Mail, label: "Email", value: <>Contact address pending</> },
|
||||||
{ Icon: Phone, label: "Phone", value: <>Available Mon–Fri, 9am–5pm EST<br />+1 (555) 123-4567</> },
|
{ Icon: Phone, label: "Phone", value: <>Contact hours pending<br />Phone pending</> },
|
||||||
{ Icon: MapPin, label: "Studio", value: <>New York, NY<br />(By appointment only)</> },
|
{ Icon: MapPin, label: "Studio", value: <>Studio details pending<br />(By appointment only)</> },
|
||||||
].map(({ Icon, label, value }) => (
|
].map(({ Icon, label, value }) => (
|
||||||
<div key={label} className="contact-info-item">
|
<div key={label} className="contact-info-item">
|
||||||
<div className="contact-info-icon"><Icon size={20} /></div>
|
<div className="contact-info-icon"><Icon size={20} /></div>
|
||||||
|
|
@ -64,10 +56,10 @@ export default function ContactPage() {
|
||||||
<div className="contact-social-box">
|
<div className="contact-social-box">
|
||||||
<h3>Follow Our Journey</h3>
|
<h3>Follow Our Journey</h3>
|
||||||
<p>Join our community on Instagram for behind-the-scenes peeks, styling inspiration, and launch announcements.</p>
|
<p>Join our community on Instagram for behind-the-scenes peeks, styling inspiration, and launch announcements.</p>
|
||||||
<a href="#" className="contact-ig-link">
|
<span className="contact-ig-link">
|
||||||
<Instagram size={20} />
|
<Instagram size={20} />
|
||||||
<span>@manicandles.co</span>
|
<span>Social link pending</span>
|
||||||
</a>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
|
|
@ -80,46 +72,10 @@ export default function ContactPage() {
|
||||||
>
|
>
|
||||||
<div className="contact-form-top-bar" />
|
<div className="contact-form-top-bar" />
|
||||||
|
|
||||||
{formStatus === "success" ? (
|
<h2>Send a Message</h2>
|
||||||
<motion.div
|
<p role="status">Contact message delivery is not supported by the deployed API. This form will be connected when a contact service is available; no message is collected or sent during UAT.</p>
|
||||||
className="contact-success"
|
|
||||||
initial={{ opacity: 0, scale: 0.9 }}
|
|
||||||
animate={{ opacity: 1, scale: 1 }}
|
|
||||||
>
|
|
||||||
<div className="success-icon-wrap"><HeartHandshake size={32} /></div>
|
|
||||||
<h3>Thank you!</h3>
|
|
||||||
<p>Your message has been received. We will get back to you as soon as possible.</p>
|
|
||||||
<button className="send-another-btn" onClick={() => setFormStatus("idle")}>Send another</button>
|
|
||||||
</motion.div>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<h2>Send a Message</h2>
|
|
||||||
<form onSubmit={handleSubmit}>
|
|
||||||
<div className="form-row">
|
|
||||||
<div className="form-field">
|
|
||||||
<label htmlFor="name" className="form-label">Name</label>
|
|
||||||
<input id="name" type="text" className="form-input" placeholder="Your name" required />
|
|
||||||
</div>
|
|
||||||
<div className="form-field">
|
|
||||||
<label htmlFor="email" className="form-label">Email</label>
|
|
||||||
<input id="email" type="email" className="form-input" placeholder="Your email" required />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="form-field">
|
|
||||||
<label htmlFor="subject" className="form-label">Subject</label>
|
|
||||||
<input id="subject" type="text" className="form-input" placeholder="How can we help?" required />
|
|
||||||
</div>
|
|
||||||
<div className="form-field">
|
|
||||||
<label htmlFor="message" className="form-label">Message</label>
|
|
||||||
<textarea id="message" className="form-textarea" placeholder="Write your message here..." required />
|
|
||||||
</div>
|
|
||||||
<button type="submit" className="form-submit" disabled={formStatus === "submitting"}>
|
|
||||||
{formStatus === "submitting" ? "Sending..." : "Send Message"}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</Container>
|
</Container>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -130,4 +86,4 @@ export default function ContactPage() {
|
||||||
</section>
|
</section>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
import { Link } from "wouter";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import Container from "@mui/material/Container";
|
||||||
|
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 { usePlatform } from "@/lib/platform";
|
||||||
|
import { ApiNotice } from "@/components/ApiNotice";
|
||||||
|
import "./products.css";
|
||||||
|
|
||||||
|
export default function ProductPage({ id }: { id: string }) {
|
||||||
|
const { organization } = usePlatform();
|
||||||
|
const query = useQuery({
|
||||||
|
queryKey: ["product", organization, id],
|
||||||
|
queryFn: ({ signal }) => getProduct(organization, id, signal),
|
||||||
|
enabled: Boolean(organization),
|
||||||
|
retry: false,
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<section className="products-body">
|
||||||
|
<Container maxWidth="md">
|
||||||
|
<Link href="/products" className="catalog-details">
|
||||||
|
← Back to collection
|
||||||
|
</Link>
|
||||||
|
{!organization ? (
|
||||||
|
<Alert severity="info" sx={{ mt: 3 }}>
|
||||||
|
Configure your organization under{" "}
|
||||||
|
<Link href="/connection">
|
||||||
|
<u>Connection</u>
|
||||||
|
</Link>{" "}
|
||||||
|
first.
|
||||||
|
</Alert>
|
||||||
|
) : query.isPending ? (
|
||||||
|
<Skeleton variant="rectangular" height={300} sx={{ mt: 3 }} />
|
||||||
|
) : query.isError ? (
|
||||||
|
<>
|
||||||
|
<ApiNotice error={query.error} />
|
||||||
|
<Button onClick={() => query.refetch()}>Try again</Button>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div className="product-detail">
|
||||||
|
<h1>{query.data.name}</h1>
|
||||||
|
<p className="product-description">
|
||||||
|
{query.data.description ||
|
||||||
|
"Explore the available candle variants below."}
|
||||||
|
</p>
|
||||||
|
<div className="product-groups">
|
||||||
|
{query.data.groups.map(({ group }) => (
|
||||||
|
<Chip key={group.id} label={group.name} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<h2>Available variants</h2>
|
||||||
|
{!query.data.variants.length ? (
|
||||||
|
<Alert severity="info">No active variants are available.</Alert>
|
||||||
|
) : (
|
||||||
|
<ul className="variant-list">
|
||||||
|
{query.data.variants.map((variant) => (
|
||||||
|
<li key={variant.id}>
|
||||||
|
<div>
|
||||||
|
<h3>{variant.name}</h3>
|
||||||
|
<small>SKU: {variant.sku}</small>
|
||||||
|
<dl>
|
||||||
|
{Object.entries(variant.attributes).map(
|
||||||
|
([key, value]) => (
|
||||||
|
<div key={key}>
|
||||||
|
<dt>{key.replaceAll("_", " ")}</dt>
|
||||||
|
<dd>{value}</dd>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
<strong>
|
||||||
|
{variant.currency} {variant.price}
|
||||||
|
</strong>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
<Alert severity="info">
|
||||||
|
Ordering will be available in the commerce phase. Payment and
|
||||||
|
shipping integrations are not enabled yet.
|
||||||
|
</Alert>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Container>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,100 +1,77 @@
|
||||||
import { motion } from "framer-motion";
|
import { useEffect, useState } from "react";
|
||||||
import { useState } from "react";
|
import Box from "@mui/material/Box";
|
||||||
import Box from "@mui/material/Box";
|
import Container from "@mui/material/Container";
|
||||||
import Container from "@mui/material/Container";
|
import TextField from "@mui/material/TextField";
|
||||||
import birthdayImage from "@/assets/images/product-birthday.png";
|
import Button from "@mui/material/Button";
|
||||||
import eucalyptusImage from "@/assets/images/product-eucalyptus.png";
|
import { Catalog } from "@/components/Catalog";
|
||||||
import jasmineImage from "@/assets/images/product-jasmine.png";
|
import { usePlatform } from "@/lib/platform";
|
||||||
import lavenderImage from "@/assets/images/product-lavender.png";
|
import "./products.css";
|
||||||
import linenImage from "@/assets/images/product-linen.png";
|
|
||||||
import oudImage from "@/assets/images/product-oud.png";
|
export default function ProductsPage() {
|
||||||
import roseImage from "@/assets/images/product-rose.png";
|
const { organization } = usePlatform();
|
||||||
import sandalwoodImage from "@/assets/images/product-sandalwood.png";
|
const [draft, setDraft] = useState("");
|
||||||
import "./products.css";
|
const [search, setSearch] = useState("");
|
||||||
|
const [offset, setOffset] = useState(0);
|
||||||
const PRODUCTS = [
|
useEffect(() => {
|
||||||
{ id: 1, name: "Lavender Dream", scent: "Calming French Lavender, Vanilla, & Bergamot", price: "$28", image: lavenderImage, category: "Floral" },
|
setOffset(0);
|
||||||
{ id: 2, name: "Rose & Vanilla", scent: "Damask Rose, Sweet Vanilla Bean, & Amber", price: "$32", image: roseImage, category: "Floral" },
|
setSearch("");
|
||||||
{ id: 3, name: "Eucalyptus Mint", scent: "Fresh Eucalyptus, Spearmint, & Cedar", price: "$28", image: eucalyptusImage, category: "Fresh" },
|
setDraft("");
|
||||||
{ id: 4, name: "Oud & Amber", scent: "Rich Oud Wood, Warm Amber, & Dark Musk", price: "$36", image: oudImage, category: "Woody" },
|
}, [organization]);
|
||||||
{ id: 5, name: "Jasmine Night", scent: "Night-blooming Jasmine, Ylang Ylang, & Sandalwood", price: "$30", image: jasmineImage, category: "Floral" },
|
return (
|
||||||
{ id: 6, name: "Sandalwood Cedar", scent: "Indian Sandalwood, Cedarwood, & Patchouli", price: "$34", image: sandalwoodImage, category: "Woody" },
|
<Box>
|
||||||
{ id: 7, name: "Fresh Linen", scent: "Crisp Cotton, White Tea, & Lily of the Valley", price: "$26", image: linenImage, category: "Fresh" },
|
<section className="products-hero">
|
||||||
{ id: 8, name: "Birthday Cake", scent: "Vanilla Buttercream, Sugar Spun, & Joy", price: "$28", image: birthdayImage, category: "Sweet" },
|
<Container maxWidth="md">
|
||||||
];
|
<h1>Our Collection</h1>
|
||||||
|
<p>
|
||||||
export default function ProductsPage() {
|
Explore our published candles and find the right variant for your
|
||||||
const [filter, setFilter] = useState("All");
|
everyday rituals.
|
||||||
const categories = ["All", ...Array.from(new Set(PRODUCTS.map((p) => p.category)))];
|
</p>
|
||||||
const filteredProducts = filter === "All" ? PRODUCTS : PRODUCTS.filter((p) => p.category === filter);
|
<div className="section-divider" />
|
||||||
|
</Container>
|
||||||
return (
|
</section>
|
||||||
<Box>
|
<section className="products-body">
|
||||||
{/* ── Hero ── */}
|
<Container maxWidth="xl">
|
||||||
<section className="products-hero">
|
{organization && (
|
||||||
<Container maxWidth="md">
|
<form
|
||||||
<motion.div
|
className="catalog-search"
|
||||||
initial={{ opacity: 0, y: 30 }}
|
onSubmit={(e) => {
|
||||||
animate={{ opacity: 1, y: 0 }}
|
e.preventDefault();
|
||||||
transition={{ duration: 0.8 }}
|
setSearch(draft.trim());
|
||||||
>
|
setOffset(0);
|
||||||
<h1>Our Collection</h1>
|
}}
|
||||||
<p>Each candle is meticulously hand-poured with natural soy wax and premium fragrance oils, designed to elevate your everyday rituals.</p>
|
>
|
||||||
<div className="section-divider" />
|
<TextField
|
||||||
</motion.div>
|
label="Search candles"
|
||||||
</Container>
|
type="search"
|
||||||
</section>
|
size="small"
|
||||||
|
value={draft}
|
||||||
{/* ── Products Body ── */}
|
inputProps={{ maxLength: 100 }}
|
||||||
<section className="products-body">
|
onChange={(e) => setDraft(e.target.value)}
|
||||||
<Container maxWidth="xl">
|
/>
|
||||||
{/* Filter Bar */}
|
<Button type="submit" variant="contained">
|
||||||
<motion.div
|
Search
|
||||||
className="filter-bar"
|
</Button>
|
||||||
initial={{ opacity: 0 }}
|
{search && (
|
||||||
animate={{ opacity: 1 }}
|
<Button
|
||||||
transition={{ delay: 0.2 }}
|
onClick={() => {
|
||||||
>
|
setDraft("");
|
||||||
{categories.map((cat) => (
|
setSearch("");
|
||||||
<button
|
setOffset(0);
|
||||||
key={cat}
|
}}
|
||||||
className={`filter-btn${filter === cat ? " active" : ""}`}
|
>
|
||||||
onClick={() => setFilter(cat)}
|
Clear
|
||||||
>
|
</Button>
|
||||||
{cat}
|
)}
|
||||||
</button>
|
</form>
|
||||||
))}
|
)}
|
||||||
</motion.div>
|
<Catalog
|
||||||
|
search={search}
|
||||||
{/* Grid */}
|
offset={offset}
|
||||||
<div className="products-grid">
|
onPrevious={() => setOffset((n) => Math.max(0, n - 12))}
|
||||||
{filteredProducts.map((product, index) => (
|
onNext={() => setOffset((n) => n + 12)}
|
||||||
<motion.div
|
/>
|
||||||
key={product.id}
|
</Container>
|
||||||
className="prod-card"
|
</section>
|
||||||
initial={{ opacity: 0, y: 30 }}
|
</Box>
|
||||||
whileInView={{ opacity: 1, y: 0 }}
|
);
|
||||||
viewport={{ once: true, margin: "-50px" }}
|
}
|
||||||
transition={{ delay: (index % 4) * 0.1, duration: 0.6 }}
|
|
||||||
>
|
|
||||||
<div className="prod-img-wrap">
|
|
||||||
<img src={product.image} alt={product.name} />
|
|
||||||
<div className="prod-overlay">
|
|
||||||
<button className="prod-overlay-btn">Add to Cart</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="prod-info">
|
|
||||||
<div>
|
|
||||||
<h3 className="prod-name">{product.name}</h3>
|
|
||||||
<p className="prod-scent">{product.scent}</p>
|
|
||||||
</div>
|
|
||||||
<p className="prod-price">{product.price}</p>
|
|
||||||
</div>
|
|
||||||
</motion.div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</Container>
|
|
||||||
</section>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
import { useState, type FormEvent } from "react";
|
||||||
|
import { Link } from "wouter";
|
||||||
|
import Container from "@mui/material/Container";
|
||||||
|
import Paper from "@mui/material/Paper";
|
||||||
|
import TextField from "@mui/material/TextField";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
import Alert from "@mui/material/Alert";
|
||||||
|
import { usePlatform } from "@/lib/platform";
|
||||||
|
import { ApiNotice } from "@/components/ApiNotice";
|
||||||
|
import "./workspace.css";
|
||||||
|
|
||||||
|
export default function WorkspacePage() {
|
||||||
|
const { organization, principal, signIn, signOut, notice } = usePlatform();
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
const [error, setError] = useState<unknown>(null);
|
||||||
|
async function submit(event: FormEvent<HTMLFormElement>) {
|
||||||
|
event.preventDefault();
|
||||||
|
const form = event.currentTarget;
|
||||||
|
const fields = new FormData(form);
|
||||||
|
setBusy(true);
|
||||||
|
setError(null);
|
||||||
|
const email = String(fields.get("email"));
|
||||||
|
const password = String(fields.get("password"));
|
||||||
|
form.reset();
|
||||||
|
try {
|
||||||
|
await signIn(email, password);
|
||||||
|
} catch (error) {
|
||||||
|
setError(error);
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function logout() {
|
||||||
|
setBusy(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
await signOut();
|
||||||
|
} catch (error) {
|
||||||
|
setError(error);
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<section className="workspace-page">
|
||||||
|
<Container maxWidth="md">
|
||||||
|
<h1>Staff Workspace</h1>
|
||||||
|
<p className="workspace-intro">
|
||||||
|
Sign in with your approved Mani Candles account.
|
||||||
|
</p>
|
||||||
|
<Paper variant="outlined" className="workspace-panel">
|
||||||
|
<ApiNotice error={error} />
|
||||||
|
{notice && <Alert severity="info">{notice}</Alert>}
|
||||||
|
{principal ? (
|
||||||
|
<>
|
||||||
|
<h2>Your session</h2>
|
||||||
|
<p className="workspace-id">
|
||||||
|
Organization: {principal.organizationId}
|
||||||
|
</p>
|
||||||
|
<p className="workspace-id">User: {principal.userId}</p>
|
||||||
|
<h3>Effective permissions</h3>
|
||||||
|
{principal.permissions.length ? (
|
||||||
|
<ul className="permission-list">
|
||||||
|
{principal.permissions.map((permission) => (
|
||||||
|
<li key={permission}>{permission}</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
) : (
|
||||||
|
<p>No permissions assigned. Contact your administrator.</p>
|
||||||
|
)}
|
||||||
|
<p className="workspace-intro">
|
||||||
|
Operational tools will be connected in the following frontend
|
||||||
|
phases.
|
||||||
|
</p>
|
||||||
|
<Button variant="contained" disabled={busy} onClick={logout}>
|
||||||
|
{busy ? "Signing out…" : "Sign out"}
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<form className="workspace-form" onSubmit={submit}>
|
||||||
|
{!organization && (
|
||||||
|
<Alert severity="info">
|
||||||
|
Set your organization on the{" "}
|
||||||
|
<Link href="/connection">
|
||||||
|
<u>Connection page</u>
|
||||||
|
</Link>{" "}
|
||||||
|
before signing in. The first owner must be provisioned on the
|
||||||
|
backend.
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
<TextField
|
||||||
|
label="Email address"
|
||||||
|
name="email"
|
||||||
|
type="email"
|
||||||
|
autoComplete="username"
|
||||||
|
required
|
||||||
|
inputProps={{ maxLength: 254 }}
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
label="Password"
|
||||||
|
name="password"
|
||||||
|
type="password"
|
||||||
|
autoComplete="current-password"
|
||||||
|
required
|
||||||
|
inputProps={{ maxLength: 128 }}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
type="submit"
|
||||||
|
disabled={busy || !organization}
|
||||||
|
>
|
||||||
|
{busy ? "Signing in…" : "Sign in"}
|
||||||
|
</Button>
|
||||||
|
<small>
|
||||||
|
Sessions stay in memory. Reloading or closing this page requires
|
||||||
|
a new sign-in.
|
||||||
|
</small>
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
|
</Paper>
|
||||||
|
</Container>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -5,9 +5,9 @@ import { Flame, Heart, Leaf, Sparkles } from "lucide-react";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Container from "@mui/material/Container";
|
import Container from "@mui/material/Container";
|
||||||
import lavenderImage from "@/assets/images/image-removebg-preview.png";
|
import lavenderImage from "@/assets/images/image-removebg-preview.png";
|
||||||
import roseImage from "@/assets/images/product-rose.png";
|
import { Catalog } from "@/components/Catalog";
|
||||||
import eucalyptusImage from "@/assets/images/product-eucalyptus.png";
|
|
||||||
import oudImage from "@/assets/images/product-oud.png";
|
|
||||||
import "./home.css";
|
import "./home.css";
|
||||||
|
|
||||||
const logoPath = "/opengraph.jpg";
|
const logoPath = "/opengraph.jpg";
|
||||||
|
|
@ -233,38 +233,13 @@ export default function Home() {
|
||||||
<Container maxWidth="xl">
|
<Container maxWidth="xl">
|
||||||
<motion.div initial="hidden" whileInView="visible" viewport={{ once: true }} variants={fadeInUp} className="home-products-header">
|
<motion.div initial="hidden" whileInView="visible" viewport={{ once: true }} variants={fadeInUp} className="home-products-header">
|
||||||
<div>
|
<div>
|
||||||
<h2>Curated Favorites</h2>
|
<h2>From Our Collection</h2>
|
||||||
<div className="section-divider" style={{ margin: "0.5rem 0 0", width: 80 }} />
|
<div className="section-divider" style={{ margin: "0.5rem 0 0", width: 80 }} />
|
||||||
</div>
|
</div>
|
||||||
<Link href="/products" className="view-all-link">View All Candles</Link>
|
<Link href="/products" className="view-all-link">View All Candles</Link>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
<div className="product-grid">
|
<Catalog limit={4}/>
|
||||||
{[
|
|
||||||
{ id: 1, name: "Lavender Dream", image: lavenderImage, price: "$28" },
|
|
||||||
{ id: 2, name: "Rose & Vanilla", image: roseImage, price: "$32" },
|
|
||||||
{ id: 3, name: "Eucalyptus Mint", image: eucalyptusImage, price: "$28" },
|
|
||||||
{ id: 4, name: "Oud & Amber", image: oudImage, price: "$36" },
|
|
||||||
].map((product, i) => (
|
|
||||||
<motion.div
|
|
||||||
key={product.id}
|
|
||||||
className="product-card"
|
|
||||||
initial="hidden"
|
|
||||||
whileInView="visible"
|
|
||||||
viewport={{ once: true }}
|
|
||||||
variants={{ hidden: { opacity: 0, y: 20 }, visible: { opacity: 1, y: 0, transition: { delay: i * 0.1, duration: 0.6 } } }}
|
|
||||||
>
|
|
||||||
<div className="product-img-wrap">
|
|
||||||
<img src={product.image} alt={product.name} />
|
|
||||||
<div className="product-overlay">
|
|
||||||
<button className="product-overlay-btn">Quick Add</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<h3 className="product-name">{product.name}</h3>
|
|
||||||
<p className="product-price">{product.price}</p>
|
|
||||||
</motion.div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</Container>
|
</Container>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
@ -284,13 +259,10 @@ export default function Home() {
|
||||||
<section className="home-newsletter">
|
<section className="home-newsletter">
|
||||||
<motion.div initial="hidden" whileInView="visible" viewport={{ once: true }} variants={fadeInUp}>
|
<motion.div initial="hidden" whileInView="visible" viewport={{ once: true }} variants={fadeInUp}>
|
||||||
<h2>Join Our Sanctuary</h2>
|
<h2>Join Our Sanctuary</h2>
|
||||||
<p>Subscribe to receive gentle updates on new collections, exclusive access, and a little light in your inbox.</p>
|
<p>Collection updates and consent-aware messaging will arrive in a later phase.</p>
|
||||||
<form className="newsletter-form" onSubmit={(e) => e.preventDefault()}>
|
<p role="status">Newsletter subscription is not available during this UAT phase.</p>
|
||||||
<input type="email" className="newsletter-input" placeholder="Your email address" required />
|
|
||||||
<button type="submit" className="newsletter-btn">Subscribe</button>
|
|
||||||
</form>
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</section>
|
</section>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,3 +171,21 @@
|
||||||
font-size: 1.05rem;
|
font-size: 1.05rem;
|
||||||
color: var(--brand-gold);
|
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; }
|
||||||
|
.catalog-details { display:inline-block; color:var(--brand-purple); font-weight:600; padding:.5rem 0; }
|
||||||
|
.catalog-search { display:flex; gap:1rem; flex-wrap:wrap; justify-content:center; margin-bottom:3rem; }
|
||||||
|
.catalog-pagination { display:flex; align-items:center; justify-content:center; gap:1rem; margin-top:3rem; }
|
||||||
|
.product-detail { margin-top:2rem; }
|
||||||
|
.product-detail h1 { font-size:clamp(2rem,6vw,3.5rem); color:var(--brand-purple); margin-bottom:1rem; overflow-wrap:anywhere; }
|
||||||
|
.product-description { white-space:pre-wrap; margin:1rem 0; }
|
||||||
|
.product-groups { display:flex; flex-wrap:wrap; gap:.5rem; margin:1.5rem 0; }
|
||||||
|
.product-detail h2 { font-size:2rem; margin:2rem 0 1rem; }
|
||||||
|
.variant-list { list-style:none; margin-bottom:2rem; }
|
||||||
|
.variant-list li { display:flex; justify-content:space-between; gap:1.5rem; border-top:1px solid var(--brand-border); padding:1.5rem 0; }
|
||||||
|
.variant-list h3 { font-size:1.5rem; }
|
||||||
|
.variant-list strong { white-space:nowrap; }
|
||||||
|
.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; } }
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
.workspace-page {
|
||||||
|
padding: 4rem 1rem;
|
||||||
|
background: var(--brand-light-lavender);
|
||||||
|
}
|
||||||
|
.workspace-page h1 {
|
||||||
|
text-align: center;
|
||||||
|
font-size: clamp(2.2rem, 6vw, 3.5rem);
|
||||||
|
color: var(--brand-purple);
|
||||||
|
}
|
||||||
|
.workspace-intro {
|
||||||
|
margin: 1rem 0 2rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.workspace-panel {
|
||||||
|
padding: 2rem;
|
||||||
|
background: var(--brand-card) !important;
|
||||||
|
}
|
||||||
|
.workspace-panel h2 {
|
||||||
|
font-size: 2rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
.workspace-panel h3 {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin: 1.5rem 0 1rem;
|
||||||
|
}
|
||||||
|
.workspace-panel p {
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
|
.workspace-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1.5rem;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
}
|
||||||
|
.workspace-panel hr {
|
||||||
|
margin: 2rem 0;
|
||||||
|
border: 0;
|
||||||
|
border-top: 1px solid var(--brand-border);
|
||||||
|
}
|
||||||
|
.workspace-id,
|
||||||
|
.permission-list {
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
.permission-list {
|
||||||
|
padding-left: 1.5rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
.health-result {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.workspace-page {
|
||||||
|
padding: 2.5rem 0.25rem;
|
||||||
|
}
|
||||||
|
.workspace-panel {
|
||||||
|
padding: 1.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,161 @@
|
||||||
|
import { test, afterEach } from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import {
|
||||||
|
apiRequest,
|
||||||
|
listProducts,
|
||||||
|
getProduct,
|
||||||
|
login,
|
||||||
|
getPrincipal,
|
||||||
|
healthCheck,
|
||||||
|
ApiError,
|
||||||
|
} from "../src/lib/api.ts";
|
||||||
|
const originalFetch = globalThis.fetch;
|
||||||
|
const org = "d66c798a-f764-4b88-8d13-ace328ff1010";
|
||||||
|
afterEach(() => {
|
||||||
|
globalThis.fetch = originalFetch;
|
||||||
|
});
|
||||||
|
test("invalid organization cannot trigger catalog requests", async () => {
|
||||||
|
globalThis.fetch = async () => {
|
||||||
|
assert.fail("Must not send a request");
|
||||||
|
};
|
||||||
|
await assert.rejects(listProducts("../auth/me"));
|
||||||
|
});
|
||||||
|
test("catalog search is encoded and uses the deployed list shape", async () => {
|
||||||
|
globalThis.fetch = async (url) => {
|
||||||
|
assert.equal(
|
||||||
|
url,
|
||||||
|
`/api/v1/storefront/${org}/products?limit=12&offset=12&search=rose+%26+oud`,
|
||||||
|
);
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify([{ id: org, name: "Rose", slug: "rose" }]),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
assert.equal((await listProducts(org, "rose & oud", 12))[0].name, "Rose");
|
||||||
|
});
|
||||||
|
test("product variants retain exact decimal and currency strings", async () => {
|
||||||
|
globalThis.fetch = async () =>
|
||||||
|
new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
id: org,
|
||||||
|
name: "Rose",
|
||||||
|
slug: "rose",
|
||||||
|
description: "",
|
||||||
|
variants: [
|
||||||
|
{
|
||||||
|
id: org,
|
||||||
|
name: "Small",
|
||||||
|
sku: "ROSE",
|
||||||
|
price: "123.45",
|
||||||
|
currency: "INR",
|
||||||
|
attributes: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
groups: [],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
assert.equal((await getProduct(org, org)).variants[0].price, "123.45");
|
||||||
|
});
|
||||||
|
test("login uses strict body and me uses opaque bearer token", async () => {
|
||||||
|
globalThis.fetch = async (url, options) => {
|
||||||
|
assert.equal(url, "/api/v1/auth/login");
|
||||||
|
assert.deepEqual(JSON.parse(options?.body as string), {
|
||||||
|
organizationId: org,
|
||||||
|
email: "staff@example.com",
|
||||||
|
password: "private",
|
||||||
|
});
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
accessToken: "opaque",
|
||||||
|
tokenType: "Bearer",
|
||||||
|
expiresAt: "2026-10-12T00:00:00.000Z",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const session = await login(org, "staff@example.com", "private");
|
||||||
|
globalThis.fetch = async (url, options) => {
|
||||||
|
assert.equal(
|
||||||
|
new Headers(options?.headers).get("Authorization"),
|
||||||
|
"Bearer opaque",
|
||||||
|
);
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
userId: org,
|
||||||
|
organizationId: org,
|
||||||
|
sessionId: org,
|
||||||
|
permissions: ["products.read"],
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
assert.deepEqual((await getPrincipal(session.accessToken)).permissions, [
|
||||||
|
"products.read",
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
test("logout accepts 204 and errors retain code and request reference", async () => {
|
||||||
|
globalThis.fetch = async () => new Response(null, { status: 204 });
|
||||||
|
assert.equal(await apiRequest("/auth/logout", { method: "POST" }), null);
|
||||||
|
globalThis.fetch = async () =>
|
||||||
|
new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
message: "Denied",
|
||||||
|
code: "ACCESS_DENIED",
|
||||||
|
requestId: "ref",
|
||||||
|
}),
|
||||||
|
{ status: 403 },
|
||||||
|
);
|
||||||
|
await assert.rejects(
|
||||||
|
apiRequest("/auth/me"),
|
||||||
|
(e) =>
|
||||||
|
e instanceof ApiError &&
|
||||||
|
e.status === 403 &&
|
||||||
|
e.requestId === "ref" &&
|
||||||
|
e.code === "ACCESS_DENIED",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
test("network errors are sanitized and aborts stay cancellable", async () => {
|
||||||
|
globalThis.fetch = async () => {
|
||||||
|
throw new Error("internal host");
|
||||||
|
};
|
||||||
|
await assert.rejects(
|
||||||
|
apiRequest("/health/live"),
|
||||||
|
(e) =>
|
||||||
|
e instanceof ApiError &&
|
||||||
|
e.code === "NETWORK_ERROR" &&
|
||||||
|
!e.message.includes("internal"),
|
||||||
|
);
|
||||||
|
globalThis.fetch = async () => {
|
||||||
|
throw new DOMException("Aborted", "AbortError");
|
||||||
|
};
|
||||||
|
await assert.rejects(
|
||||||
|
apiRequest("/health/live"),
|
||||||
|
(e) => e instanceof Error && e.name === "AbortError",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
test("malformed catalog and unsuccessful readiness status are rejected", async () => {
|
||||||
|
globalThis.fetch = async () => new Response(JSON.stringify({ products: [] }));
|
||||||
|
await assert.rejects(
|
||||||
|
listProducts(org),
|
||||||
|
(e) => e instanceof ApiError && e.code === "INVALID_RESPONSE",
|
||||||
|
);
|
||||||
|
globalThis.fetch = async () =>
|
||||||
|
new Response(JSON.stringify({ status: "failed" }));
|
||||||
|
await assert.rejects(healthCheck("ready"));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("malformed diagnostic values cannot leak objects into UI rendering", async () => {
|
||||||
|
globalThis.fetch = async () =>
|
||||||
|
new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
message: ["invalid"],
|
||||||
|
code: { private: "details" },
|
||||||
|
requestId: { bad: true },
|
||||||
|
}),
|
||||||
|
{ status: 400, headers: { "x-request-id": "safe-ref" } },
|
||||||
|
);
|
||||||
|
await assert.rejects(
|
||||||
|
apiRequest("/auth/login"),
|
||||||
|
(error) =>
|
||||||
|
error instanceof ApiError &&
|
||||||
|
error.code === undefined &&
|
||||||
|
error.requestId === "safe-ref",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
@ -1,29 +1,35 @@
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
const projectRoot = fileURLToPath(new URL(".", import.meta.url));
|
const projectRoot = fileURLToPath(new URL(".", import.meta.url));
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"@": path.resolve(projectRoot, "src"),
|
"@": path.resolve(projectRoot, "src"),
|
||||||
},
|
},
|
||||||
dedupe: ["react", "react-dom"],
|
dedupe: ["react", "react-dom"],
|
||||||
},
|
},
|
||||||
root: projectRoot,
|
root: projectRoot,
|
||||||
build: {
|
build: {
|
||||||
outDir: path.resolve(projectRoot, "dist"),
|
outDir: path.resolve(projectRoot, "dist"),
|
||||||
emptyOutDir: true,
|
emptyOutDir: true,
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 5173,
|
port: 5173,
|
||||||
host: "0.0.0.0",
|
host: "127.0.0.1",
|
||||||
},
|
proxy: {
|
||||||
preview: {
|
"/api": {
|
||||||
port: 4173,
|
target: "https://manicandles-backend.midastix.com",
|
||||||
host: "0.0.0.0",
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
},
|
||||||
|
preview: {
|
||||||
|
port: 4173,
|
||||||
|
host: "127.0.0.1",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue