@cosmocart/bookings-react
v0.2.0
Published
Owner admin React helpers for Cosmo Bookings (provider, hooks, BookingsAdminList).
Readme
@cosmocart/bookings-react
Owner/admin React helpers for Cosmo Bookings. Drop these into any custom frontend so authenticated owners can list bookings, approve/reject/cancel/ reschedule, and manage services + availability — without depending on the hosted admin app.
npm install @cosmocart/bookings-reactQuick start
import {
CosmoBookingsProvider,
BookingsAdminList,
} from '@cosmocart/bookings-react';
function Admin({ accessToken }: { accessToken: string }) {
return (
<CosmoBookingsProvider
apiBaseUrl="https://cosmo-bookings-api-....run.app"
jwt={accessToken}
>
<BookingsAdminList />
</CosmoBookingsProvider>
);
}The JWT is a Supabase Auth access token from the same project that backs the
cosmo-bookings API. Public customer embeds continue to use
@cosmocart/bookings-widget with a publishable pk_ key.
Exports
| Export | Purpose |
|---|---|
| CosmoBookingsAdminClient | Typed owner REST client (injectable JWT) |
| CosmoBookingsProvider / useCosmoBookings | React context around the client |
| useOwnerBookings | List + approve/reject/cancel/reschedule |
| useServices | Services CRUD |
| useAvailability | Weekly hours + date overrides |
| BookingsAdminList | Ready-made admin list UI |
| useSupabaseSession | Zero-dep convenience session reader |
Auth model
Owner endpoints require Authorization: Bearer <supabase-jwt>. The Nest API
scopes every query to auth.uid() / the JWT sub, so each consumer only sees
their own bookings, services, and keys.
