Compare commits
No commits in common. "10f795ebeddf78e8d49bd09bb5fcaaa3fe5f5f9e" and "2d8c162834478825a0a5f5d74e6efc930f089cc8" have entirely different histories.
10f795ebed
...
2d8c162834
|
|
@ -29,7 +29,7 @@ After the one-time [server setup](docs/STATIC-DEPLOYMENT.md), main-branch Drone
|
||||||
|
|
||||||
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 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.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
See [delivery phases](docs/PHASES.md) and [UAT evidence](docs/UAT-RESULTS.md).
|
See [delivery phases](docs/PHASES.md) and [UAT evidence](docs/UAT-RESULTS.md).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,4 +38,4 @@ Record the active and previous build/commit release IDs before rollout. The SSH
|
||||||
|
|
||||||
## Operational limits
|
## Operational limits
|
||||||
|
|
||||||
Pending intents exist only within the active browser session; reloading signs out and discards them. After interruption, inspect orders or the stock ledger before beginning a new intent. The backend currently has no live gateway/carrier 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.
|
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.
|
||||||
|
|
|
||||||
|
|
@ -235,21 +235,6 @@ export async function login(
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export async function register(
|
|
||||||
organizationId: string,
|
|
||||||
name: string,
|
|
||||||
email: string,
|
|
||||||
password: string,
|
|
||||||
) {
|
|
||||||
const organization = organizationSchema.parse(organizationId);
|
|
||||||
return parse(
|
|
||||||
sessionSchema,
|
|
||||||
await apiRequest("/auth/register", {
|
|
||||||
method: "POST",
|
|
||||||
body: { organizationId: organization, name, email, password },
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
export async function getPrincipal(token: string) {
|
export async function getPrincipal(token: string) {
|
||||||
return parse(principalSchema, await apiRequest("/auth/me", { token }));
|
return parse(principalSchema, await apiRequest("/auth/me", { token }));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import {
|
||||||
login,
|
login,
|
||||||
organizationSchema,
|
organizationSchema,
|
||||||
parse,
|
parse,
|
||||||
register,
|
|
||||||
type Principal,
|
type Principal,
|
||||||
type Session,
|
type Session,
|
||||||
} from "./api";
|
} from "./api";
|
||||||
|
|
@ -30,7 +29,6 @@ const PlatformContext = createContext<{
|
||||||
principal: Principal | null;
|
principal: Principal | null;
|
||||||
scope: string;
|
scope: string;
|
||||||
signIn: (email: string, password: string) => Promise<void>;
|
signIn: (email: string, password: string) => Promise<void>;
|
||||||
signUp: (name: string, email: string, password: string) => Promise<void>;
|
|
||||||
signOut: () => Promise<void>;
|
signOut: () => Promise<void>;
|
||||||
notice: string;
|
notice: string;
|
||||||
clearSession: (notice?: string) => void;
|
clearSession: (notice?: string) => void;
|
||||||
|
|
@ -112,15 +110,9 @@ export function PlatformProvider({ children }: { children: ReactNode }) {
|
||||||
/* The in-memory setting still works. */
|
/* The in-memory setting still works. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function signIn(email: string, password: string) {
|
async function signIn(email: string, password: string) {
|
||||||
return adopt(() => login(organization, email, password));
|
|
||||||
}
|
|
||||||
function signUp(name: string, email: string, password: string) {
|
|
||||||
return adopt(() => register(organization, name, email, password));
|
|
||||||
}
|
|
||||||
async function adopt(start: () => ReturnType<typeof login>) {
|
|
||||||
const version = ++generation.current;
|
const version = ++generation.current;
|
||||||
const next = await start();
|
const next = await login(organization, email, password);
|
||||||
try {
|
try {
|
||||||
const me = await getPrincipal(next.accessToken);
|
const me = await getPrincipal(next.accessToken);
|
||||||
if (
|
if (
|
||||||
|
|
@ -255,7 +247,6 @@ export function PlatformProvider({ children }: { children: ReactNode }) {
|
||||||
principal,
|
principal,
|
||||||
scope: principal ? `${principal.sessionId}:${accessRevision}` : "",
|
scope: principal ? `${principal.sessionId}:${accessRevision}` : "",
|
||||||
signIn,
|
signIn,
|
||||||
signUp,
|
|
||||||
signOut,
|
signOut,
|
||||||
notice,
|
notice,
|
||||||
clearSession,
|
clearSession,
|
||||||
|
|
|
||||||
|
|
@ -11,25 +11,20 @@ import "./workspace.css";
|
||||||
import { WorkspaceNavigation } from "@/components/WorkspaceShell";
|
import { WorkspaceNavigation } from "@/components/WorkspaceShell";
|
||||||
|
|
||||||
export default function WorkspacePage() {
|
export default function WorkspacePage() {
|
||||||
const { organization, principal, signIn, signUp, signOut, notice } =
|
const { organization, principal, signIn, signOut, notice } = usePlatform();
|
||||||
usePlatform();
|
|
||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const [error, setError] = useState<unknown>(null);
|
const [error, setError] = useState<unknown>(null);
|
||||||
const [creating, setCreating] = useState(false);
|
|
||||||
async function submit(event: FormEvent<HTMLFormElement>) {
|
async function submit(event: FormEvent<HTMLFormElement>) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const form = event.currentTarget;
|
const form = event.currentTarget;
|
||||||
const fields = new FormData(form);
|
const fields = new FormData(form);
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
const name = String(fields.get("name") ?? "");
|
|
||||||
const email = String(fields.get("email"));
|
const email = String(fields.get("email"));
|
||||||
const password = String(fields.get("password"));
|
const password = String(fields.get("password"));
|
||||||
form.reset();
|
form.reset();
|
||||||
try {
|
try {
|
||||||
await (creating
|
await signIn(email, password);
|
||||||
? signUp(name, email, password)
|
|
||||||
: signIn(email, password));
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setError(error);
|
setError(error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -52,7 +47,7 @@ export default function WorkspacePage() {
|
||||||
<Container maxWidth="md">
|
<Container maxWidth="md">
|
||||||
<h1>Account Workspace</h1>
|
<h1>Account Workspace</h1>
|
||||||
<p className="workspace-intro">
|
<p className="workspace-intro">
|
||||||
Sign in, or create a customer account to shop.
|
Sign in with your approved Mani Candles account.
|
||||||
</p>
|
</p>
|
||||||
<Paper variant="outlined" className="workspace-panel">
|
<Paper variant="outlined" className="workspace-panel">
|
||||||
<ApiNotice error={error} />
|
<ApiNotice error={error} />
|
||||||
|
|
@ -73,7 +68,7 @@ export default function WorkspacePage() {
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
) : (
|
) : (
|
||||||
<p>Customer account. Use your cart, addresses and orders below.</p>
|
<p>No permissions assigned. Contact your administrator.</p>
|
||||||
)}
|
)}
|
||||||
<p className="workspace-intro">
|
<p className="workspace-intro">
|
||||||
Open a customer or administration tool below.
|
Open a customer or administration tool below.
|
||||||
|
|
@ -94,20 +89,11 @@ export default function WorkspacePage() {
|
||||||
backend.
|
backend.
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
{creating && (
|
|
||||||
<TextField
|
|
||||||
label="Full name"
|
|
||||||
name="name"
|
|
||||||
autoComplete="name"
|
|
||||||
required
|
|
||||||
inputProps={{ maxLength: 160 }}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<TextField
|
<TextField
|
||||||
label="Email address"
|
label="Email address"
|
||||||
name="email"
|
name="email"
|
||||||
type="email"
|
type="email"
|
||||||
autoComplete={creating ? "email" : "username"}
|
autoComplete="username"
|
||||||
required
|
required
|
||||||
inputProps={{ maxLength: 254 }}
|
inputProps={{ maxLength: 254 }}
|
||||||
/>
|
/>
|
||||||
|
|
@ -115,36 +101,16 @@ export default function WorkspacePage() {
|
||||||
label="Password"
|
label="Password"
|
||||||
name="password"
|
name="password"
|
||||||
type="password"
|
type="password"
|
||||||
autoComplete={creating ? "new-password" : "current-password"}
|
autoComplete="current-password"
|
||||||
required
|
required
|
||||||
helperText={creating ? "At least 15 characters." : undefined}
|
inputProps={{ maxLength: 128 }}
|
||||||
inputProps={{ minLength: creating ? 15 : 1, maxLength: 128 }}
|
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={busy || !organization}
|
disabled={busy || !organization}
|
||||||
>
|
>
|
||||||
{creating
|
{busy ? "Signing in…" : "Sign in"}
|
||||||
? busy
|
|
||||||
? "Creating account…"
|
|
||||||
: "Create account"
|
|
||||||
: busy
|
|
||||||
? "Signing in…"
|
|
||||||
: "Sign in"}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="text"
|
|
||||||
type="button"
|
|
||||||
disabled={busy}
|
|
||||||
onClick={() => {
|
|
||||||
setCreating(!creating);
|
|
||||||
setError(null);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{creating
|
|
||||||
? "Already have an account? Sign in"
|
|
||||||
: "New customer? Create an account"}
|
|
||||||
</Button>
|
</Button>
|
||||||
<small>
|
<small>
|
||||||
Sessions stay in memory. Reloading or closing this page requires
|
Sessions stay in memory. Reloading or closing this page requires
|
||||||
|
|
|
||||||
|
|
@ -332,19 +332,3 @@ test("organization change cancels private scope and removes cached data", async
|
||||||
await waitFor(() => expect(h.result.current.scope).toBe(""));
|
await waitFor(() => expect(h.result.current.scope).toBe(""));
|
||||||
expect(h.client.getQueriesData({ queryKey: ["private"] })).toEqual([]);
|
expect(h.client.getQueriesData({ queryKey: ["private"] })).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("sign-up registers in the configured organization and adopts the new session", async () => {
|
|
||||||
const bodies: unknown[] = [];
|
|
||||||
vi.stubGlobal("fetch", vi.fn(async (url: string, options?: RequestInit) => {
|
|
||||||
if (url.endsWith("/auth/register")) {
|
|
||||||
bodies.push(JSON.parse(String(options?.body)));
|
|
||||||
return json(session, 201);
|
|
||||||
}
|
|
||||||
if (url.endsWith("/auth/me")) return json({ ...me, permissions: [] });
|
|
||||||
throw new Error(`Unexpected request ${url}`);
|
|
||||||
}));
|
|
||||||
const h = harness();
|
|
||||||
await act(() => h.result.current.signUp("Asha Buyer", "buyer@example.com", "a long enough password"));
|
|
||||||
expect(bodies).toEqual([{ organizationId: id, name: "Asha Buyer", email: "buyer@example.com", password: "a long enough password" }]);
|
|
||||||
expect(h.result.current.principal).toMatchObject({ userId: id, permissions: [] });
|
|
||||||
});
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue