uniweb 1.35.5 → 1.35.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uniweb",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.6",
|
|
4
4
|
"description": "Create structured Vite + React sites with content/code separation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"js-yaml": "^4.3.2",
|
|
42
42
|
"prompts": "^2.4.2",
|
|
43
43
|
"tar": "^7.5.21",
|
|
44
|
+
"@uniweb/schemas": "~1.7.5",
|
|
44
45
|
"@uniweb/core": "~1.6.13",
|
|
45
46
|
"@uniweb/semantic-parser": "~1.13.6",
|
|
46
|
-
"@uniweb/content-writer": "~1.3.3"
|
|
47
|
-
"@uniweb/schemas": "~1.7.5"
|
|
47
|
+
"@uniweb/content-writer": "~1.3.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@uniweb/semantic-parser": "~1.13.6",
|
|
51
50
|
"@uniweb/content-reader": "~1.5.12",
|
|
51
|
+
"@uniweb/semantic-parser": "~1.13.6",
|
|
52
52
|
"@uniweb/build": "~1.24.4"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
@@ -124,7 +124,7 @@ A site with a backend is a solution: public pages, a members' area for each role
|
|
|
124
124
|
## Selling
|
|
125
125
|
|
|
126
126
|
```jsx
|
|
127
|
-
import { useStore, offeringState, useEntitlements, useHolders } from '@uniweb/api'
|
|
127
|
+
import { useStore, offeringState, useCoupon, couponReason, useEntitlements, useHolders } from '@uniweb/api'
|
|
128
128
|
const { status, store, offerings, checkout, checking } = useStore({ entity: course.uuid }) // 'none': the site sells nothing
|
|
129
129
|
offeringState(offering, store) // 'owned' · 'take' (a free one-off) · 'not-ready' (payments not connected) · 'buy'
|
|
130
130
|
await checkout(offering) // sends the buyer to pay; a free one-off is held at once: { url: null, held: true }
|
|
@@ -135,6 +135,8 @@ await checkout(offering) // sends the buyer to pay; a free one-off is he
|
|
|
135
135
|
- A purchase lets the buyer read the record, and through it what its `sold_with` references point to: `useEntity({ schema: '@/lesson', uuid, via: course.uuid })`.
|
|
136
136
|
- `useEntitlements()` — what the viewer holds, for "My courses". `useHolders({ schema, uuid })` — who holds a record, for a roster: its owner's or an `admin`'s to read, `forbidden` for anyone else, so draw nothing.
|
|
137
137
|
- Why a checkout was refused: `error.extensions.reason` — `payments_not_ready`, `coupon_not_applicable` (with `cause`), `not_for_sale`.
|
|
138
|
+
- A coupon code: `const { check, coupon, applied, checking, clear } = useCoupon()`. `check(code)` previews it with the checkout's rules: `coupon.discount` (`{ type: 'percent'|'amount', value, currency?, duration }`), or `valid: false` with `coupon.reason`, one of `COUPON_CAUSE` from `@uniweb/api/wire`. `couponReason(coupon, offering)` adds `wrong_currency` (an amount off in another currency); a free offering ignores a code. Word each reason in your foundation, with a fallback for a new one. Then `checkout(offering, { coupon: applied })`. It checks again, and a refusal's `cause` is the same set.
|
|
139
|
+
- Paying in the page: `const { payment } = await checkout(offering, { coupon, inPage: true })`, then `<Overlay open onClose={payment.cancel}><div ref={payment.mount} /></Overlay>` and `await payment.done` (`'paid'`/`'cancelled'`; after `'paid'`, `refresh()` until `owned`). The provider's form shows the total and discount itself. Where the backend can't, `checkout` navigates to the payment page as usual.
|
|
138
140
|
|
|
139
141
|
**Prices for visitors who aren't signed in** come as records, so the first page a visit lands on already shows them, to people and to search engines. A section declares the store's catalog, a site query reads it, and the site's `blueprint.yml` opens it to visitors:
|
|
140
142
|
|
package/src/framework-index.json
CHANGED