feat(web): useSetVisibility hook + adjacentTransitions helper + MSW handler
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import { adjacentTransitions } from "./transitions";
|
||||
|
||||
test("draft can only go forward to internal", () => {
|
||||
expect(adjacentTransitions("draft")).toEqual({ forward: "internal" });
|
||||
});
|
||||
test("internal can go forward to public and back to draft", () => {
|
||||
expect(adjacentTransitions("internal")).toEqual({ forward: "public", back: "draft" });
|
||||
});
|
||||
test("public can only go back to internal", () => {
|
||||
expect(adjacentTransitions("public")).toEqual({ back: "internal" });
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
export type Visibility = "draft" | "internal" | "public";
|
||||
|
||||
/** The legal one-step visibility moves from `v`, per the backend state machine
|
||||
* (Draft<->Internal, Internal<->Public; no skipping). */
|
||||
export function adjacentTransitions(v: Visibility): { forward?: Visibility; back?: Visibility } {
|
||||
switch (v) {
|
||||
case "draft":
|
||||
return { forward: "internal" };
|
||||
case "internal":
|
||||
return { forward: "public", back: "draft" };
|
||||
case "public":
|
||||
return { back: "internal" };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user