@schematichq/schematic-react 1.4.0 → 1.5.0
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/README.md +27 -0
- package/dist/schematic-react.cjs.js +665 -27
- package/dist/schematic-react.d.ts +1042 -32
- package/dist/schematic-react.esm.js +665 -27
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -175,6 +175,33 @@ The hook returns an object with the following properties:
|
|
|
175
175
|
| `trialEndDate` | `Date \| undefined` | The trial end date, if the company has or had a trial |
|
|
176
176
|
| `trialStatus` | `"active" \| "expired" \| "converted" \| undefined` | The company's trial status: `active` if the trial is ongoing, `expired` if the trial ended without conversion, `converted` if the company converted to a paid plan, or `undefined` if the company has never trialed |
|
|
177
177
|
|
|
178
|
+
### Credit balances
|
|
179
|
+
|
|
180
|
+
To display a company's credit balance, use the `useSchematicCreditBalance` hook. It is keyed by credit ID and updates reactively as the balance changes over the DataStream:
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
import { useSchematicCreditBalance } from "@schematichq/schematic-react";
|
|
184
|
+
|
|
185
|
+
const CreditMeter = () => {
|
|
186
|
+
const { balance, isLoading } = useSchematicCreditBalance("credit-id");
|
|
187
|
+
|
|
188
|
+
if (isLoading) {
|
|
189
|
+
return <div>Loading…</div>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return <div>{balance} credits remaining</div>;
|
|
193
|
+
};
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The hook returns an object with the following properties:
|
|
197
|
+
|
|
198
|
+
| Property | Type | Description |
|
|
199
|
+
| --- | --- | --- |
|
|
200
|
+
| `balance` | `number` | The spendable balance, or `0` while loading or when the company holds no balance in this credit |
|
|
201
|
+
| `isLoading` | `boolean` | `true` while the balance is still loading and no value has arrived yet |
|
|
202
|
+
|
|
203
|
+
The credit ID is available on a feature's entitlement: `useSchematicEntitlement(key)` returns `creditId` for credit-based features.
|
|
204
|
+
|
|
178
205
|
## Fallback Behavior
|
|
179
206
|
|
|
180
207
|
The SDK includes built-in fallback behavior you can use to ensure your application continues to function even when unable to reach Schematic (e.g., during service disruptions or network issues).
|