Files
cozsweet-frontend-nextjs/src/stores/private-room/private-room-state.ts
T

41 lines
1.1 KiB
TypeScript

import { DEFAULT_CHARACTER_ID } from "@/data/constants/character";
import type { PrivateAlbum } from "@/data/schemas/private-room";
export interface PrivateRoomUnlockPaywallRequest {
albumId: string;
reason: string;
requiredCredits: number;
currentCredits: number;
shortfallCredits: number;
}
export interface PrivateRoomState {
characterId: string;
items: readonly PrivateAlbum[];
creditBalance: number;
errorMessage: string | null;
unlockingAlbumId: string | null;
unlockErrorMessage: string | null;
pendingConfirmAlbumId: string | null;
unlockPaywallRequest: PrivateRoomUnlockPaywallRequest | null;
unlockSuccessNonce: number;
}
export function createInitialPrivateRoomState(
characterId: string,
): PrivateRoomState {
return {
characterId,
items: [],
creditBalance: 0,
errorMessage: null,
unlockingAlbumId: null,
unlockErrorMessage: null,
pendingConfirmAlbumId: null,
unlockPaywallRequest: null,
unlockSuccessNonce: 0,
};
}
export const initialState = createInitialPrivateRoomState(DEFAULT_CHARACTER_ID);