refactor(private-zone): use canonical product name
Docker Image / Build and Push Docker Image (push) Successful in 2m7s
Docker Image / Build and Push Docker Image (push) Successful in 2m7s
This commit is contained in:
@@ -85,8 +85,8 @@ describe("shared Tailwind components", () => {
|
||||
<CharacterAvatar
|
||||
src="/images/avatar/elio.png"
|
||||
alt="Elio Silvestri"
|
||||
actionLabel="Open Elio's private zoom"
|
||||
analyticsKey="chat.open_private_zoom_from_avatar"
|
||||
actionLabel="Open Elio's private zone"
|
||||
analyticsKey="chat.open_private_zone_from_avatar"
|
||||
onClick={() => undefined}
|
||||
/>,
|
||||
);
|
||||
@@ -100,10 +100,10 @@ describe("shared Tailwind components", () => {
|
||||
|
||||
expect(characterHtml).toContain('<button type="button"');
|
||||
expect(characterHtml).toContain(
|
||||
'aria-label="Open Elio's private zoom"',
|
||||
'aria-label="Open Elio's private zone"',
|
||||
);
|
||||
expect(characterHtml).toContain(
|
||||
'data-analytics-key="chat.open_private_zoom_from_avatar"',
|
||||
'data-analytics-key="chat.open_private_zone_from_avatar"',
|
||||
);
|
||||
expect(userHtml).toContain('<button type="button"');
|
||||
expect(userHtml).toContain('aria-label="Open profile"');
|
||||
|
||||
@@ -79,19 +79,19 @@ describe("core Tailwind components", () => {
|
||||
<AppBottomNav
|
||||
activeItem="chat"
|
||||
variant="dark"
|
||||
privateZoomLabel="Maya Private Zoom"
|
||||
privateZoneLabel="Maya Private Zone"
|
||||
onChatClick={() => undefined}
|
||||
onPrivateZoomClick={() => undefined}
|
||||
onPrivateZoneClick={() => undefined}
|
||||
onMenuClick={() => undefined}
|
||||
/>,
|
||||
);
|
||||
const privateZoomHtml = renderToStaticMarkup(
|
||||
const privateZoneHtml = renderToStaticMarkup(
|
||||
<AppBottomNav
|
||||
activeItem="privateZoom"
|
||||
activeItem="privateZone"
|
||||
variant="warm"
|
||||
privateZoomLabel="Maya Private Zoom"
|
||||
privateZoneLabel="Maya Private Zone"
|
||||
onChatClick={() => undefined}
|
||||
onPrivateZoomClick={() => undefined}
|
||||
onPrivateZoneClick={() => undefined}
|
||||
onMenuClick={() => undefined}
|
||||
/>,
|
||||
);
|
||||
@@ -101,13 +101,13 @@ describe("core Tailwind components", () => {
|
||||
expect(chatHtml).toMatch(
|
||||
/<button[^>]*aria-current="page"[^>]*>.*?<span>Chat<\/span>/,
|
||||
);
|
||||
expect(privateZoomHtml).toMatch(/class="[^"]*warm[^"]*"/);
|
||||
expect(privateZoomHtml).toMatch(
|
||||
/<button[^>]*aria-current="page"[^>]*>.*?<span>Maya Private Zoom<\/span>/,
|
||||
expect(privateZoneHtml).toMatch(/class="[^"]*warm[^"]*"/);
|
||||
expect(privateZoneHtml).toMatch(
|
||||
/<button[^>]*aria-current="page"[^>]*>.*?<span>Maya Private Zone<\/span>/,
|
||||
);
|
||||
expect(chatHtml).toContain('data-analytics-key="navigation.chat"');
|
||||
expect(privateZoomHtml).toContain(
|
||||
'data-analytics-key="navigation.private_zoom"',
|
||||
expect(privateZoneHtml).toContain(
|
||||
'data-analytics-key="navigation.private_zone"',
|
||||
);
|
||||
expect(chatHtml).toContain('data-analytics-key="navigation.menu"');
|
||||
expect(chatHtml).toContain("<span>Menu</span>");
|
||||
|
||||
@@ -4,24 +4,24 @@ import { Camera, Menu as MenuIcon, MessageCircle } from "lucide-react";
|
||||
|
||||
import styles from "./app-bottom-nav.module.css";
|
||||
|
||||
export type AppBottomNavItem = "chat" | "privateZoom" | "menu";
|
||||
export type AppBottomNavItem = "chat" | "privateZone" | "menu";
|
||||
export type AppBottomNavVariant = "warm" | "dark";
|
||||
|
||||
export interface AppBottomNavProps {
|
||||
activeItem?: AppBottomNavItem | null;
|
||||
variant?: AppBottomNavVariant;
|
||||
privateZoomLabel: string;
|
||||
privateZoneLabel: string;
|
||||
onChatClick: () => void;
|
||||
onPrivateZoomClick: () => void;
|
||||
onPrivateZoneClick: () => void;
|
||||
onMenuClick: () => void;
|
||||
}
|
||||
|
||||
export function AppBottomNav({
|
||||
activeItem = null,
|
||||
variant = "warm",
|
||||
privateZoomLabel,
|
||||
privateZoneLabel,
|
||||
onChatClick,
|
||||
onPrivateZoomClick,
|
||||
onPrivateZoneClick,
|
||||
onMenuClick,
|
||||
}: AppBottomNavProps) {
|
||||
return (
|
||||
@@ -39,14 +39,14 @@ export function AppBottomNav({
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
data-analytics-key="navigation.private_zoom"
|
||||
data-analytics-label="Private Zoom navigation"
|
||||
className={getButtonClass(activeItem === "privateZoom")}
|
||||
aria-current={activeItem === "privateZoom" ? "page" : undefined}
|
||||
onClick={onPrivateZoomClick}
|
||||
data-analytics-key="navigation.private_zone"
|
||||
data-analytics-label="Private Zone navigation"
|
||||
className={getButtonClass(activeItem === "privateZone")}
|
||||
aria-current={activeItem === "privateZone" ? "page" : undefined}
|
||||
onClick={onPrivateZoneClick}
|
||||
>
|
||||
<Camera size={20} aria-hidden="true" />
|
||||
<span>{privateZoomLabel}</span>
|
||||
<span>{privateZoneLabel}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
+5
-5
@@ -2,9 +2,9 @@ import type { ReactNode } from "react";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { getCharacterBySlug } from "@/data/constants/character";
|
||||
import { PrivateZoomRouteProvider } from "@/providers/private-zoom-route-provider";
|
||||
import { PrivateZoneRouteProvider } from "@/providers/private-zone-route-provider";
|
||||
|
||||
export default async function CharacterPrivateZoomLayout({
|
||||
export default async function CharacterPrivateZoneLayout({
|
||||
children,
|
||||
params,
|
||||
}: {
|
||||
@@ -13,11 +13,11 @@ export default async function CharacterPrivateZoomLayout({
|
||||
}) {
|
||||
const { characterSlug } = await params;
|
||||
const character = getCharacterBySlug(characterSlug);
|
||||
if (!character?.capabilities.privateZoom) notFound();
|
||||
if (!character?.capabilities.privateZone) notFound();
|
||||
|
||||
return (
|
||||
<PrivateZoomRouteProvider characterId={character.id}>
|
||||
<PrivateZoneRouteProvider characterId={character.id}>
|
||||
{children}
|
||||
</PrivateZoomRouteProvider>
|
||||
</PrivateZoneRouteProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { PrivateZoneScreen } from "@/app/private-zone/private-zone-screen";
|
||||
|
||||
export default function CharacterPrivateZonePage() {
|
||||
return <PrivateZoneScreen />;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { PrivateZoomScreen } from "@/app/private-zoom/private-zoom-screen";
|
||||
|
||||
export default function CharacterPrivateZoomPage() {
|
||||
return <PrivateZoomScreen />;
|
||||
}
|
||||
@@ -246,8 +246,8 @@ export function ChatScreen() {
|
||||
);
|
||||
}
|
||||
|
||||
function handleOpenCharacterPrivateZoom(): void {
|
||||
router.push(characterRoutes.privateZoom);
|
||||
function handleOpenCharacterPrivateZone(): void {
|
||||
router.push(characterRoutes.privateZone);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -297,7 +297,7 @@ export function ChatScreen() {
|
||||
onUnlockImageMessage={handleUnlockImageMessage}
|
||||
onOpenImage={handleOpenImage}
|
||||
onUserAvatarClick={handleOpenUserProfile}
|
||||
onCharacterAvatarClick={handleOpenCharacterPrivateZoom}
|
||||
onCharacterAvatarClick={handleOpenCharacterPrivateZone}
|
||||
onLoadMoreHistory={() => {
|
||||
chatDispatch({ type: "ChatLoadMoreHistoryRequested" });
|
||||
}}
|
||||
|
||||
@@ -62,10 +62,10 @@ describe("chat Tailwind components", () => {
|
||||
|
||||
expect(aiHtml).toContain('<button type="button"');
|
||||
expect(aiHtml).toContain(
|
||||
'data-analytics-key="chat.open_private_zoom_from_avatar"',
|
||||
'data-analytics-key="chat.open_private_zone_from_avatar"',
|
||||
);
|
||||
expect(aiHtml).toContain(
|
||||
'aria-label="Open Elio Silvestri's private zoom"',
|
||||
'aria-label="Open Elio Silvestri's private zone"',
|
||||
);
|
||||
expect(userHtml).toContain('<button type="button"');
|
||||
expect(userHtml).toContain(
|
||||
|
||||
@@ -29,8 +29,8 @@ export function MessageAvatar({
|
||||
imageSize={43}
|
||||
priority
|
||||
className={AVATAR_CLASS_NAME}
|
||||
actionLabel={`Open ${character.displayName}'s private zoom`}
|
||||
analyticsKey="chat.open_private_zoom_from_avatar"
|
||||
actionLabel={`Open ${character.displayName}'s private zone`}
|
||||
analyticsKey="chat.open_private_zone_from_avatar"
|
||||
onClick={onClick}
|
||||
/>
|
||||
);
|
||||
|
||||
+4
-4
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
buildPrivateAlbumGalleryUrl,
|
||||
buildPrivateZoomWithoutGalleryUrl,
|
||||
buildPrivateZoneWithoutGalleryUrl,
|
||||
getPrivateAlbumGalleryState,
|
||||
} from "../private-album-gallery-url";
|
||||
|
||||
@@ -11,7 +11,7 @@ describe("private album gallery URL", () => {
|
||||
const url = buildPrivateAlbumGalleryUrl("album:91", 3);
|
||||
const params = new URL(url, "https://cozsweet.test").searchParams;
|
||||
|
||||
expect(url).toBe("/private-zoom?album=album%3A91&image=3");
|
||||
expect(url).toBe("/private-zone?album=album%3A91&image=3");
|
||||
expect(getPrivateAlbumGalleryState(params)).toEqual({
|
||||
albumId: "album:91",
|
||||
imageIndex: 3,
|
||||
@@ -29,9 +29,9 @@ describe("private album gallery URL", () => {
|
||||
|
||||
it("removes gallery params without dropping other query values", () => {
|
||||
expect(
|
||||
buildPrivateZoomWithoutGalleryUrl(
|
||||
buildPrivateZoneWithoutGalleryUrl(
|
||||
new URLSearchParams("album=album-1&image=2&source=external"),
|
||||
),
|
||||
).toBe("/private-zoom?source=external");
|
||||
).toBe("/private-zone?source=external");
|
||||
});
|
||||
});
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { PrivateAlbumSchema } from "@/data/schemas/private-zoom";
|
||||
import { PrivateAlbumSchema } from "@/data/schemas/private-zone";
|
||||
|
||||
import {
|
||||
findPrivateAlbumDisplayImage,
|
||||
+15
-15
@@ -6,10 +6,10 @@ import { getCharacterBySlug } from "@/data/constants/character";
|
||||
import type { LoginStatus } from "@/data/schemas/auth";
|
||||
import { CharacterProvider } from "@/providers/character-provider";
|
||||
import { getCharacterRoutes } from "@/router/routes";
|
||||
import type { PrivateZoomEvent } from "@/stores/private-zoom";
|
||||
import type { PrivateZoomUnlockPaywallRequest } from "@/stores/private-zoom/private-zoom-state";
|
||||
import type { PrivateZoneEvent } from "@/stores/private-zone";
|
||||
import type { PrivateZoneUnlockPaywallRequest } from "@/stores/private-zone/private-zone-state";
|
||||
|
||||
import { usePrivateZoomUnlockPaywallNavigation } from "../use-private-zoom-flow";
|
||||
import { usePrivateZoneUnlockPaywallNavigation } from "../use-private-zone-flow";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
openAuth: vi.fn(),
|
||||
@@ -30,7 +30,7 @@ vi.mock("@/lib/analytics", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
const unlockPaywallRequest: PrivateZoomUnlockPaywallRequest = {
|
||||
const unlockPaywallRequest: PrivateZoneUnlockPaywallRequest = {
|
||||
albumId: "album-1",
|
||||
reason: "insufficient_credits",
|
||||
requiredCredits: 10,
|
||||
@@ -38,7 +38,7 @@ const unlockPaywallRequest: PrivateZoomUnlockPaywallRequest = {
|
||||
shortfallCredits: 7,
|
||||
};
|
||||
|
||||
describe("Private Zoom paywall navigation", () => {
|
||||
describe("Private Zone paywall navigation", () => {
|
||||
let container: HTMLDivElement;
|
||||
let root: Root;
|
||||
|
||||
@@ -58,31 +58,31 @@ describe("Private Zoom paywall navigation", () => {
|
||||
container.remove();
|
||||
});
|
||||
|
||||
it("opens top up with a private zoom return target", () => {
|
||||
const roomDispatch = vi.fn<Dispatch<PrivateZoomEvent>>();
|
||||
it("opens top up with a private zone return target", () => {
|
||||
const roomDispatch = vi.fn<Dispatch<PrivateZoneEvent>>();
|
||||
|
||||
renderHarness(root, "email", roomDispatch);
|
||||
|
||||
expect(mocks.openSubscription).toHaveBeenCalledWith({
|
||||
type: "topup",
|
||||
returnTo: "private-zoom",
|
||||
returnTo: "private-zone",
|
||||
analytics: {
|
||||
entryPoint: "private_album_unlock",
|
||||
triggerReason: "insufficient_credits",
|
||||
},
|
||||
});
|
||||
expect(roomDispatch).toHaveBeenCalledWith({
|
||||
type: "PrivateZoomUnlockPaywallConsumed",
|
||||
type: "PrivateZoneUnlockPaywallConsumed",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps guest users on the private zoom auth return path", () => {
|
||||
const roomDispatch = vi.fn<Dispatch<PrivateZoomEvent>>();
|
||||
it("keeps guest users on the private zone auth return path", () => {
|
||||
const roomDispatch = vi.fn<Dispatch<PrivateZoneEvent>>();
|
||||
|
||||
renderHarness(root, "guest", roomDispatch);
|
||||
|
||||
expect(mocks.openAuth).toHaveBeenCalledWith(
|
||||
getCharacterRoutes("maya").privateZoom,
|
||||
getCharacterRoutes("maya").privateZone,
|
||||
);
|
||||
expect(mocks.openSubscription).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -91,7 +91,7 @@ describe("Private Zoom paywall navigation", () => {
|
||||
function renderHarness(
|
||||
root: Root,
|
||||
loginStatus: LoginStatus,
|
||||
roomDispatch: Dispatch<PrivateZoomEvent>,
|
||||
roomDispatch: Dispatch<PrivateZoneEvent>,
|
||||
): void {
|
||||
const character = getCharacterBySlug("maya");
|
||||
if (!character) throw new Error("Missing Maya character fixture");
|
||||
@@ -109,9 +109,9 @@ function Harness({
|
||||
roomDispatch,
|
||||
}: {
|
||||
loginStatus: LoginStatus;
|
||||
roomDispatch: Dispatch<PrivateZoomEvent>;
|
||||
roomDispatch: Dispatch<PrivateZoneEvent>;
|
||||
}) {
|
||||
usePrivateZoomUnlockPaywallNavigation({
|
||||
usePrivateZoneUnlockPaywallNavigation({
|
||||
loginStatus,
|
||||
roomDispatch,
|
||||
unlockPaywallRequest,
|
||||
+4
-4
@@ -1,19 +1,19 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { isPrivateZoomAuthRequired } from "../use-private-zoom-flow";
|
||||
import { isPrivateZoneAuthRequired } from "../use-private-zone-flow";
|
||||
|
||||
describe("isPrivateZoomAuthRequired", () => {
|
||||
describe("isPrivateZoneAuthRequired", () => {
|
||||
it.each(["guest", "notLoggedIn"] as const)(
|
||||
"requires auth for %s users",
|
||||
(loginStatus) => {
|
||||
expect(isPrivateZoomAuthRequired(loginStatus)).toBe(true);
|
||||
expect(isPrivateZoneAuthRequired(loginStatus)).toBe(true);
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["email", "facebook", "google"] as const)(
|
||||
"allows %s users to top up directly",
|
||||
(loginStatus) => {
|
||||
expect(isPrivateZoomAuthRequired(loginStatus)).toBe(false);
|
||||
expect(isPrivateZoneAuthRequired(loginStatus)).toBe(false);
|
||||
},
|
||||
);
|
||||
});
|
||||
+5
-5
@@ -4,7 +4,7 @@ import { act } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { PrivateAlbumSchema } from "@/data/schemas/private-zoom";
|
||||
import { PrivateAlbumSchema } from "@/data/schemas/private-zone";
|
||||
|
||||
import { PrivateAlbumCard } from "../private-album-card";
|
||||
|
||||
@@ -33,9 +33,9 @@ describe("PrivateAlbumCard interactions", () => {
|
||||
imageCount: 4,
|
||||
images: [
|
||||
{ url: "", locked: false, index: 0 },
|
||||
{ url: "/images/private-zoom/locked.png", locked: true, index: 1 },
|
||||
{ url: "/images/private-zoom/photo-2.png", locked: false, index: 2 },
|
||||
{ url: "/images/private-zoom/photo-3.png", locked: false, index: 3 },
|
||||
{ url: "/images/private-zone/locked.png", locked: true, index: 1 },
|
||||
{ url: "/images/private-zone/photo-2.png", locked: false, index: 2 },
|
||||
{ url: "/images/private-zone/photo-3.png", locked: false, index: 3 },
|
||||
],
|
||||
locked: false,
|
||||
unlocked: true,
|
||||
@@ -72,7 +72,7 @@ describe("PrivateAlbumCard interactions", () => {
|
||||
title: "Locked afternoon",
|
||||
imageCount: 3,
|
||||
images: [
|
||||
{ url: "/images/private-zoom/locked.png", locked: true, index: 0 },
|
||||
{ url: "/images/private-zone/locked.png", locked: true, index: 0 },
|
||||
],
|
||||
locked: true,
|
||||
unlocked: false,
|
||||
+3
-3
@@ -5,11 +5,11 @@ import {
|
||||
PrivateAlbumSchema,
|
||||
type PrivateAlbum,
|
||||
type PrivateAlbumInput,
|
||||
} from "@/data/schemas/private-zoom";
|
||||
} from "@/data/schemas/private-zone";
|
||||
|
||||
import { PrivateAlbumCard } from "../private-album-card";
|
||||
|
||||
const COVER_URL = "/images/private-zoom/banner/elio.png";
|
||||
const COVER_URL = "/images/private-zone/banner/elio.png";
|
||||
|
||||
function makeAlbum(overrides: Partial<PrivateAlbumInput> = {}): PrivateAlbum {
|
||||
return PrivateAlbumSchema.parse({
|
||||
@@ -157,7 +157,7 @@ describe("PrivateAlbumCard", () => {
|
||||
|
||||
function makeImages(count: number) {
|
||||
return Array.from({ length: count }, (_, index) => ({
|
||||
url: `/images/private-zoom/photo-${index}.png`,
|
||||
url: `/images/private-zone/photo-${index}.png`,
|
||||
locked: false,
|
||||
index,
|
||||
}));
|
||||
+5
-5
@@ -4,7 +4,7 @@ import { act } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { PrivateAlbumSchema } from "@/data/schemas/private-zoom";
|
||||
import { PrivateAlbumSchema } from "@/data/schemas/private-zone";
|
||||
|
||||
import { PrivateAlbumGallery } from "../private-album-gallery";
|
||||
|
||||
@@ -13,11 +13,11 @@ const album = PrivateAlbumSchema.parse({
|
||||
title: "Private afternoon",
|
||||
imageCount: 5,
|
||||
images: [
|
||||
{ url: "/images/private-zoom/photo-0.png", locked: false, index: 0 },
|
||||
{ url: "/images/private-zone/photo-0.png", locked: false, index: 0 },
|
||||
{ url: "", locked: false, index: 1 },
|
||||
{ url: "/images/private-zoom/locked.png", locked: true, index: 2 },
|
||||
{ url: "/images/private-zoom/photo-3.png", locked: false, index: 3 },
|
||||
{ url: "/images/private-zoom/photo-4.png", locked: false, index: 4 },
|
||||
{ url: "/images/private-zone/locked.png", locked: true, index: 2 },
|
||||
{ url: "/images/private-zone/photo-3.png", locked: false, index: 3 },
|
||||
{ url: "/images/private-zone/photo-4.png", locked: false, index: 4 },
|
||||
],
|
||||
locked: false,
|
||||
unlocked: true,
|
||||
+3
-3
@@ -3,8 +3,8 @@ import Image from "next/image";
|
||||
import { Copy, ImageIcon, LockKeyhole } from "lucide-react";
|
||||
|
||||
import { CharacterAvatar } from "@/app/_components";
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
|
||||
import { isPrivateAlbumLocked } from "@/lib/private-zoom/private_album";
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zone";
|
||||
import { isPrivateAlbumLocked } from "@/lib/private-zone/private_album";
|
||||
|
||||
import {
|
||||
getPrivateAlbumDisplayImages,
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
PRIVATE_ALBUM_GRID_LIMIT,
|
||||
} from "../private-album-images";
|
||||
|
||||
import styles from "../private-zoom-screen.module.css";
|
||||
import styles from "../private-zone-screen.module.css";
|
||||
|
||||
export interface PrivateAlbumCardProps {
|
||||
album: PrivateAlbum;
|
||||
+2
-2
@@ -11,14 +11,14 @@ import {
|
||||
import Image from "next/image";
|
||||
import { ChevronLeft, ChevronRight, X } from "lucide-react";
|
||||
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zone";
|
||||
|
||||
import {
|
||||
getResistedGalleryDragDistance,
|
||||
resolveGallerySwipeDirection,
|
||||
} from "../private-album-gallery-motion";
|
||||
import { getPrivateAlbumDisplayImages } from "../private-album-images";
|
||||
import styles from "../private-zoom-screen.module.css";
|
||||
import styles from "../private-zone-screen.module.css";
|
||||
|
||||
export interface PrivateAlbumGalleryProps {
|
||||
album: PrivateAlbum;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import styles from "../private-zoom-screen.module.css";
|
||||
import styles from "../private-zone-screen.module.css";
|
||||
|
||||
export interface StatusCardProps {
|
||||
message: string;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zone";
|
||||
|
||||
import styles from "../private-zoom-screen.module.css";
|
||||
import styles from "../private-zone-screen.module.css";
|
||||
|
||||
export interface UnlockConfirmDialogProps {
|
||||
album: PrivateAlbum;
|
||||
@@ -7,14 +7,14 @@ import {
|
||||
type RouteSearchParams,
|
||||
} from "@/router/routes";
|
||||
|
||||
export default async function PrivateZoomPage({
|
||||
export default async function PrivateZonePage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<RouteSearchParams>;
|
||||
}) {
|
||||
redirect(
|
||||
appendRouteSearchParams(
|
||||
getCharacterRoutes(DEFAULT_CHARACTER_SLUG).privateZoom,
|
||||
getCharacterRoutes(DEFAULT_CHARACTER_SLUG).privateZone,
|
||||
await searchParams,
|
||||
),
|
||||
);
|
||||
+3
-3
@@ -15,7 +15,7 @@ export function getPrivateAlbumGalleryState(input: {
|
||||
export function buildPrivateAlbumGalleryUrl(
|
||||
albumId: string,
|
||||
imageIndex: number,
|
||||
basePath: string = ROUTES.privateZoom,
|
||||
basePath: string = ROUTES.privateZone,
|
||||
): string {
|
||||
const params = new URLSearchParams({
|
||||
[PRIVATE_ALBUM_QUERY_PARAM]: albumId,
|
||||
@@ -24,9 +24,9 @@ export function buildPrivateAlbumGalleryUrl(
|
||||
return `${basePath}?${params.toString()}`;
|
||||
}
|
||||
|
||||
export function buildPrivateZoomWithoutGalleryUrl(
|
||||
export function buildPrivateZoneWithoutGalleryUrl(
|
||||
input: { toString: () => string },
|
||||
basePath: string = ROUTES.privateZoom,
|
||||
basePath: string = ROUTES.privateZone,
|
||||
): string {
|
||||
const params = new URLSearchParams(input.toString());
|
||||
params.delete(PRIVATE_ALBUM_QUERY_PARAM);
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zone";
|
||||
|
||||
export const PRIVATE_ALBUM_GRID_LIMIT = 9;
|
||||
|
||||
+41
-41
@@ -17,12 +17,12 @@ import {
|
||||
useActiveCharacter,
|
||||
useActiveCharacterRoutes,
|
||||
} from "@/providers/character-provider";
|
||||
import { isPrivateAlbumLocked } from "@/lib/private-zoom/private_album";
|
||||
import { isPrivateAlbumLocked } from "@/lib/private-zone/private_album";
|
||||
import { useAuthDispatch, useAuthState } from "@/stores/auth/auth-context";
|
||||
import {
|
||||
usePrivateZoomDispatch,
|
||||
usePrivateZoomState,
|
||||
} from "@/stores/private-zoom";
|
||||
usePrivateZoneDispatch,
|
||||
usePrivateZoneState,
|
||||
} from "@/stores/private-zone";
|
||||
|
||||
import {
|
||||
PrivateAlbumCard,
|
||||
@@ -30,21 +30,21 @@ import {
|
||||
StatusCard,
|
||||
UnlockConfirmDialog,
|
||||
} from "./components";
|
||||
import styles from "./private-zoom-screen.module.css";
|
||||
import styles from "./private-zone-screen.module.css";
|
||||
import {
|
||||
isPrivateZoomAuthRequired,
|
||||
usePrivateZoomBootstrapFlow,
|
||||
usePrivateZoomUnlockPaywallNavigation,
|
||||
usePrivateZoomUnlockSuccessRefresh,
|
||||
} from "./use-private-zoom-flow";
|
||||
isPrivateZoneAuthRequired,
|
||||
usePrivateZoneBootstrapFlow,
|
||||
usePrivateZoneUnlockPaywallNavigation,
|
||||
usePrivateZoneUnlockSuccessRefresh,
|
||||
} from "./use-private-zone-flow";
|
||||
import {
|
||||
buildPrivateAlbumGalleryUrl,
|
||||
buildPrivateZoomWithoutGalleryUrl,
|
||||
buildPrivateZoneWithoutGalleryUrl,
|
||||
getPrivateAlbumGalleryState,
|
||||
} from "./private-album-gallery-url";
|
||||
import { findPrivateAlbumDisplayImage } from "./private-album-images";
|
||||
|
||||
export function PrivateZoomScreen() {
|
||||
export function PrivateZoneScreen() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const navigator = useAppNavigator();
|
||||
@@ -52,15 +52,15 @@ export function PrivateZoomScreen() {
|
||||
const characterRoutes = useActiveCharacterRoutes();
|
||||
const authState = useAuthState();
|
||||
const authDispatch = useAuthDispatch();
|
||||
const state = usePrivateZoomState();
|
||||
const dispatch = usePrivateZoomDispatch();
|
||||
const state = usePrivateZoneState();
|
||||
const dispatch = usePrivateZoneDispatch();
|
||||
const openedGalleryInPageRef = useRef(false);
|
||||
const galleryState = useMemo(
|
||||
() => getPrivateAlbumGalleryState(searchParams),
|
||||
[searchParams],
|
||||
);
|
||||
|
||||
usePrivateZoomBootstrapFlow({
|
||||
usePrivateZoneBootstrapFlow({
|
||||
authDispatch,
|
||||
hasInitialized: authState.hasInitialized,
|
||||
isAuthLoading: authState.isLoading,
|
||||
@@ -68,17 +68,17 @@ export function PrivateZoomScreen() {
|
||||
roomDispatch: dispatch,
|
||||
roomStatus: state.status,
|
||||
});
|
||||
usePrivateZoomUnlockPaywallNavigation({
|
||||
usePrivateZoneUnlockPaywallNavigation({
|
||||
loginStatus: authState.loginStatus,
|
||||
roomDispatch: dispatch,
|
||||
unlockPaywallRequest: state.unlockPaywallRequest,
|
||||
});
|
||||
usePrivateZoomUnlockSuccessRefresh(state.unlockSuccessNonce);
|
||||
usePrivateZoneUnlockSuccessRefresh(state.unlockSuccessNonce);
|
||||
|
||||
const displayName = character.displayName;
|
||||
const avatarUrl = character.assets.avatar;
|
||||
const title = character.copy.privateZoomTitle;
|
||||
const subtitle = character.copy.privateZoomSubtitle;
|
||||
const title = character.copy.privateZoneTitle;
|
||||
const subtitle = character.copy.privateZoneSubtitle;
|
||||
const pendingAlbum = useMemo(
|
||||
() =>
|
||||
state.items.find(
|
||||
@@ -113,15 +113,15 @@ export function PrivateZoomScreen() {
|
||||
!galleryImage
|
||||
) {
|
||||
router.replace(
|
||||
buildPrivateZoomWithoutGalleryUrl(
|
||||
buildPrivateZoneWithoutGalleryUrl(
|
||||
searchParams,
|
||||
characterRoutes.privateZoom,
|
||||
characterRoutes.privateZone,
|
||||
),
|
||||
{ scroll: false },
|
||||
);
|
||||
}
|
||||
}, [
|
||||
characterRoutes.privateZoom,
|
||||
characterRoutes.privateZone,
|
||||
galleryAlbum,
|
||||
galleryImage,
|
||||
galleryState,
|
||||
@@ -131,15 +131,15 @@ export function PrivateZoomScreen() {
|
||||
]);
|
||||
|
||||
const handleTopUpClick = () => {
|
||||
if (isPrivateZoomAuthRequired(authState.loginStatus)) {
|
||||
navigator.openAuth(characterRoutes.privateZoom);
|
||||
if (isPrivateZoneAuthRequired(authState.loginStatus)) {
|
||||
navigator.openAuth(characterRoutes.privateZone);
|
||||
return;
|
||||
}
|
||||
navigator.openSubscription({
|
||||
type: "topup",
|
||||
returnTo: "private-zoom",
|
||||
returnTo: "private-zone",
|
||||
analytics: {
|
||||
entryPoint: "private_zoom",
|
||||
entryPoint: "private_zone",
|
||||
triggerReason: "vip_cta",
|
||||
},
|
||||
});
|
||||
@@ -151,7 +151,7 @@ export function PrivateZoomScreen() {
|
||||
buildPrivateAlbumGalleryUrl(
|
||||
albumId,
|
||||
imageIndex,
|
||||
characterRoutes.privateZoom,
|
||||
characterRoutes.privateZone,
|
||||
),
|
||||
{ scroll: false },
|
||||
);
|
||||
@@ -164,9 +164,9 @@ export function PrivateZoomScreen() {
|
||||
return;
|
||||
}
|
||||
router.replace(
|
||||
buildPrivateZoomWithoutGalleryUrl(
|
||||
buildPrivateZoneWithoutGalleryUrl(
|
||||
searchParams,
|
||||
characterRoutes.privateZoom,
|
||||
characterRoutes.privateZone,
|
||||
),
|
||||
{ scroll: false },
|
||||
);
|
||||
@@ -178,7 +178,7 @@ export function PrivateZoomScreen() {
|
||||
buildPrivateAlbumGalleryUrl(
|
||||
galleryAlbum.albumId,
|
||||
imageIndex,
|
||||
characterRoutes.privateZoom,
|
||||
characterRoutes.privateZone,
|
||||
),
|
||||
{ scroll: false },
|
||||
);
|
||||
@@ -199,7 +199,7 @@ export function PrivateZoomScreen() {
|
||||
<section className={styles.hero} aria-label={title}>
|
||||
<div className={styles.heroCover}>
|
||||
<Image
|
||||
src={character.assets.privateZoomBanner}
|
||||
src={character.assets.privateZoneBanner}
|
||||
alt=""
|
||||
width={2048}
|
||||
height={1152}
|
||||
@@ -225,8 +225,8 @@ export function PrivateZoomScreen() {
|
||||
|
||||
<button
|
||||
type="button"
|
||||
data-analytics-key="private_zoom.primary_cta"
|
||||
data-analytics-label="Open private zoom top up"
|
||||
data-analytics-key="private_zone.primary_cta"
|
||||
data-analytics-label="Open private zone top up"
|
||||
className={styles.primaryCta}
|
||||
onClick={handleTopUpClick}
|
||||
>
|
||||
@@ -249,7 +249,7 @@ export function PrivateZoomScreen() {
|
||||
<StatusCard
|
||||
message={state.errorMessage}
|
||||
actionLabel="Retry"
|
||||
onAction={() => dispatch({ type: "PrivateZoomRefresh" })}
|
||||
onAction={() => dispatch({ type: "PrivateZoneRefresh" })}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -261,7 +261,7 @@ export function PrivateZoomScreen() {
|
||||
<StatusCard
|
||||
message="No private albums yet."
|
||||
actionLabel="Refresh"
|
||||
onAction={() => dispatch({ type: "PrivateZoomRefresh" })}
|
||||
onAction={() => dispatch({ type: "PrivateZoneRefresh" })}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -279,7 +279,7 @@ export function PrivateZoomScreen() {
|
||||
}
|
||||
onUnlock={() =>
|
||||
dispatch({
|
||||
type: "PrivateZoomUnlockRequested",
|
||||
type: "PrivateZoneUnlockRequested",
|
||||
albumId: album.albumId,
|
||||
})
|
||||
}
|
||||
@@ -289,12 +289,12 @@ export function PrivateZoomScreen() {
|
||||
</section>
|
||||
|
||||
<AppBottomNav
|
||||
activeItem="privateZoom"
|
||||
privateZoomLabel={character.copy.privateZoomTitle}
|
||||
activeItem="privateZone"
|
||||
privateZoneLabel={character.copy.privateZoneTitle}
|
||||
onChatClick={() =>
|
||||
navigator.push(characterRoutes.splash, { scroll: false })
|
||||
}
|
||||
onPrivateZoomClick={() => undefined}
|
||||
onPrivateZoneClick={() => undefined}
|
||||
onMenuClick={() =>
|
||||
navigator.push(
|
||||
buildGlobalPageUrl(ROUTES.profile, characterRoutes.chat),
|
||||
@@ -308,8 +308,8 @@ export function PrivateZoomScreen() {
|
||||
album={pendingAlbum}
|
||||
isUnlocking={state.isUnlocking}
|
||||
errorMessage={state.unlockErrorMessage}
|
||||
onCancel={() => dispatch({ type: "PrivateZoomUnlockCancelled" })}
|
||||
onConfirm={() => dispatch({ type: "PrivateZoomUnlockConfirmed" })}
|
||||
onCancel={() => dispatch({ type: "PrivateZoneUnlockCancelled" })}
|
||||
onConfirm={() => dispatch({ type: "PrivateZoneUnlockConfirmed" })}
|
||||
/>
|
||||
) : state.unlockErrorMessage ? (
|
||||
<div className={styles.toast} role="status">
|
||||
+20
-20
@@ -8,37 +8,37 @@ import { behaviorAnalytics } from "@/lib/analytics";
|
||||
import { useActiveCharacterRoutes } from "@/providers/character-provider";
|
||||
import { useAppNavigator } from "@/router/use-app-navigator";
|
||||
import type { AuthEvent } from "@/stores/auth/auth-events";
|
||||
import type { PrivateZoomEvent } from "@/stores/private-zoom";
|
||||
import type { PrivateZoomUnlockPaywallRequest } from "@/stores/private-zoom/private-zoom-state";
|
||||
import type { PrivateZoneEvent } from "@/stores/private-zone";
|
||||
import type { PrivateZoneUnlockPaywallRequest } from "@/stores/private-zone/private-zone-state";
|
||||
import { useUserDispatch } from "@/stores/user/user-context";
|
||||
|
||||
export interface UsePrivateZoomBootstrapFlowInput {
|
||||
export interface UsePrivateZoneBootstrapFlowInput {
|
||||
authDispatch: Dispatch<AuthEvent>;
|
||||
hasInitialized: boolean;
|
||||
isAuthLoading: boolean;
|
||||
loginStatus: LoginStatus;
|
||||
roomDispatch: Dispatch<PrivateZoomEvent>;
|
||||
roomDispatch: Dispatch<PrivateZoneEvent>;
|
||||
roomStatus: string;
|
||||
}
|
||||
|
||||
export interface UsePrivateZoomUnlockPaywallNavigationInput {
|
||||
export interface UsePrivateZoneUnlockPaywallNavigationInput {
|
||||
loginStatus: LoginStatus;
|
||||
roomDispatch: Dispatch<PrivateZoomEvent>;
|
||||
unlockPaywallRequest: PrivateZoomUnlockPaywallRequest | null;
|
||||
roomDispatch: Dispatch<PrivateZoneEvent>;
|
||||
unlockPaywallRequest: PrivateZoneUnlockPaywallRequest | null;
|
||||
}
|
||||
|
||||
export function isPrivateZoomAuthRequired(loginStatus: LoginStatus): boolean {
|
||||
export function isPrivateZoneAuthRequired(loginStatus: LoginStatus): boolean {
|
||||
return loginStatus === "guest" || loginStatus === "notLoggedIn";
|
||||
}
|
||||
|
||||
export function usePrivateZoomBootstrapFlow({
|
||||
export function usePrivateZoneBootstrapFlow({
|
||||
authDispatch,
|
||||
hasInitialized,
|
||||
isAuthLoading,
|
||||
loginStatus,
|
||||
roomDispatch,
|
||||
roomStatus,
|
||||
}: UsePrivateZoomBootstrapFlowInput): void {
|
||||
}: UsePrivateZoneBootstrapFlowInput): void {
|
||||
const previousLoginStatusRef = useRef(loginStatus);
|
||||
|
||||
useGuestLoginBootstrap({
|
||||
@@ -56,12 +56,12 @@ export function usePrivateZoomBootstrapFlow({
|
||||
previousLoginStatusRef.current = loginStatus;
|
||||
|
||||
if (roomStatus === "idle") {
|
||||
roomDispatch({ type: "PrivateZoomInit" });
|
||||
roomDispatch({ type: "PrivateZoneInit" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (previousLoginStatus !== loginStatus && roomStatus !== "loading") {
|
||||
roomDispatch({ type: "PrivateZoomRefresh" });
|
||||
roomDispatch({ type: "PrivateZoneRefresh" });
|
||||
}
|
||||
}, [
|
||||
hasInitialized,
|
||||
@@ -72,19 +72,19 @@ export function usePrivateZoomBootstrapFlow({
|
||||
]);
|
||||
}
|
||||
|
||||
export function usePrivateZoomUnlockPaywallNavigation({
|
||||
export function usePrivateZoneUnlockPaywallNavigation({
|
||||
loginStatus,
|
||||
roomDispatch,
|
||||
unlockPaywallRequest,
|
||||
}: UsePrivateZoomUnlockPaywallNavigationInput): void {
|
||||
}: UsePrivateZoneUnlockPaywallNavigationInput): void {
|
||||
const navigator = useAppNavigator();
|
||||
const characterRoutes = useActiveCharacterRoutes();
|
||||
|
||||
useEffect(() => {
|
||||
if (!unlockPaywallRequest) return;
|
||||
|
||||
if (isPrivateZoomAuthRequired(loginStatus)) {
|
||||
navigator.openAuth(characterRoutes.privateZoom);
|
||||
if (isPrivateZoneAuthRequired(loginStatus)) {
|
||||
navigator.openAuth(characterRoutes.privateZone);
|
||||
} else {
|
||||
behaviorAnalytics.paywallShown({
|
||||
entryPoint: "private_album_unlock",
|
||||
@@ -92,16 +92,16 @@ export function usePrivateZoomUnlockPaywallNavigation({
|
||||
});
|
||||
navigator.openSubscription({
|
||||
type: "topup",
|
||||
returnTo: "private-zoom",
|
||||
returnTo: "private-zone",
|
||||
analytics: {
|
||||
entryPoint: "private_album_unlock",
|
||||
triggerReason: "insufficient_credits",
|
||||
},
|
||||
});
|
||||
}
|
||||
roomDispatch({ type: "PrivateZoomUnlockPaywallConsumed" });
|
||||
roomDispatch({ type: "PrivateZoneUnlockPaywallConsumed" });
|
||||
}, [
|
||||
characterRoutes.privateZoom,
|
||||
characterRoutes.privateZone,
|
||||
loginStatus,
|
||||
navigator,
|
||||
roomDispatch,
|
||||
@@ -109,7 +109,7 @@ export function usePrivateZoomUnlockPaywallNavigation({
|
||||
]);
|
||||
}
|
||||
|
||||
export function usePrivateZoomUnlockSuccessRefresh(
|
||||
export function usePrivateZoneUnlockSuccessRefresh(
|
||||
unlockSuccessNonce: number,
|
||||
): void {
|
||||
const userDispatch = useUserDispatch();
|
||||
@@ -191,14 +191,14 @@ export function ProfileScreen({ returnTo }: ProfileScreenProps) {
|
||||
|
||||
<AppBottomNav
|
||||
activeItem="menu"
|
||||
privateZoomLabel={
|
||||
character?.copy.privateZoomTitle ?? "Private Zoom"
|
||||
privateZoneLabel={
|
||||
character?.copy.privateZoneTitle ?? "Private Zone"
|
||||
}
|
||||
onChatClick={() =>
|
||||
navigator.push(navigation.splashUrl, { scroll: false })
|
||||
}
|
||||
onPrivateZoomClick={() =>
|
||||
navigator.push(characterRoutes.privateZoom, { scroll: false })
|
||||
onPrivateZoneClick={() =>
|
||||
navigator.push(characterRoutes.privateZone, { scroll: false })
|
||||
}
|
||||
onMenuClick={() => undefined}
|
||||
/>
|
||||
|
||||
@@ -43,8 +43,8 @@ export function SplashScreen() {
|
||||
navigator.openChat({ replace: true });
|
||||
};
|
||||
|
||||
const handleOpenPrivateZoom = () => {
|
||||
navigator.push(characterRoutes.privateZoom, { scroll: false });
|
||||
const handleOpenPrivateZone = () => {
|
||||
navigator.push(characterRoutes.privateZone, { scroll: false });
|
||||
};
|
||||
|
||||
const handleOpenSplash = () => {
|
||||
@@ -96,9 +96,9 @@ export function SplashScreen() {
|
||||
</div>
|
||||
<AppBottomNav
|
||||
activeItem="chat"
|
||||
privateZoomLabel={character.copy.privateZoomTitle}
|
||||
privateZoneLabel={character.copy.privateZoneTitle}
|
||||
onChatClick={handleOpenSplash}
|
||||
onPrivateZoomClick={handleOpenPrivateZoom}
|
||||
onPrivateZoneClick={handleOpenPrivateZone}
|
||||
onMenuClick={handleOpenMenu}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -71,7 +71,7 @@ describe("local character catalog", () => {
|
||||
expect(snapshot.catalog.getById("maya-tan")).toMatchObject({
|
||||
displayName: "Maya Backend",
|
||||
assets: { avatar: "/images/avatar/maya.png" },
|
||||
capabilities: { chat: true, privateZoom: false, tip: true },
|
||||
capabilities: { chat: true, privateZone: false, tip: true },
|
||||
});
|
||||
expect(snapshot.defaultCharacter.id).toBe("elio");
|
||||
});
|
||||
@@ -101,7 +101,7 @@ describe("local character catalog", () => {
|
||||
for (const character of CHARACTERS) {
|
||||
expect(character.capabilities).toEqual({
|
||||
chat: true,
|
||||
privateZoom: true,
|
||||
privateZone: true,
|
||||
tip: true,
|
||||
});
|
||||
expect(character.tagline.length).toBeGreaterThan(0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export interface CharacterCapabilities {
|
||||
readonly chat: boolean;
|
||||
readonly privateZoom: boolean;
|
||||
readonly privateZone: boolean;
|
||||
readonly tip: boolean;
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ export interface CharacterProfile {
|
||||
readonly avatar: string;
|
||||
readonly cover: string;
|
||||
readonly chatBackground: string;
|
||||
readonly privateZoomBanner: string;
|
||||
readonly privateZoneBanner: string;
|
||||
};
|
||||
readonly copy: {
|
||||
readonly splashRelationship: string;
|
||||
readonly privateZoomTitle: string;
|
||||
readonly privateZoomSubtitle: string;
|
||||
readonly privateZoneTitle: string;
|
||||
readonly privateZoneSubtitle: string;
|
||||
readonly tipHeader: string;
|
||||
readonly tipTitle: string;
|
||||
};
|
||||
@@ -62,19 +62,19 @@ const CHARACTER_PROFILES: readonly CharacterProfile[] = Object.freeze([
|
||||
"Finally I can relax. How was your day out?",
|
||||
capabilities: {
|
||||
chat: true,
|
||||
privateZoom: true,
|
||||
privateZone: true,
|
||||
tip: true,
|
||||
},
|
||||
assets: {
|
||||
avatar: "/images/avatar/elio.png",
|
||||
cover: "/images/cover/elio.png",
|
||||
chatBackground: "/images/chat/bg-chatpage.png",
|
||||
privateZoomBanner: "/images/private-zoom/banner/elio.png",
|
||||
privateZoneBanner: "/images/private-zone/banner/elio.png",
|
||||
},
|
||||
copy: {
|
||||
splashRelationship: "Your exclusive AI boyfriend",
|
||||
privateZoomTitle: "Elio Private Zoom",
|
||||
privateZoomSubtitle: "Join me, unlock my private zoom",
|
||||
privateZoneTitle: "Elio Private Zone",
|
||||
privateZoneSubtitle: "Join me, unlock my private zone",
|
||||
tipHeader: "Tip Elio",
|
||||
tipTitle: "Buy Elio a coffee",
|
||||
},
|
||||
@@ -91,19 +91,19 @@ const CHARACTER_PROFILES: readonly CharacterProfile[] = Object.freeze([
|
||||
"How was your day?",
|
||||
capabilities: {
|
||||
chat: true,
|
||||
privateZoom: true,
|
||||
privateZone: true,
|
||||
tip: true,
|
||||
},
|
||||
assets: {
|
||||
avatar: "/images/avatar/maya.png",
|
||||
cover: "/images/cover/maya.webp",
|
||||
chatBackground: "/images/chat/bg-chatpage.png",
|
||||
privateZoomBanner: "/images/private-zoom/banner/maya.png",
|
||||
privateZoneBanner: "/images/private-zone/banner/maya.png",
|
||||
},
|
||||
copy: {
|
||||
splashRelationship: "Your exclusive AI girlfriend",
|
||||
privateZoomTitle: "Maya Private Zoom",
|
||||
privateZoomSubtitle: "Join me, unlock my private zoom",
|
||||
privateZoneTitle: "Maya Private Zone",
|
||||
privateZoneSubtitle: "Join me, unlock my private zone",
|
||||
tipHeader: "Tip Maya",
|
||||
tipTitle: "Buy Maya a coffee",
|
||||
},
|
||||
@@ -120,19 +120,19 @@ const CHARACTER_PROFILES: readonly CharacterProfile[] = Object.freeze([
|
||||
"Tell me how your day went.",
|
||||
capabilities: {
|
||||
chat: true,
|
||||
privateZoom: true,
|
||||
privateZone: true,
|
||||
tip: true,
|
||||
},
|
||||
assets: {
|
||||
avatar: "/images/avatar/nayeli.png",
|
||||
cover: "/images/cover/nayeli.webp",
|
||||
chatBackground: "/images/chat/bg-chatpage.png",
|
||||
privateZoomBanner: "/images/private-zoom/banner/nayeli.png",
|
||||
privateZoneBanner: "/images/private-zone/banner/nayeli.png",
|
||||
},
|
||||
copy: {
|
||||
splashRelationship: "Your exclusive AI girlfriend",
|
||||
privateZoomTitle: "Nayeli Private Zoom",
|
||||
privateZoomSubtitle: "Join me, unlock my private zoom",
|
||||
privateZoneTitle: "Nayeli Private Zone",
|
||||
privateZoneSubtitle: "Join me, unlock my private zone",
|
||||
tipHeader: "Tip Nayeli",
|
||||
tipTitle: "Buy Nayeli a coffee",
|
||||
},
|
||||
@@ -186,8 +186,8 @@ export function mergeRemoteCharacterCatalog(
|
||||
sortOrder: item.sortOrder,
|
||||
capabilities: {
|
||||
chat: item.capabilities.chat,
|
||||
privateZoom:
|
||||
local.capabilities.privateZoom && item.capabilities.privateContent,
|
||||
privateZone:
|
||||
local.capabilities.privateZone && item.capabilities.privateContent,
|
||||
tip: local.capabilities.tip,
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -8,7 +8,7 @@ export * from "./character_repository";
|
||||
export * from "./feedback_repository";
|
||||
export * from "./metrics_repository";
|
||||
export * from "./payment_repository";
|
||||
export * from "./private_zoom_repository";
|
||||
export * from "./private_zone_repository";
|
||||
export * from "./user_repository";
|
||||
export * from "./interfaces/iauth_repository";
|
||||
export * from "./interfaces/ichat_repository";
|
||||
@@ -16,5 +16,5 @@ export * from "./interfaces/icharacter_repository";
|
||||
export * from "./interfaces/ifeedback_repository";
|
||||
export * from "./interfaces/imetrics_repository";
|
||||
export * from "./interfaces/ipayment_repository";
|
||||
export * from "./interfaces/iprivate_zoom_repository";
|
||||
export * from "./interfaces/iprivate_zone_repository";
|
||||
export * from "./interfaces/iuser_repository";
|
||||
|
||||
@@ -8,5 +8,5 @@ export * from "./icharacter_repository";
|
||||
export * from "./ifeedback_repository";
|
||||
export * from "./imetrics_repository";
|
||||
export * from "./ipayment_repository";
|
||||
export * from "./iprivate_zoom_repository";
|
||||
export * from "./iprivate_zone_repository";
|
||||
export * from "./iuser_repository";
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import type {
|
||||
PrivateAlbumsResponse,
|
||||
PrivateAlbumUnlockResponse,
|
||||
} from "@/data/schemas/private-zoom";
|
||||
} from "@/data/schemas/private-zone";
|
||||
import type { Result } from "@/utils/result";
|
||||
|
||||
export interface GetPrivateAlbumsInput {
|
||||
@@ -9,7 +9,7 @@ export interface GetPrivateAlbumsInput {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export interface IPrivateZoomRepository {
|
||||
export interface IPrivateZoneRepository {
|
||||
getAlbums(
|
||||
input: GetPrivateAlbumsInput,
|
||||
): Promise<Result<PrivateAlbumsResponse>>;
|
||||
+10
-10
@@ -1,22 +1,22 @@
|
||||
import type {
|
||||
GetPrivateAlbumsInput,
|
||||
IPrivateZoomRepository,
|
||||
IPrivateZoneRepository,
|
||||
} from "@/data/repositories/interfaces";
|
||||
import {
|
||||
type PrivateAlbumsResponse,
|
||||
type PrivateAlbumUnlockResponse,
|
||||
UnlockPrivateAlbumRequestSchema,
|
||||
} from "@/data/schemas/private-zoom";
|
||||
} from "@/data/schemas/private-zone";
|
||||
import {
|
||||
PrivateZoomApi,
|
||||
privateZoomApi,
|
||||
} from "@/data/services/api/private_zoom_api";
|
||||
PrivateZoneApi,
|
||||
privateZoneApi,
|
||||
} from "@/data/services/api/private_zone_api";
|
||||
import { Result } from "@/utils/result";
|
||||
|
||||
import { createLazySingleton } from "./lazy_singleton";
|
||||
|
||||
export class PrivateZoomRepository implements IPrivateZoomRepository {
|
||||
constructor(private readonly api: PrivateZoomApi) {}
|
||||
export class PrivateZoneRepository implements IPrivateZoneRepository {
|
||||
constructor(private readonly api: PrivateZoneApi) {}
|
||||
|
||||
getAlbums(
|
||||
input: GetPrivateAlbumsInput,
|
||||
@@ -37,7 +37,7 @@ export class PrivateZoomRepository implements IPrivateZoomRepository {
|
||||
}
|
||||
}
|
||||
|
||||
export const getPrivateZoomRepository =
|
||||
createLazySingleton<IPrivateZoomRepository>(
|
||||
() => new PrivateZoomRepository(privateZoomApi),
|
||||
export const getPrivateZoneRepository =
|
||||
createLazySingleton<IPrivateZoneRepository>(
|
||||
() => new PrivateZoneRepository(privateZoneApi),
|
||||
);
|
||||
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { FacebookIdentityResponseSchema } from "@/data/schemas/auth";
|
||||
import { ChatHistoryResponseSchema } from "@/data/schemas/chat";
|
||||
import { PaymentPlansResponseSchema } from "@/data/schemas/payment";
|
||||
import { PrivateAlbumsResponseSchema } from "@/data/schemas/private-zoom";
|
||||
import { PrivateAlbumsResponseSchema } from "@/data/schemas/private-zone";
|
||||
import { UserSchema } from "@/data/schemas/user";
|
||||
|
||||
describe("immutable schemas", () => {
|
||||
@@ -33,7 +33,7 @@ describe("immutable schemas", () => {
|
||||
expectDeepFrozen(response);
|
||||
});
|
||||
|
||||
it("freezes payment and private-zoom collections", () => {
|
||||
it("freezes payment and private-zone collections", () => {
|
||||
const plans = PaymentPlansResponseSchema.parse({
|
||||
firstRechargeOffer: {
|
||||
enabled: true,
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@ import {
|
||||
PrivateAlbumUnlockResponseSchema,
|
||||
PrivateAlbumsResponseSchema,
|
||||
UnlockPrivateAlbumRequestSchema,
|
||||
} from "@/data/schemas/private-zoom";
|
||||
} from "@/data/schemas/private-zone";
|
||||
import { ApiPath } from "@/data/services/api";
|
||||
|
||||
const ALBUM_ID = "a1b2c3d4-0000-0000-0000-000000000000";
|
||||
@@ -96,8 +96,8 @@ describe("Private Album schema models", () => {
|
||||
});
|
||||
|
||||
it("encodes the album id in the unlock path", () => {
|
||||
expect(ApiPath.privateZoomAlbumUnlock("album:91")).toBe(
|
||||
"/api/private-zoom/albums/album%3A91/unlock",
|
||||
expect(ApiPath.privateZoneAlbumUnlock("album:91")).toBe(
|
||||
"/api/private-zone/albums/album%3A91/unlock",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -6,7 +6,7 @@ import { ApiPath } from "../api_path";
|
||||
describe("ApiPath contract source", () => {
|
||||
it("uses the shared contract path for every static operation", () => {
|
||||
const staticOperations = Object.entries(apiContract).filter(
|
||||
([operationId]) => operationId !== "privateZoomAlbumUnlock",
|
||||
([operationId]) => operationId !== "privateZoneAlbumUnlock",
|
||||
);
|
||||
|
||||
for (const [operationId, operation] of staticOperations) {
|
||||
@@ -17,8 +17,8 @@ describe("ApiPath contract source", () => {
|
||||
});
|
||||
|
||||
it("fills and encodes the private album path parameter", () => {
|
||||
expect(ApiPath.privateZoomAlbumUnlock("album/id 1")).toBe(
|
||||
"/api/private-zoom/albums/album%2Fid%201/unlock",
|
||||
expect(ApiPath.privateZoneAlbumUnlock("album/id 1")).toBe(
|
||||
"/api/private-zone/albums/album%2Fid%201/unlock",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ vi.mock("../http_client", () => ({
|
||||
|
||||
import { ChatApi } from "../chat_api";
|
||||
import { CharacterApi } from "../character_api";
|
||||
import { PrivateZoomApi } from "../private_zoom_api";
|
||||
import { PrivateZoneApi } from "../private_zone_api";
|
||||
|
||||
const CHARACTER_ID = "elio";
|
||||
|
||||
@@ -146,18 +146,18 @@ describe("multi-character API contract", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("scopes private-zoom albums to characterId", async () => {
|
||||
it("scopes private-zone albums to characterId", async () => {
|
||||
httpClientMock.mockResolvedValue({
|
||||
success: true,
|
||||
data: { items: [], creditBalance: 0 },
|
||||
});
|
||||
|
||||
await new PrivateZoomApi().getAlbums({
|
||||
await new PrivateZoneApi().getAlbums({
|
||||
characterId: CHARACTER_ID,
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
expect(httpClientMock).toHaveBeenCalledWith("/api/private-zoom/albums", {
|
||||
expect(httpClientMock).toHaveBeenCalledWith("/api/private-zone/albums", {
|
||||
query: { characterId: CHARACTER_ID, limit: 20 },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
"chatHistory": { "method": "get", "path": "/api/chat/history" },
|
||||
"chatUnlockPrivate": { "method": "post", "path": "/api/chat/unlock-private" },
|
||||
"chatUnlockHistory": { "method": "post", "path": "/api/chat/unlock-history" },
|
||||
"privateZoomAlbums": { "method": "get", "path": "/api/private-zoom/albums" },
|
||||
"privateZoomAlbumUnlock": { "method": "post", "path": "/api/private-zoom/albums/{albumId}/unlock" },
|
||||
"privateZoneAlbums": { "method": "get", "path": "/api/private-zone/albums" },
|
||||
"privateZoneAlbumUnlock": { "method": "post", "path": "/api/private-zone/albums/{albumId}/unlock" },
|
||||
"metricsPwaEvent": { "method": "post", "path": "/api/metrics/pwa/event" },
|
||||
"reportUserInfo": { "method": "post", "path": "/api/data/report-user-info" },
|
||||
"feedback": { "method": "post", "path": "/api/feedback" },
|
||||
|
||||
@@ -81,11 +81,11 @@ export class ApiPath {
|
||||
|
||||
// ============ 私密空间相关 ============
|
||||
/** 获取私密图片包列表 */
|
||||
static readonly privateZoomAlbums = apiContract.privateZoomAlbums.path;
|
||||
static readonly privateZoneAlbums = apiContract.privateZoneAlbums.path;
|
||||
|
||||
/** 解锁私密图片包 */
|
||||
static privateZoomAlbumUnlock(albumId: string): string {
|
||||
return apiContract.privateZoomAlbumUnlock.path.replace(
|
||||
static privateZoneAlbumUnlock(albumId: string): string {
|
||||
return apiContract.privateZoneAlbumUnlock.path.replace(
|
||||
"{albumId}",
|
||||
encodeURIComponent(albumId),
|
||||
);
|
||||
|
||||
@@ -12,6 +12,6 @@ export * from "./feedback_api";
|
||||
export * from "./http_client";
|
||||
export * from "./metrics_api";
|
||||
export * from "./payment_api";
|
||||
export * from "./private_zoom_api";
|
||||
export * from "./private_zone_api";
|
||||
export * from "./response_helper";
|
||||
export * from "./user_api";
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@ import {
|
||||
PrivateAlbumUnlockResponse,
|
||||
PrivateAlbumUnlockResponseSchema,
|
||||
UnlockPrivateAlbumRequest,
|
||||
} from "@/data/schemas/private-zoom";
|
||||
} from "@/data/schemas/private-zone";
|
||||
|
||||
import { ApiPath } from "./api_path";
|
||||
import { httpClient } from "./http_client";
|
||||
@@ -15,12 +15,12 @@ export interface GetPrivateAlbumsInput {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export class PrivateZoomApi {
|
||||
export class PrivateZoneApi {
|
||||
async getAlbums(
|
||||
input: GetPrivateAlbumsInput,
|
||||
): Promise<PrivateAlbumsResponse> {
|
||||
const env = await httpClient<ApiEnvelope<unknown>>(
|
||||
ApiPath.privateZoomAlbums,
|
||||
ApiPath.privateZoneAlbums,
|
||||
{
|
||||
query: {
|
||||
characterId: input.characterId,
|
||||
@@ -36,7 +36,7 @@ export class PrivateZoomApi {
|
||||
body: UnlockPrivateAlbumRequest,
|
||||
): Promise<PrivateAlbumUnlockResponse> {
|
||||
const env = await httpClient<ApiEnvelope<unknown>>(
|
||||
ApiPath.privateZoomAlbumUnlock(albumId),
|
||||
ApiPath.privateZoneAlbumUnlock(albumId),
|
||||
{
|
||||
method: "POST",
|
||||
body,
|
||||
@@ -46,4 +46,4 @@ export class PrivateZoomApi {
|
||||
}
|
||||
}
|
||||
|
||||
export const privateZoomApi = new PrivateZoomApi();
|
||||
export const privateZoneApi = new PrivateZoneApi();
|
||||
@@ -14,7 +14,7 @@ const PendingPaymentOrderSchema = z
|
||||
subscriptionType: z.enum(["vip", "topup", "tip"]),
|
||||
giftCategory: z.string().min(1).nullable().default(null),
|
||||
giftPlanId: z.string().min(1).nullable().default(null),
|
||||
returnTo: z.enum(["chat", "private-zoom", "profile"]).optional(),
|
||||
returnTo: z.enum(["chat", "private-zone", "profile"]).optional(),
|
||||
characterSlug: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(),
|
||||
createdAt: z.number(),
|
||||
})
|
||||
|
||||
@@ -15,7 +15,7 @@ export type PaymentAnalyticsEntryPoint =
|
||||
| "chat_input"
|
||||
| "chat_unlock"
|
||||
| "private_album_unlock"
|
||||
| "private_zoom"
|
||||
| "private_zone"
|
||||
| "profile"
|
||||
| "chat_offer_banner"
|
||||
| "subscription_direct"
|
||||
@@ -32,7 +32,7 @@ const ENTRY_POINTS = new Set<PaymentAnalyticsEntryPoint>([
|
||||
"chat_input",
|
||||
"chat_unlock",
|
||||
"private_album_unlock",
|
||||
"private_zoom",
|
||||
"private_zone",
|
||||
"profile",
|
||||
"chat_offer_banner",
|
||||
"subscription_direct",
|
||||
|
||||
@@ -17,15 +17,15 @@ describe("external entry navigation", () => {
|
||||
it("resolves only canonical targets", () => {
|
||||
expect(resolveExternalEntryTarget({ target: "chat" })).toBe(ROUTES.chat);
|
||||
expect(resolveExternalEntryTarget({ target: "tip" })).toBe(ROUTES.tip);
|
||||
expect(resolveExternalEntryTarget({ target: "private-zoom" })).toBe(
|
||||
ROUTES.privateZoom,
|
||||
expect(resolveExternalEntryTarget({ target: "private-zone" })).toBe(
|
||||
ROUTES.privateZone,
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects removed aliases and unsupported targets", () => {
|
||||
expect(resolveExternalEntryTarget({ target: "tips" })).toBe(ROUTES.chat);
|
||||
expect(resolveExternalEntryTarget({ target: "coffee" })).toBe(ROUTES.chat);
|
||||
expect(resolveExternalEntryTarget({ target: "private_zoom" })).toBe(
|
||||
expect(resolveExternalEntryTarget({ target: "private_zone" })).toBe(
|
||||
ROUTES.chat,
|
||||
);
|
||||
expect(resolveExternalEntryTarget({ target: "/tip" })).toBe(ROUTES.chat);
|
||||
@@ -44,10 +44,10 @@ describe("external entry navigation", () => {
|
||||
).toBe(getCharacterRoutes("maya").chat);
|
||||
expect(
|
||||
resolveExternalEntryDestination({
|
||||
target: "private-zoom",
|
||||
target: "private-zone",
|
||||
character: "unknown",
|
||||
}),
|
||||
).toBe(getCharacterRoutes("elio").privateZoom);
|
||||
).toBe(getCharacterRoutes("elio").privateZone);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ describe("subscription exit helpers", () => {
|
||||
expect(peekPendingChatUnlockMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("returns directly to private zoom without consuming chat state", async () => {
|
||||
it("returns directly to private zone without consuming chat state", async () => {
|
||||
consumePendingChatImageReturnMock.mockResolvedValue({
|
||||
reason: "image_paywall",
|
||||
characterId: "elio",
|
||||
@@ -108,18 +108,18 @@ describe("subscription exit helpers", () => {
|
||||
createdAt: 1,
|
||||
});
|
||||
|
||||
expect(getSubscriptionFallbackExitUrl("private-zoom")).toBe(
|
||||
getCharacterRoutes("elio").privateZoom,
|
||||
expect(getSubscriptionFallbackExitUrl("private-zone")).toBe(
|
||||
getCharacterRoutes("elio").privateZone,
|
||||
);
|
||||
await expect(consumeSubscriptionExitUrl("private-zoom")).resolves.toBe(
|
||||
getCharacterRoutes("elio").privateZoom,
|
||||
await expect(consumeSubscriptionExitUrl("private-zone")).resolves.toBe(
|
||||
getCharacterRoutes("elio").privateZone,
|
||||
);
|
||||
expect(consumePendingChatImageReturnMock).not.toHaveBeenCalled();
|
||||
expect(peekPendingChatUnlockMock).not.toHaveBeenCalled();
|
||||
expect(clearPendingChatUnlockMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps private zoom ahead of stale chat state after payment", async () => {
|
||||
it("keeps private zone ahead of stale chat state after payment", async () => {
|
||||
peekPendingChatUnlockMock.mockResolvedValue({
|
||||
reason: "single_message_unlock",
|
||||
characterId: "elio",
|
||||
@@ -132,8 +132,8 @@ describe("subscription exit helpers", () => {
|
||||
});
|
||||
|
||||
await expect(
|
||||
resolveSubscriptionSuccessExitUrl("private-zoom", "maya"),
|
||||
).resolves.toBe(getCharacterRoutes("maya").privateZoom);
|
||||
resolveSubscriptionSuccessExitUrl("private-zone", "maya"),
|
||||
).resolves.toBe(getCharacterRoutes("maya").privateZone);
|
||||
expect(peekPendingChatUnlockMock).not.toHaveBeenCalled();
|
||||
expect(clearPendingChatUnlockMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ import { getCharacterRoutes, ROUTES } from "@/router/routes";
|
||||
export type ExternalEntryTarget =
|
||||
| typeof ROUTES.chat
|
||||
| typeof ROUTES.tip
|
||||
| typeof ROUTES.privateZoom;
|
||||
| typeof ROUTES.privateZone;
|
||||
|
||||
export interface ExternalEntryPayload {
|
||||
deviceId?: string | null;
|
||||
@@ -91,7 +91,7 @@ export function resolveExternalEntryDestination({
|
||||
const routes = getCharacterRoutes(characterSlug);
|
||||
const resolvedTarget = resolveExternalEntryTarget({ target });
|
||||
if (resolvedTarget === ROUTES.tip) return routes.tip;
|
||||
if (resolvedTarget === ROUTES.privateZoom) return routes.privateZoom;
|
||||
if (resolvedTarget === ROUTES.privateZone) return routes.privateZone;
|
||||
return routes.chat;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ function resolveTarget(
|
||||
|
||||
if (target === "chat") return ROUTES.chat;
|
||||
if (target === "tip") return ROUTES.tip;
|
||||
if (target === "private-zoom") return ROUTES.privateZoom;
|
||||
if (target === "private-zone") return ROUTES.privateZone;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ export function getSubscriptionFallbackExitUrl(
|
||||
): string {
|
||||
const routes = getCharacterRoutes(characterSlug);
|
||||
if (returnTo === "chat") return routes.chat;
|
||||
if (returnTo === "private-zoom") return routes.privateZoom;
|
||||
if (returnTo === "private-zone") return routes.privateZone;
|
||||
if (returnTo === "profile") {
|
||||
return buildGlobalPageUrl(ROUTES.profile, routes.chat);
|
||||
}
|
||||
@@ -58,8 +58,8 @@ export async function consumeSubscriptionExitUrl(
|
||||
returnTo: SubscriptionReturnTo,
|
||||
characterSlug: string = DEFAULT_CHARACTER_SLUG,
|
||||
): Promise<string> {
|
||||
if (returnTo === "private-zoom") {
|
||||
return getCharacterRoutes(characterSlug).privateZoom;
|
||||
if (returnTo === "private-zone") {
|
||||
return getCharacterRoutes(characterSlug).privateZone;
|
||||
}
|
||||
if (returnTo === "profile") {
|
||||
return getSubscriptionFallbackExitUrl(returnTo, characterSlug);
|
||||
@@ -75,8 +75,8 @@ export async function resolveSubscriptionSuccessExitUrl(
|
||||
returnTo: SubscriptionReturnTo,
|
||||
characterSlug: string = DEFAULT_CHARACTER_SLUG,
|
||||
): Promise<string> {
|
||||
if (returnTo === "private-zoom") {
|
||||
return getCharacterRoutes(characterSlug).privateZoom;
|
||||
if (returnTo === "private-zone") {
|
||||
return getCharacterRoutes(characterSlug).privateZone;
|
||||
}
|
||||
if (returnTo === "profile") {
|
||||
return getSubscriptionFallbackExitUrl(returnTo, characterSlug);
|
||||
|
||||
@@ -39,10 +39,10 @@ describe("payment search params", () => {
|
||||
|
||||
it("accepts only supported subscription return targets", () => {
|
||||
expect(parseSubscriptionReturnTo("chat")).toBe("chat");
|
||||
expect(parseSubscriptionReturnTo("private-zoom")).toBe("private-zoom");
|
||||
expect(parseSubscriptionReturnTo("private-zone")).toBe("private-zone");
|
||||
expect(parseSubscriptionReturnTo("profile")).toBe("profile");
|
||||
expect(parseSubscriptionReturnTo(["private-zoom", "chat"])).toBe(
|
||||
"private-zoom",
|
||||
expect(parseSubscriptionReturnTo(["private-zone", "chat"])).toBe(
|
||||
"private-zone",
|
||||
);
|
||||
expect(parseSubscriptionReturnTo("tip")).toBeNull();
|
||||
expect(parseSubscriptionReturnTo(undefined)).toBeNull();
|
||||
|
||||
@@ -20,24 +20,24 @@ describe("pending payment order helpers", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves private zoom returns when rebuilding Ezpay urls", () => {
|
||||
it("preserves private zone returns when rebuilding Ezpay urls", () => {
|
||||
expect(
|
||||
buildPendingPaymentSubscriptionUrl({
|
||||
payChannel: "ezpay",
|
||||
returnTo: "private-zoom",
|
||||
returnTo: "private-zone",
|
||||
subscriptionType: "topup",
|
||||
}),
|
||||
).toBe(
|
||||
"/subscription?type=topup&payChannel=ezpay&paymentReturn=1&returnTo=private-zoom&character=elio",
|
||||
"/subscription?type=topup&payChannel=ezpay&paymentReturn=1&returnTo=private-zone&character=elio",
|
||||
);
|
||||
});
|
||||
|
||||
it("stores private zoom as an Ezpay return target", async () => {
|
||||
it("stores private zone as an Ezpay return target", async () => {
|
||||
await clearPendingPaymentOrder();
|
||||
|
||||
const saveResult = await savePendingEzpayOrder({
|
||||
orderId: "order-private-zoom",
|
||||
returnTo: "private-zoom",
|
||||
orderId: "order-private-zone",
|
||||
returnTo: "private-zone",
|
||||
subscriptionType: "topup",
|
||||
createdAt: 1,
|
||||
});
|
||||
@@ -47,8 +47,8 @@ describe("pending payment order helpers", () => {
|
||||
expect(storedResult).toMatchObject({
|
||||
success: true,
|
||||
data: {
|
||||
orderId: "order-private-zoom",
|
||||
returnTo: "private-zoom",
|
||||
orderId: "order-private-zone",
|
||||
returnTo: "private-zone",
|
||||
},
|
||||
});
|
||||
await clearPendingPaymentOrder();
|
||||
|
||||
@@ -28,7 +28,7 @@ export function parseSubscriptionReturnTo(
|
||||
const returnTo = getFirstPaymentSearchParam(value);
|
||||
if (
|
||||
returnTo === "chat" ||
|
||||
returnTo === "private-zoom" ||
|
||||
returnTo === "private-zone" ||
|
||||
returnTo === "profile"
|
||||
) {
|
||||
return returnTo;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zone";
|
||||
|
||||
export function isPrivateAlbumLocked(album: PrivateAlbum): boolean {
|
||||
return album.locked || !album.unlocked || album.lockDetail.locked;
|
||||
@@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
const instances = vi.hoisted(() => ({
|
||||
chat: 0,
|
||||
payment: 0,
|
||||
privateZoom: 0,
|
||||
privateZone: 0,
|
||||
}));
|
||||
|
||||
vi.mock("@/stores/chat/chat-context", async () => {
|
||||
@@ -51,23 +51,23 @@ vi.mock("@/stores/payment/payment-context", async () => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("@/stores/private-zoom", async () => {
|
||||
vi.mock("@/stores/private-zone", async () => {
|
||||
const { createElement, useState } = await import("react");
|
||||
return {
|
||||
PrivateZoomProvider({
|
||||
PrivateZoneProvider({
|
||||
characterId,
|
||||
children,
|
||||
}: {
|
||||
characterId: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const [instanceId] = useState(() => ++instances.privateZoom);
|
||||
const [instanceId] = useState(() => ++instances.privateZone);
|
||||
return createElement(
|
||||
"div",
|
||||
{
|
||||
"data-character-id": characterId,
|
||||
"data-instance-id": instanceId,
|
||||
"data-testid": "private-zoom-provider",
|
||||
"data-testid": "private-zone-provider",
|
||||
},
|
||||
children,
|
||||
);
|
||||
@@ -85,7 +85,7 @@ vi.mock("@/stores/sync/payment-success-sync", () => ({
|
||||
|
||||
import { ChatRouteProviders } from "@/providers/chat-route-providers";
|
||||
import { PaymentRouteProvider } from "@/providers/payment-route-provider";
|
||||
import { PrivateZoomRouteProvider } from "@/providers/private-zoom-route-provider";
|
||||
import { PrivateZoneRouteProvider } from "@/providers/private-zone-route-provider";
|
||||
|
||||
describe("character actor route providers", () => {
|
||||
let container: HTMLDivElement;
|
||||
@@ -94,7 +94,7 @@ describe("character actor route providers", () => {
|
||||
beforeEach(() => {
|
||||
instances.chat = 0;
|
||||
instances.payment = 0;
|
||||
instances.privateZoom = 0;
|
||||
instances.privateZone = 0;
|
||||
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean })
|
||||
.IS_REACT_ACT_ENVIRONMENT = true;
|
||||
container = document.createElement("div");
|
||||
@@ -121,14 +121,14 @@ describe("character actor route providers", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("recreates the private-zoom actor when the character changes", () => {
|
||||
renderPrivateZoom("elio");
|
||||
const firstInstance = instanceId("private-zoom-provider");
|
||||
it("recreates the private-zone actor when the character changes", () => {
|
||||
renderPrivateZone("elio");
|
||||
const firstInstance = instanceId("private-zone-provider");
|
||||
|
||||
renderPrivateZoom("maya-tan");
|
||||
renderPrivateZone("maya-tan");
|
||||
|
||||
expect(instanceId("private-zoom-provider")).not.toBe(firstInstance);
|
||||
expect(testNode("private-zoom-provider").dataset.characterId).toBe(
|
||||
expect(instanceId("private-zone-provider")).not.toBe(firstInstance);
|
||||
expect(testNode("private-zone-provider").dataset.characterId).toBe(
|
||||
"maya-tan",
|
||||
);
|
||||
});
|
||||
@@ -155,12 +155,12 @@ describe("character actor route providers", () => {
|
||||
});
|
||||
}
|
||||
|
||||
function renderPrivateZoom(characterId: string): void {
|
||||
function renderPrivateZone(characterId: string): void {
|
||||
act(() => {
|
||||
root.render(
|
||||
<PrivateZoomRouteProvider characterId={characterId}>
|
||||
<span>private zoom</span>
|
||||
</PrivateZoomRouteProvider>,
|
||||
<PrivateZoneRouteProvider characterId={characterId}>
|
||||
<span>private zone</span>
|
||||
</PrivateZoneRouteProvider>,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
"use client";
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { PrivateZoneProvider } from "@/stores/private-zone";
|
||||
|
||||
export interface PrivateZoneRouteProviderProps {
|
||||
children: ReactNode;
|
||||
characterId: string;
|
||||
}
|
||||
|
||||
export function PrivateZoneRouteProvider({
|
||||
children,
|
||||
characterId,
|
||||
}: PrivateZoneRouteProviderProps) {
|
||||
return (
|
||||
<PrivateZoneProvider key={characterId} characterId={characterId}>
|
||||
{children}
|
||||
</PrivateZoneProvider>
|
||||
);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { PrivateZoomProvider } from "@/stores/private-zoom";
|
||||
|
||||
export interface PrivateZoomRouteProviderProps {
|
||||
children: ReactNode;
|
||||
characterId: string;
|
||||
}
|
||||
|
||||
export function PrivateZoomRouteProvider({
|
||||
children,
|
||||
characterId,
|
||||
}: PrivateZoomRouteProviderProps) {
|
||||
return (
|
||||
<PrivateZoomProvider key={characterId} characterId={characterId}>
|
||||
{children}
|
||||
</PrivateZoomProvider>
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* 根级 Client Providers 包装
|
||||
*
|
||||
* 这里只保留跨路由的 Character Catalog、Auth、User、消息预览和 viewport
|
||||
* Provider。Chat、Payment、PrivateZoom 状态机由对应路由 layout 按需挂载。
|
||||
* Provider。Chat、Payment、PrivateZone 状态机由对应路由 layout 按需挂载。
|
||||
*/
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
@@ -43,7 +43,7 @@ describe("global route context", () => {
|
||||
"https://example.com/characters/maya/chat",
|
||||
"//example.com/characters/maya/chat",
|
||||
"/characters/unknown/chat",
|
||||
"/characters/maya/private-zoom",
|
||||
"/characters/maya/private-zone",
|
||||
"/characters/maya/chat?image=1",
|
||||
])("falls back to Elio for an invalid return target", (value) => {
|
||||
expect(resolveGlobalRouteContextValue(value)).toBe(
|
||||
|
||||
@@ -54,15 +54,15 @@ describe("navigation resolver", () => {
|
||||
).toBe(ROUTE_BUILDERS.authWithRedirect(subscriptionUrl));
|
||||
});
|
||||
|
||||
it("builds private zoom subscription return urls", () => {
|
||||
it("builds private zone subscription return urls", () => {
|
||||
expect(
|
||||
ROUTE_BUILDERS.subscription("topup", {
|
||||
payChannel: "stripe",
|
||||
returnTo: "private-zoom",
|
||||
returnTo: "private-zone",
|
||||
sourceCharacterSlug: "maya",
|
||||
}),
|
||||
).toBe(
|
||||
"/subscription?type=topup&payChannel=stripe&returnTo=private-zoom&character=maya",
|
||||
"/subscription?type=topup&payChannel=stripe&returnTo=private-zone&character=maya",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ describe("route meta", () => {
|
||||
expect(getRouteAccess(ROUTES.splash)).toBe("authOnly");
|
||||
expect(getRouteAccess(ROUTES.auth)).toBe("authOnly");
|
||||
expect(getRouteAccess(ROUTES.chat)).toBe("guestEntry");
|
||||
expect(getRouteAccess(ROUTES.privateZoom)).toBe("guestEntry");
|
||||
expect(getRouteAccess(ROUTES.privateZone)).toBe("guestEntry");
|
||||
expect(getRouteAccess(ROUTES.tip)).toBe("public");
|
||||
expect(getRouteAccess(ROUTES.externalEntry)).toBe("public");
|
||||
expect(getRouteAccess(ROUTES.profile)).toBe("realUser");
|
||||
@@ -26,12 +26,12 @@ describe("route meta", () => {
|
||||
expect(routes).toEqual({
|
||||
splash: "/characters/maya/splash",
|
||||
chat: "/characters/maya/chat",
|
||||
privateZoom: "/characters/maya/private-zoom",
|
||||
privateZone: "/characters/maya/private-zone",
|
||||
tip: "/characters/maya/tip",
|
||||
});
|
||||
expect(getRouteAccess(routes.splash)).toBe("authOnly");
|
||||
expect(getRouteAccess(routes.chat)).toBe("guestEntry");
|
||||
expect(getRouteAccess(routes.privateZoom)).toBe("guestEntry");
|
||||
expect(getRouteAccess(routes.privateZone)).toBe("guestEntry");
|
||||
expect(getRouteAccess(routes.tip)).toBe("public");
|
||||
});
|
||||
|
||||
@@ -41,8 +41,8 @@ describe("route meta", () => {
|
||||
expect(getRouteAccess("/characters/maya/coins-rules")).toBe("public");
|
||||
});
|
||||
|
||||
it("includes private zoom in static routes", () => {
|
||||
expect(ALL_STATIC_ROUTES).toContain(ROUTES.privateZoom);
|
||||
it("includes private zone in static routes", () => {
|
||||
expect(ALL_STATIC_ROUTES).toContain(ROUTES.privateZone);
|
||||
});
|
||||
|
||||
it("includes tip in static routes", () => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
export type AppSubscriptionType = "vip" | "topup";
|
||||
export type AppSubscriptionReturnTo =
|
||||
| "chat"
|
||||
| "private-zoom"
|
||||
| "private-zone"
|
||||
| "profile"
|
||||
| null;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ const GLOBAL_ROUTE_ACCESS: Partial<Record<string, RouteAccess>> = {
|
||||
[ROUTES.splash]: "authOnly",
|
||||
[ROUTES.auth]: "authOnly",
|
||||
[ROUTES.chat]: "guestEntry",
|
||||
[ROUTES.privateZoom]: "guestEntry",
|
||||
[ROUTES.privateZone]: "guestEntry",
|
||||
[ROUTES.tip]: "public",
|
||||
[ROUTES.externalEntry]: "public",
|
||||
[ROUTES.profile]: "realUser",
|
||||
@@ -24,7 +24,7 @@ const GLOBAL_ROUTE_ACCESS: Partial<Record<string, RouteAccess>> = {
|
||||
const CHARACTER_ROUTE_ACCESS: Readonly<Record<string, RouteAccess>> = {
|
||||
splash: "authOnly",
|
||||
chat: "guestEntry",
|
||||
"private-zoom": "guestEntry",
|
||||
"private-zone": "guestEntry",
|
||||
tip: "public",
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ROUTES = {
|
||||
root: "/",
|
||||
splash: "/splash",
|
||||
chat: "/chat",
|
||||
privateZoom: "/private-zoom",
|
||||
privateZone: "/private-zone",
|
||||
tip: "/tip",
|
||||
externalEntry: "/external-entry",
|
||||
auth: "/auth",
|
||||
@@ -36,7 +36,7 @@ export type StaticRoute = (typeof ROUTES)[keyof typeof ROUTES];
|
||||
export interface CharacterRoutes {
|
||||
readonly splash: string;
|
||||
readonly chat: string;
|
||||
readonly privateZoom: string;
|
||||
readonly privateZone: string;
|
||||
readonly tip: string;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ export function getCharacterRoutes(
|
||||
return {
|
||||
splash: `${root}/splash`,
|
||||
chat: `${root}/chat`,
|
||||
privateZoom: `${root}/private-zoom`,
|
||||
privateZone: `${root}/private-zone`,
|
||||
tip: `${root}/tip`,
|
||||
};
|
||||
}
|
||||
@@ -110,7 +110,7 @@ export const ROUTE_BUILDERS = {
|
||||
export const ALL_STATIC_ROUTES: readonly StaticRoute[] = [
|
||||
ROUTES.splash,
|
||||
ROUTES.chat,
|
||||
ROUTES.privateZoom,
|
||||
ROUTES.privateZone,
|
||||
ROUTES.tip,
|
||||
ROUTES.externalEntry,
|
||||
ROUTES.auth,
|
||||
|
||||
+11
-11
@@ -2,18 +2,18 @@ import { describe, expect, it } from "vitest";
|
||||
import { createActor, waitFor } from "xstate";
|
||||
|
||||
import {
|
||||
createTestPrivateZoomMachine,
|
||||
loadPrivateZoom,
|
||||
createTestPrivateZoneMachine,
|
||||
loadPrivateZone,
|
||||
makeAlbum,
|
||||
makeAlbumsResponse,
|
||||
TEST_PRIVATE_ZOOM_INPUT,
|
||||
} from "./private-zoom-machine.test-utils";
|
||||
TEST_PRIVATE_ZONE_INPUT,
|
||||
} from "./private-zone-machine.test-utils";
|
||||
|
||||
describe("private zoom album flow", () => {
|
||||
describe("private zone album flow", () => {
|
||||
it("loads albums for the supplied character", async () => {
|
||||
let loadedCharacterId: string | null = null;
|
||||
const actor = createActor(
|
||||
createTestPrivateZoomMachine({
|
||||
createTestPrivateZoneMachine({
|
||||
onLoad: ({ characterId }) => {
|
||||
loadedCharacterId = characterId;
|
||||
},
|
||||
@@ -21,7 +21,7 @@ describe("private zoom album flow", () => {
|
||||
{ input: { characterId: "character_aria" } },
|
||||
).start();
|
||||
|
||||
actor.send({ type: "PrivateZoomInit" });
|
||||
actor.send({ type: "PrivateZoneInit" });
|
||||
await waitFor(actor, (snapshot) => snapshot.matches("ready"));
|
||||
|
||||
expect(actor.getSnapshot().context.characterId).toBe("character_aria");
|
||||
@@ -30,7 +30,7 @@ describe("private zoom album flow", () => {
|
||||
});
|
||||
|
||||
it("loads only the first non-paginated album page", async () => {
|
||||
const actor = await loadPrivateZoom({
|
||||
const actor = await loadPrivateZone({
|
||||
loadResponse: makeAlbumsResponse({
|
||||
items: Array.from({ length: 20 }, (_, index) => makeAlbum(index)),
|
||||
}),
|
||||
@@ -43,12 +43,12 @@ describe("private zoom album flow", () => {
|
||||
|
||||
it("moves to failed when the album actor rejects", async () => {
|
||||
const actor = createActor(
|
||||
createTestPrivateZoomMachine({
|
||||
createTestPrivateZoneMachine({
|
||||
loadError: new Error("albums unavailable"),
|
||||
}),
|
||||
{ input: TEST_PRIVATE_ZOOM_INPUT },
|
||||
{ input: TEST_PRIVATE_ZONE_INPUT },
|
||||
).start();
|
||||
actor.send({ type: "PrivateZoomInit" });
|
||||
actor.send({ type: "PrivateZoneInit" });
|
||||
await waitFor(actor, (snapshot) => snapshot.matches("failed"));
|
||||
expect(actor.getSnapshot().context.errorMessage).toBe(
|
||||
"albums unavailable",
|
||||
+13
-13
@@ -8,13 +8,13 @@ import {
|
||||
type PrivateAlbumUnlockResponseInput,
|
||||
type PrivateAlbumsResponse,
|
||||
type PrivateAlbumsResponseInput,
|
||||
} from "@/data/schemas/private-zoom";
|
||||
import { privateZoomMachine } from "@/stores/private-zoom/private-zoom-machine";
|
||||
} from "@/data/schemas/private-zone";
|
||||
import { privateZoneMachine } from "@/stores/private-zone/private-zone-machine";
|
||||
|
||||
export const ALBUM_ID = "a1b2c3d4-0000-0000-0000-000000000000";
|
||||
export const COVER_URL =
|
||||
"https://dbapi.banlv-ai.com/storage/v1/object/public/elio-schedules/01.jpg";
|
||||
export const TEST_PRIVATE_ZOOM_INPUT = {
|
||||
export const TEST_PRIVATE_ZONE_INPUT = {
|
||||
characterId: DEFAULT_CHARACTER_ID,
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ export function makeUnlockResponse(
|
||||
});
|
||||
}
|
||||
|
||||
export function createTestPrivateZoomMachine(
|
||||
export function createTestPrivateZoneMachine(
|
||||
options: {
|
||||
loadResponse?: PrivateAlbumsResponse;
|
||||
unlockResponse?: PrivateAlbumUnlockResponse;
|
||||
@@ -74,7 +74,7 @@ export function createTestPrivateZoomMachine(
|
||||
onLoad?: (input: { characterId: string }) => void;
|
||||
} = {},
|
||||
) {
|
||||
return privateZoomMachine.provide({
|
||||
return privateZoneMachine.provide({
|
||||
actors: {
|
||||
loadAlbums: fromPromise<PrivateAlbumsResponse, { characterId: string }>(
|
||||
async ({ input }) => {
|
||||
@@ -91,24 +91,24 @@ export function createTestPrivateZoomMachine(
|
||||
});
|
||||
}
|
||||
|
||||
export async function loadPrivateZoom(
|
||||
options: Parameters<typeof createTestPrivateZoomMachine>[0] = {},
|
||||
export async function loadPrivateZone(
|
||||
options: Parameters<typeof createTestPrivateZoneMachine>[0] = {},
|
||||
) {
|
||||
const actor = createActor(createTestPrivateZoomMachine(options), {
|
||||
input: TEST_PRIVATE_ZOOM_INPUT,
|
||||
const actor = createActor(createTestPrivateZoneMachine(options), {
|
||||
input: TEST_PRIVATE_ZONE_INPUT,
|
||||
}).start();
|
||||
actor.send({ type: "PrivateZoomInit" });
|
||||
actor.send({ type: "PrivateZoneInit" });
|
||||
await waitFor(actor, (snapshot) => snapshot.matches("ready"));
|
||||
return actor;
|
||||
}
|
||||
|
||||
export async function unlockFirstAlbum(
|
||||
actor: Awaited<ReturnType<typeof loadPrivateZoom>>,
|
||||
actor: Awaited<ReturnType<typeof loadPrivateZone>>,
|
||||
) {
|
||||
actor.send({
|
||||
type: "PrivateZoomUnlockRequested",
|
||||
type: "PrivateZoneUnlockRequested",
|
||||
albumId: ALBUM_ID,
|
||||
});
|
||||
actor.send({ type: "PrivateZoomUnlockConfirmed" });
|
||||
actor.send({ type: "PrivateZoneUnlockConfirmed" });
|
||||
await waitFor(actor, (snapshot) => snapshot.matches("ready"));
|
||||
}
|
||||
+9
-9
@@ -3,14 +3,14 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
ALBUM_ID,
|
||||
COVER_URL,
|
||||
loadPrivateZoom,
|
||||
loadPrivateZone,
|
||||
makeUnlockResponse,
|
||||
unlockFirstAlbum,
|
||||
} from "./private-zoom-machine.test-utils";
|
||||
} from "./private-zone-machine.test-utils";
|
||||
|
||||
describe("private zoom unlock flow", () => {
|
||||
describe("private zone unlock flow", () => {
|
||||
it("patches album images after a successful unlock", async () => {
|
||||
const actor = await loadPrivateZoom();
|
||||
const actor = await loadPrivateZone();
|
||||
await unlockFirstAlbum(actor);
|
||||
expect(actor.getSnapshot().context.items[0]).toMatchObject({
|
||||
albumId: ALBUM_ID,
|
||||
@@ -24,7 +24,7 @@ describe("private zoom unlock flow", () => {
|
||||
});
|
||||
|
||||
it("exposes a paywall request when credits are low", async () => {
|
||||
const actor = await loadPrivateZoom({
|
||||
const actor = await loadPrivateZone({
|
||||
unlockResponse: makeUnlockResponse({
|
||||
locked: true,
|
||||
unlocked: false,
|
||||
@@ -47,7 +47,7 @@ describe("private zoom unlock flow", () => {
|
||||
|
||||
it("reloads when expected cost changes", async () => {
|
||||
let loadCount = 0;
|
||||
const actor = await loadPrivateZoom({
|
||||
const actor = await loadPrivateZone({
|
||||
onLoad: () => {
|
||||
loadCount += 1;
|
||||
},
|
||||
@@ -66,7 +66,7 @@ describe("private zoom unlock flow", () => {
|
||||
});
|
||||
|
||||
it("removes an album that no longer exists", async () => {
|
||||
const actor = await loadPrivateZoom({
|
||||
const actor = await loadPrivateZone({
|
||||
unlockResponse: makeUnlockResponse({
|
||||
locked: true,
|
||||
unlocked: false,
|
||||
@@ -80,7 +80,7 @@ describe("private zoom unlock flow", () => {
|
||||
});
|
||||
|
||||
it("keeps refunded persistence failures locked", async () => {
|
||||
const actor = await loadPrivateZoom({
|
||||
const actor = await loadPrivateZone({
|
||||
unlockResponse: makeUnlockResponse({
|
||||
locked: true,
|
||||
unlocked: false,
|
||||
@@ -99,7 +99,7 @@ describe("private zoom unlock flow", () => {
|
||||
});
|
||||
|
||||
it("returns to ready when the unlock actor rejects", async () => {
|
||||
const actor = await loadPrivateZoom({
|
||||
const actor = await loadPrivateZone({
|
||||
unlockError: new Error("unlock unavailable"),
|
||||
});
|
||||
await unlockFirstAlbum(actor);
|
||||
@@ -3,15 +3,15 @@ import {
|
||||
PrivateAlbumSchema,
|
||||
type PrivateAlbumsResponse,
|
||||
type PrivateAlbumUnlockResponse,
|
||||
} from "@/data/schemas/private-zoom";
|
||||
} from "@/data/schemas/private-zone";
|
||||
|
||||
import type { PrivateZoomState } from "../private-zoom-state";
|
||||
import type { PrivateZoneState } from "../private-zone-state";
|
||||
|
||||
export const PRIVATE_ZOOM_PAGE_SIZE = 20;
|
||||
export const PRIVATE_ZONE_PAGE_SIZE = 20;
|
||||
|
||||
export function applyAlbumsResponse(
|
||||
response: PrivateAlbumsResponse,
|
||||
): Partial<PrivateZoomState> {
|
||||
): Partial<PrivateZoneState> {
|
||||
return {
|
||||
items: response.items,
|
||||
creditBalance: response.creditBalance,
|
||||
@@ -20,7 +20,7 @@ export function applyAlbumsResponse(
|
||||
}
|
||||
|
||||
export function getPendingAlbum(
|
||||
context: PrivateZoomState,
|
||||
context: PrivateZoneState,
|
||||
): PrivateAlbum | null {
|
||||
if (!context.pendingConfirmAlbumId) return null;
|
||||
return (
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { PrivateAlbumUnlockResponse } from "@/data/schemas/private-zoom";
|
||||
import type { PrivateAlbumUnlockResponse } from "@/data/schemas/private-zone";
|
||||
|
||||
import type { PrivateZoomUnlockPaywallRequest } from "../private-zoom-state";
|
||||
import type { PrivateZoneUnlockPaywallRequest } from "../private-zone-state";
|
||||
|
||||
export function toPrivateZoomErrorMessage(error: unknown): string {
|
||||
export function toPrivateZoneErrorMessage(error: unknown): string {
|
||||
if (error instanceof Error && error.message) return error.message;
|
||||
return "Private Zoom is temporarily unavailable. Please try again.";
|
||||
return "Private Zone is temporarily unavailable. Please try again.";
|
||||
}
|
||||
|
||||
export function toUnlockErrorMessage(
|
||||
@@ -30,7 +30,7 @@ export function toUnlockErrorMessage(
|
||||
|
||||
export function toPaywallRequest(
|
||||
response: PrivateAlbumUnlockResponse,
|
||||
): PrivateZoomUnlockPaywallRequest {
|
||||
): PrivateZoneUnlockPaywallRequest {
|
||||
return {
|
||||
albumId: response.albumId,
|
||||
reason: response.reason,
|
||||
@@ -0,0 +1,7 @@
|
||||
/** @file Private Zone store barrel. */
|
||||
|
||||
export * from "./private-zone-context";
|
||||
export * from "./private-zone-events";
|
||||
export * from "./helper";
|
||||
export * from "./private-zone-machine";
|
||||
export * from "./private-zone-state";
|
||||
+6
-6
@@ -3,19 +3,19 @@ import { fromPromise } from "xstate";
|
||||
import type {
|
||||
PrivateAlbumsResponse,
|
||||
PrivateAlbumUnlockResponse,
|
||||
} from "@/data/schemas/private-zoom";
|
||||
import { getPrivateZoomRepository } from "@/data/repositories/private_zoom_repository";
|
||||
} from "@/data/schemas/private-zone";
|
||||
import { getPrivateZoneRepository } from "@/data/repositories/private_zone_repository";
|
||||
import { Result } from "@/utils/result";
|
||||
|
||||
import { PRIVATE_ZOOM_PAGE_SIZE } from "../../helper/albums";
|
||||
import { PRIVATE_ZONE_PAGE_SIZE } from "../../helper/albums";
|
||||
|
||||
export const loadPrivateAlbumsActor =
|
||||
fromPromise<PrivateAlbumsResponse, { characterId: string }>(async ({
|
||||
input,
|
||||
}) => {
|
||||
const result = await getPrivateZoomRepository().getAlbums({
|
||||
const result = await getPrivateZoneRepository().getAlbums({
|
||||
characterId: input.characterId,
|
||||
limit: PRIVATE_ZOOM_PAGE_SIZE,
|
||||
limit: PRIVATE_ZONE_PAGE_SIZE,
|
||||
});
|
||||
if (Result.isErr(result)) throw result.error;
|
||||
return result.data;
|
||||
@@ -25,7 +25,7 @@ export const unlockPrivateAlbumActor = fromPromise<
|
||||
PrivateAlbumUnlockResponse,
|
||||
{ albumId: string; expectedCost: number }
|
||||
>(async ({ input }) => {
|
||||
const result = await getPrivateZoomRepository().unlockAlbum(
|
||||
const result = await getPrivateZoneRepository().unlockAlbum(
|
||||
input.albumId,
|
||||
input.expectedCost,
|
||||
);
|
||||
+12
-12
@@ -1,43 +1,43 @@
|
||||
import type { DoneActorEvent, ErrorActorEvent } from "xstate";
|
||||
|
||||
import type { PrivateAlbumsResponse } from "@/data/schemas/private-zoom";
|
||||
import type { PrivateAlbumsResponse } from "@/data/schemas/private-zone";
|
||||
|
||||
import { applyAlbumsResponse } from "../helper/albums";
|
||||
import { toPrivateZoomErrorMessage } from "../helper/unlock";
|
||||
import { toPrivateZoneErrorMessage } from "../helper/unlock";
|
||||
import {
|
||||
basePrivateZoomMachineSetup,
|
||||
createPrivateZoomActorActionSetup,
|
||||
basePrivateZoneMachineSetup,
|
||||
createPrivateZoneActorActionSetup,
|
||||
} from "./setup";
|
||||
|
||||
const clearAlbumLoadStateAction = basePrivateZoomMachineSetup.assign({
|
||||
const clearAlbumLoadStateAction = basePrivateZoneMachineSetup.assign({
|
||||
errorMessage: null,
|
||||
unlockPaywallRequest: null,
|
||||
});
|
||||
|
||||
export const albumMachineSetup = basePrivateZoomMachineSetup.extend({
|
||||
export const albumMachineSetup = basePrivateZoneMachineSetup.extend({
|
||||
actions: {
|
||||
clearAlbumLoadState: clearAlbumLoadStateAction,
|
||||
},
|
||||
});
|
||||
|
||||
const albumsDoneSetup =
|
||||
createPrivateZoomActorActionSetup<
|
||||
createPrivateZoneActorActionSetup<
|
||||
DoneActorEvent<PrivateAlbumsResponse>
|
||||
>();
|
||||
const albumErrorSetup =
|
||||
createPrivateZoomActorActionSetup<ErrorActorEvent>();
|
||||
createPrivateZoneActorActionSetup<ErrorActorEvent>();
|
||||
|
||||
const applyAlbumsResponseAction = albumsDoneSetup.assign(({ event }) =>
|
||||
applyAlbumsResponse(event.output),
|
||||
);
|
||||
|
||||
const applyAlbumLoadErrorAction = albumErrorSetup.assign(({ event }) => ({
|
||||
errorMessage: toPrivateZoomErrorMessage(event.error),
|
||||
errorMessage: toPrivateZoneErrorMessage(event.error),
|
||||
}));
|
||||
|
||||
export const idleState = albumMachineSetup.createStateConfig({
|
||||
on: {
|
||||
PrivateZoomInit: "loading",
|
||||
PrivateZoneInit: "loading",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ export const loadingState = albumMachineSetup.createStateConfig({
|
||||
|
||||
export const failedState = albumMachineSetup.createStateConfig({
|
||||
on: {
|
||||
PrivateZoomInit: "loading",
|
||||
PrivateZoomRefresh: "loading",
|
||||
PrivateZoneInit: "loading",
|
||||
PrivateZoneRefresh: "loading",
|
||||
},
|
||||
});
|
||||
+14
-14
@@ -1,22 +1,22 @@
|
||||
import { setup, type ActionFunction, type EventObject } from "xstate";
|
||||
|
||||
import { getPendingAlbum } from "../helper/albums";
|
||||
import type { PrivateZoomEvent } from "../private-zoom-events";
|
||||
import type { PrivateZoomState } from "../private-zoom-state";
|
||||
import type { PrivateZoneEvent } from "../private-zone-events";
|
||||
import type { PrivateZoneState } from "../private-zone-state";
|
||||
import {
|
||||
loadPrivateAlbumsActor,
|
||||
unlockPrivateAlbumActor,
|
||||
} from "./actors/albums";
|
||||
|
||||
export interface PrivateZoomMachineInput {
|
||||
export interface PrivateZoneMachineInput {
|
||||
characterId: string;
|
||||
}
|
||||
|
||||
export const basePrivateZoomMachineSetup = setup({
|
||||
export const basePrivateZoneMachineSetup = setup({
|
||||
types: {
|
||||
context: {} as PrivateZoomState,
|
||||
events: {} as PrivateZoomEvent,
|
||||
input: {} as PrivateZoomMachineInput,
|
||||
context: {} as PrivateZoneState,
|
||||
events: {} as PrivateZoneEvent,
|
||||
input: {} as PrivateZoneMachineInput,
|
||||
},
|
||||
actors: {
|
||||
loadAlbums: loadPrivateAlbumsActor,
|
||||
@@ -27,10 +27,10 @@ export const basePrivateZoomMachineSetup = setup({
|
||||
},
|
||||
});
|
||||
|
||||
type PrivateZoomActorAction<TEvent extends EventObject> = ActionFunction<
|
||||
PrivateZoomState,
|
||||
type PrivateZoneActorAction<TEvent extends EventObject> = ActionFunction<
|
||||
PrivateZoneState,
|
||||
TEvent,
|
||||
PrivateZoomEvent,
|
||||
PrivateZoneEvent,
|
||||
undefined,
|
||||
never,
|
||||
never,
|
||||
@@ -39,22 +39,22 @@ type PrivateZoomActorAction<TEvent extends EventObject> = ActionFunction<
|
||||
never
|
||||
>;
|
||||
|
||||
export function createPrivateZoomActorActionSetup<
|
||||
export function createPrivateZoneActorActionSetup<
|
||||
TEvent extends EventObject,
|
||||
>() {
|
||||
const actorActionSetup = setup({
|
||||
types: {
|
||||
context: {} as PrivateZoomState,
|
||||
context: {} as PrivateZoneState,
|
||||
events: {} as TEvent,
|
||||
},
|
||||
});
|
||||
return {
|
||||
assign(
|
||||
assignment: Parameters<typeof actorActionSetup.assign>[0],
|
||||
): PrivateZoomActorAction<TEvent> {
|
||||
): PrivateZoneActorAction<TEvent> {
|
||||
return actorActionSetup.assign(
|
||||
assignment,
|
||||
) as unknown as PrivateZoomActorAction<TEvent>;
|
||||
) as unknown as PrivateZoneActorAction<TEvent>;
|
||||
},
|
||||
};
|
||||
}
|
||||
+18
-18
@@ -1,6 +1,6 @@
|
||||
import type { DoneActorEvent, ErrorActorEvent } from "xstate";
|
||||
|
||||
import type { PrivateAlbumUnlockResponse } from "@/data/schemas/private-zoom";
|
||||
import type { PrivateAlbumUnlockResponse } from "@/data/schemas/private-zone";
|
||||
|
||||
import {
|
||||
getPendingAlbum,
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from "../helper/albums";
|
||||
import {
|
||||
toPaywallRequest,
|
||||
toPrivateZoomErrorMessage,
|
||||
toPrivateZoneErrorMessage,
|
||||
toUnlockErrorMessage,
|
||||
} from "../helper/unlock";
|
||||
import {
|
||||
@@ -18,10 +18,10 @@ import {
|
||||
idleState,
|
||||
loadingState,
|
||||
} from "./album-flow";
|
||||
import { createPrivateZoomActorActionSetup } from "./setup";
|
||||
import { createPrivateZoneActorActionSetup } from "./setup";
|
||||
|
||||
const requestUnlockAction = albumMachineSetup.assign(({ event }) =>
|
||||
event.type === "PrivateZoomUnlockRequested"
|
||||
event.type === "PrivateZoneUnlockRequested"
|
||||
? {
|
||||
pendingConfirmAlbumId: event.albumId,
|
||||
unlockErrorMessage: null,
|
||||
@@ -44,7 +44,7 @@ const beginUnlockAction = albumMachineSetup.assign(({ context }) => ({
|
||||
unlockPaywallRequest: null,
|
||||
}));
|
||||
|
||||
export const privateZoomMachineSetup = albumMachineSetup.extend({
|
||||
export const privateZoneMachineSetup = albumMachineSetup.extend({
|
||||
actions: {
|
||||
requestUnlock: requestUnlockAction,
|
||||
cancelUnlock: cancelUnlockAction,
|
||||
@@ -54,11 +54,11 @@ export const privateZoomMachineSetup = albumMachineSetup.extend({
|
||||
});
|
||||
|
||||
const unlockDoneSetup =
|
||||
createPrivateZoomActorActionSetup<
|
||||
createPrivateZoneActorActionSetup<
|
||||
DoneActorEvent<PrivateAlbumUnlockResponse>
|
||||
>();
|
||||
const unlockErrorSetup =
|
||||
createPrivateZoomActorActionSetup<ErrorActorEvent>();
|
||||
createPrivateZoneActorActionSetup<ErrorActorEvent>();
|
||||
|
||||
const applyUnlockSuccessAction = unlockDoneSetup.assign(
|
||||
({ context, event }) => ({
|
||||
@@ -111,26 +111,26 @@ const applyUnlockFailureAction = unlockDoneSetup.assign(
|
||||
const applyUnlockActorErrorAction = unlockErrorSetup.assign(({ event }) => ({
|
||||
pendingConfirmAlbumId: null,
|
||||
unlockingAlbumId: null,
|
||||
unlockErrorMessage: toPrivateZoomErrorMessage(event.error),
|
||||
unlockErrorMessage: toPrivateZoneErrorMessage(event.error),
|
||||
}));
|
||||
|
||||
const readyState = privateZoomMachineSetup.createStateConfig({
|
||||
const readyState = privateZoneMachineSetup.createStateConfig({
|
||||
on: {
|
||||
PrivateZoomInit: "loading",
|
||||
PrivateZoomRefresh: "loading",
|
||||
PrivateZoomUnlockRequested: { actions: "requestUnlock" },
|
||||
PrivateZoomUnlockCancelled: { actions: "cancelUnlock" },
|
||||
PrivateZoomUnlockConfirmed: [
|
||||
PrivateZoneInit: "loading",
|
||||
PrivateZoneRefresh: "loading",
|
||||
PrivateZoneUnlockRequested: { actions: "requestUnlock" },
|
||||
PrivateZoneUnlockCancelled: { actions: "cancelUnlock" },
|
||||
PrivateZoneUnlockConfirmed: [
|
||||
{
|
||||
guard: "hasPendingAlbum",
|
||||
target: "unlocking",
|
||||
},
|
||||
],
|
||||
PrivateZoomUnlockPaywallConsumed: { actions: "clearUnlockPaywall" },
|
||||
PrivateZoneUnlockPaywallConsumed: { actions: "clearUnlockPaywall" },
|
||||
},
|
||||
});
|
||||
|
||||
const unlockingState = privateZoomMachineSetup.createStateConfig({
|
||||
const unlockingState = privateZoneMachineSetup.createStateConfig({
|
||||
entry: "beginUnlock",
|
||||
invoke: {
|
||||
src: "unlockAlbum",
|
||||
@@ -175,8 +175,8 @@ const unlockingState = privateZoomMachineSetup.createStateConfig({
|
||||
},
|
||||
});
|
||||
|
||||
export const privateZoomRootStateConfig =
|
||||
privateZoomMachineSetup.createStateConfig({
|
||||
export const privateZoneRootStateConfig =
|
||||
privateZoneMachineSetup.createStateConfig({
|
||||
initial: "idle",
|
||||
states: {
|
||||
idle: idleState,
|
||||
+24
-24
@@ -4,14 +4,14 @@ import type { Dispatch, ReactNode } from "react";
|
||||
import { createActorContext, shallowEqual } from "@xstate/react";
|
||||
import type { SnapshotFrom } from "xstate";
|
||||
|
||||
import { privateZoomMachine } from "./private-zoom-machine";
|
||||
import { privateZoneMachine } from "./private-zone-machine";
|
||||
import type {
|
||||
PrivateZoomEvent,
|
||||
PrivateZoomState as MachineContext,
|
||||
} from "./private-zoom-machine";
|
||||
PrivateZoneEvent,
|
||||
PrivateZoneState as MachineContext,
|
||||
} from "./private-zone-machine";
|
||||
|
||||
/** Route UI reads this projection instead of the Private Zoom snapshot. */
|
||||
export interface PrivateZoomContextState {
|
||||
/** Route UI reads this projection instead of the Private Zone snapshot. */
|
||||
export interface PrivateZoneContextState {
|
||||
characterId: string;
|
||||
status: string;
|
||||
items: MachineContext["items"];
|
||||
@@ -26,45 +26,45 @@ export interface PrivateZoomContextState {
|
||||
isUnlocking: boolean;
|
||||
}
|
||||
|
||||
type PrivateZoomSnapshot = SnapshotFrom<typeof privateZoomMachine>;
|
||||
type PrivateZoomSelector<T> = (snapshot: PrivateZoomSnapshot) => T;
|
||||
type PrivateZoneSnapshot = SnapshotFrom<typeof privateZoneMachine>;
|
||||
type PrivateZoneSelector<T> = (snapshot: PrivateZoneSnapshot) => T;
|
||||
|
||||
const PrivateZoomActorContext = createActorContext(privateZoomMachine);
|
||||
const PrivateZoneActorContext = createActorContext(privateZoneMachine);
|
||||
|
||||
export interface PrivateZoomProviderProps {
|
||||
export interface PrivateZoneProviderProps {
|
||||
children: ReactNode;
|
||||
characterId: string;
|
||||
}
|
||||
|
||||
export function PrivateZoomProvider({
|
||||
export function PrivateZoneProvider({
|
||||
children,
|
||||
characterId,
|
||||
}: PrivateZoomProviderProps) {
|
||||
}: PrivateZoneProviderProps) {
|
||||
return (
|
||||
<PrivateZoomActorContext.Provider options={{ input: { characterId } }}>
|
||||
<PrivateZoneActorContext.Provider options={{ input: { characterId } }}>
|
||||
{children}
|
||||
</PrivateZoomActorContext.Provider>
|
||||
</PrivateZoneActorContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function usePrivateZoomState(): PrivateZoomContextState {
|
||||
return usePrivateZoomSelector(selectPrivateZoomState, shallowEqual);
|
||||
export function usePrivateZoneState(): PrivateZoneContextState {
|
||||
return usePrivateZoneSelector(selectPrivateZoneState, shallowEqual);
|
||||
}
|
||||
|
||||
export function usePrivateZoomDispatch(): Dispatch<PrivateZoomEvent> {
|
||||
return PrivateZoomActorContext.useActorRef().send;
|
||||
export function usePrivateZoneDispatch(): Dispatch<PrivateZoneEvent> {
|
||||
return PrivateZoneActorContext.useActorRef().send;
|
||||
}
|
||||
|
||||
export function usePrivateZoomSelector<T>(
|
||||
selector: PrivateZoomSelector<T>,
|
||||
export function usePrivateZoneSelector<T>(
|
||||
selector: PrivateZoneSelector<T>,
|
||||
compare?: (previous: T, next: T) => boolean,
|
||||
): T {
|
||||
return PrivateZoomActorContext.useSelector(selector, compare);
|
||||
return PrivateZoneActorContext.useSelector(selector, compare);
|
||||
}
|
||||
|
||||
function selectPrivateZoomState(
|
||||
state: PrivateZoomSnapshot,
|
||||
): PrivateZoomContextState {
|
||||
function selectPrivateZoneState(
|
||||
state: PrivateZoneSnapshot,
|
||||
): PrivateZoneContextState {
|
||||
return {
|
||||
characterId: state.context.characterId,
|
||||
status: String(state.value),
|
||||
@@ -0,0 +1,8 @@
|
||||
/** Public events for one character-scoped Private Zone actor. */
|
||||
export type PrivateZoneEvent =
|
||||
| { type: "PrivateZoneInit" }
|
||||
| { type: "PrivateZoneRefresh" }
|
||||
| { type: "PrivateZoneUnlockRequested"; albumId: string }
|
||||
| { type: "PrivateZoneUnlockConfirmed" }
|
||||
| { type: "PrivateZoneUnlockCancelled" }
|
||||
| { type: "PrivateZoneUnlockPaywallConsumed" };
|
||||
@@ -0,0 +1,18 @@
|
||||
import {
|
||||
privateZoneMachineSetup,
|
||||
privateZoneRootStateConfig,
|
||||
} from "./machine/unlock-flow";
|
||||
import { createInitialPrivateZoneState } from "./private-zone-state";
|
||||
|
||||
export type { PrivateZoneEvent } from "./private-zone-events";
|
||||
export type { PrivateZoneState } from "./private-zone-state";
|
||||
export { initialState } from "./private-zone-state";
|
||||
|
||||
export const privateZoneMachine = privateZoneMachineSetup.createMachine({
|
||||
id: "privateZone",
|
||||
context: ({ input }) =>
|
||||
createInitialPrivateZoneState(input.characterId),
|
||||
...privateZoneRootStateConfig,
|
||||
});
|
||||
|
||||
export type PrivateZoneMachine = typeof privateZoneMachine;
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
import { DEFAULT_CHARACTER_ID } from "@/data/constants/character";
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
|
||||
import type { PrivateAlbum } from "@/data/schemas/private-zone";
|
||||
|
||||
export interface PrivateZoomUnlockPaywallRequest {
|
||||
export interface PrivateZoneUnlockPaywallRequest {
|
||||
albumId: string;
|
||||
reason: string;
|
||||
requiredCredits: number;
|
||||
@@ -9,7 +9,7 @@ export interface PrivateZoomUnlockPaywallRequest {
|
||||
shortfallCredits: number;
|
||||
}
|
||||
|
||||
export interface PrivateZoomState {
|
||||
export interface PrivateZoneState {
|
||||
characterId: string;
|
||||
items: readonly PrivateAlbum[];
|
||||
creditBalance: number;
|
||||
@@ -17,13 +17,13 @@ export interface PrivateZoomState {
|
||||
unlockingAlbumId: string | null;
|
||||
unlockErrorMessage: string | null;
|
||||
pendingConfirmAlbumId: string | null;
|
||||
unlockPaywallRequest: PrivateZoomUnlockPaywallRequest | null;
|
||||
unlockPaywallRequest: PrivateZoneUnlockPaywallRequest | null;
|
||||
unlockSuccessNonce: number;
|
||||
}
|
||||
|
||||
export function createInitialPrivateZoomState(
|
||||
export function createInitialPrivateZoneState(
|
||||
characterId: string,
|
||||
): PrivateZoomState {
|
||||
): PrivateZoneState {
|
||||
return {
|
||||
characterId,
|
||||
items: [],
|
||||
@@ -37,4 +37,4 @@ export function createInitialPrivateZoomState(
|
||||
};
|
||||
}
|
||||
|
||||
export const initialState = createInitialPrivateZoomState(DEFAULT_CHARACTER_ID);
|
||||
export const initialState = createInitialPrivateZoneState(DEFAULT_CHARACTER_ID);
|
||||
@@ -1,7 +0,0 @@
|
||||
/** @file Private Zoom store barrel. */
|
||||
|
||||
export * from "./private-zoom-context";
|
||||
export * from "./private-zoom-events";
|
||||
export * from "./helper";
|
||||
export * from "./private-zoom-machine";
|
||||
export * from "./private-zoom-state";
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Public events for one character-scoped Private Zoom actor. */
|
||||
export type PrivateZoomEvent =
|
||||
| { type: "PrivateZoomInit" }
|
||||
| { type: "PrivateZoomRefresh" }
|
||||
| { type: "PrivateZoomUnlockRequested"; albumId: string }
|
||||
| { type: "PrivateZoomUnlockConfirmed" }
|
||||
| { type: "PrivateZoomUnlockCancelled" }
|
||||
| { type: "PrivateZoomUnlockPaywallConsumed" };
|
||||
@@ -1,18 +0,0 @@
|
||||
import {
|
||||
privateZoomMachineSetup,
|
||||
privateZoomRootStateConfig,
|
||||
} from "./machine/unlock-flow";
|
||||
import { createInitialPrivateZoomState } from "./private-zoom-state";
|
||||
|
||||
export type { PrivateZoomEvent } from "./private-zoom-events";
|
||||
export type { PrivateZoomState } from "./private-zoom-state";
|
||||
export { initialState } from "./private-zoom-state";
|
||||
|
||||
export const privateZoomMachine = privateZoomMachineSetup.createMachine({
|
||||
id: "privateZoom",
|
||||
context: ({ input }) =>
|
||||
createInitialPrivateZoomState(input.characterId),
|
||||
...privateZoomRootStateConfig,
|
||||
});
|
||||
|
||||
export type PrivateZoomMachine = typeof privateZoomMachine;
|
||||
Reference in New Issue
Block a user