@zooly/app-client is a React client package that provides reusable UI components and screens for the main application. This package contains pure React code that doesn't assume a specific framework (like Next.js), but uses Tailwind CSS for styling.
@zooly/app-clientpackages/clientdata-testid attributes for automated testingThe package includes:
M3Button, Sidebar, UserHomeDashboardScreen, LicenseImageScreen, LicenseMerchScreen, LicenseVoiceScreen, ProfileSetupScreen, SetupScreenThis package is used by Next.js apps and Vite apps as a shared component library. It provides the core UI building blocks for the application.
fetchJson@zooly/app-client exports fetchJson (formerly zFetch), a lightweight wrapper around standard fetch tailored for JSON API endpoints:
options.body (JSON.stringify(body)).Content-Type: application/json header by default.Error if response.ok is false.response.json().import { fetchJson } from "@zooly/app-client";
// GET request with JSON parsing & error checking
const user = await fetchJson<UserProfile>("/api/account/profile");
// POST request with automatic body serialization
const result = await fetchJson<SaveResult>("/api/account/settings", {
method: "POST",
body: { theme: "dark", notifications: true },
});
In Zooly2, "Acting As" another account (e.g. from the admin dashboard) does not require manual injection of client IDs in individual API functions.
sessionStorage (zly_acting_as_account_id) via packages/offers/client/src/lib/client-id.ts. It is isolated to a single browser tab and automatically disappears when the tab is closed.installActAsFetchInterceptor):
actAsFetch by monkey-patching window.fetch./api/ automatically receives the x-client-id: <accountId> header.fetchJson(...), typed @zooly/api-client, or third-party client packages using global fetch, the x-client-id header is attached without manual parameter passing.x-client-id and converts it into a per-request cookie (zly_acting_as_account_id) for downstream auth handlers.| Function / Symbol | Package | Purpose |
|---|---|---|
fetchJson(url, options) | @zooly/app-client | JSON request helper (auto-stringifies body, sets headers, handles HTTP errors). |
actAsFetch(input, init) | packages/offers/client | Low-level fetch wrapper adhering to typeof fetch that injects x-client-id. |
installActAsFetchInterceptor() | packages/offers/client | Bootstraps actAsFetch on window.fetch at dashboard startup. |
createOffersApi() | @zooly/api-client | Strongly-typed API client contracts for offer endpoints. |