"use client"; import { createPlatformClient, type PlatformClient } from "@bytelyst/platform-client"; import { PLATFORM_SERVICE_URL, PRODUCT_ID } from "@/lib/product-config"; import { getAccessToken } from "@/lib/api-helpers"; let _client: PlatformClient | null = null; function getClient(): PlatformClient { if (!_client) { _client = createPlatformClient({ baseUrl: PLATFORM_SERVICE_URL, productId: PRODUCT_ID, getAccessToken, }); } return _client; } export interface UserSettings { theme?: "dark" | "light" | "system"; language?: string; notificationsEnabled?: boolean; [key: string]: unknown; } export interface ActiveSession { id: string; deviceName: string; lastActiveAt: string; isCurrent: boolean; } export async function getUserSettings(): Promise { return getClient().get("/settings"); } export async function updateUserSettings(settings: Partial): Promise { return getClient().put("/settings", settings); } export async function listSessions(): Promise { return getClient().get("/sessions"); } export async function revokeSession(sessionId: string): Promise { await getClient().del(`/sessions/${sessionId}`); } export async function updateProfile(updates: { displayName?: string }): Promise { await getClient().put("/auth/profile", updates); }