Added shop and checkout to the CMS
Checkout is done with stripe Added reservation system
This commit is contained in:
parent
09e54033dd
commit
702d99b9ed
42 changed files with 3332 additions and 21 deletions
31
README.md
31
README.md
|
|
@ -86,6 +86,17 @@ If schema import fails because of a PocketBase version mismatch, create these co
|
|||
- `file`: file, required, max select `1`, image mime types
|
||||
- `alt`: text
|
||||
|
||||
Commerce collections (see the Stripe section above for context):
|
||||
|
||||
- `items` — `name` text, `description` text, `price` number, `image` relation→media, `type` select `item|item_with_time`, `stock` number (nullable), `duration` number (nullable, minutes), `active` bool
|
||||
- `slots` — `item` relation→items, `start` date, `end` date, `status` select `available|held|booked`, `heldUntil` date (nullable), `order` relation→orders (nullable), `notes` text
|
||||
- `baskets` — `status` select `active|completed|abandoned`, `expiresAt` date, `email` text, `customerDetails` json, `stripePaymentIntentId` text
|
||||
- `basket_lines` — `basket` relation→baskets, `item` relation→items, `slot` relation→slots (nullable), `quantity` number, `lineType` select `item|slot`
|
||||
- `orders` — `basket` relation→baskets, `email` text, `customerDetails` json, `total` number, `status` select `pending|paid|refunded`, `stripePaymentIntentId` text
|
||||
- `order_lines` — `order` relation→orders, `item` relation→items, `slot` relation→slots (nullable), `quantity` number, `lineType` select `item|slot`, `name` text (snapshot), `price` number (snapshot), `start` date (nullable, snapshot)
|
||||
|
||||
> **Schema format note:** `pb_schema.json` targets PocketBase 0.23+ using the `fields` array (not the legacy `schema` array). Relation and select fields carry their config (`collectionId`, `cascadeDelete`, `maxSelect`, `values`) at the field top level, not nested under `options`. Importing the whole file via the PocketBase admin UI or `PUT /api/collections/import` creates or updates all collections in one pass.
|
||||
|
||||
## Authentication
|
||||
|
||||
Admin routes live under `/admin`. Login accepts either:
|
||||
|
|
@ -100,8 +111,28 @@ All `/admin` routes except `/admin/login` are guarded in `src/hooks.server.ts`.
|
|||
- `/admin/login` — sign in
|
||||
- `/admin/pages` — list/create pages
|
||||
- `/admin/pages/[slug]` — block editor with draft preview
|
||||
- `/admin/calendar` — events shown by Upcoming Calendar blocks
|
||||
- `/admin/items` — services and products shown in Shop blocks
|
||||
- `/admin/slots` — manually created bookable time slots for services
|
||||
- `/admin/orders` — read-only list of confirmed bookings and purchases
|
||||
- `/admin/globals` — header/footer editor
|
||||
|
||||
## Reservations & payments (Stripe)
|
||||
|
||||
The shop/checkout blocks implement a basket-based booking flow: visitors add services (with time slots) or products to a server-side basket, then pay with an embedded Stripe Payment Element. Order creation is confirmed by the Stripe **webhook** (never the client).
|
||||
|
||||
Setup:
|
||||
|
||||
1. Add the Stripe + PocketBase-admin vars from `app/.env.example` to `app/.env` (local dev) or a root-level `.env` next to `docker-compose.yml` (Docker).
|
||||
2. `POCKETBASE_ADMIN_EMAIL` / `POCKETBASE_ADMIN_PASSWORD` are the credentials of the PocketBase superuser you created — the basket/checkout/webhook APIs use a server-side admin client so collection rules can stay admin-only.
|
||||
3. For local webhook testing, forward Stripe events with the CLI:
|
||||
```sh
|
||||
stripe listen --forward-to localhost:8080/api/webhooks/stripe
|
||||
```
|
||||
Copy the printed `whsec_…` signing secret into `STRIPE_WEBHOOK_SECRET`.
|
||||
4. Import the updated `pb_schema.json` (adds `items`, `slots`, `baskets`, `basket_lines`, `orders`, `order_lines`). The `basket_lines.slot` partial unique index guarantees two visitors can't hold the same slot.
|
||||
5. Create a published page (e.g. slug `book`) with a `shop` block and a `checkout` block, and point the header CTA at it.
|
||||
|
||||
## Public routes
|
||||
|
||||
- `/` renders `pages.slug = "home"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue