@geophrase/react 1.6.1 → 1.8.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 +4 -2
- package/package.json +2 -2
- package/src/useGeophrase.js +3 -1
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ export default function Checkout() {
|
|
|
32
32
|
mode: 'server', // widget returns a token your backend exchanges for the address
|
|
33
33
|
theme: 'system', // 'light' | 'dark' | 'system'
|
|
34
34
|
orderId: 'ORD-98765', // your internal reference id
|
|
35
|
-
phone: '9999999999', //
|
|
35
|
+
phone: '9999999999', // prefills the phone field
|
|
36
36
|
|
|
37
37
|
onSuccess: (data) => setResult(data),
|
|
38
38
|
onError: (error) => console.error('Error:', error.message),
|
|
@@ -78,7 +78,9 @@ const { open } = useGeophrase({
|
|
|
78
78
|
| `key` | `string` | **Conditional** | Your secret [Geophrase API key](https://geophrase.com/docs/api-keys). **Required if `mode` is `'client'`.** Omit if using server mode. |
|
|
79
79
|
| `theme` | `string` | Optional | `'light'`, `'dark'`, or `'system'`. Defaults to `'system'`. |
|
|
80
80
|
| `orderId` | `string` | Optional | Your internal reference ID for this checkout session. |
|
|
81
|
-
| `
|
|
81
|
+
| `hubCode` | `string` | **Conditional** | Delivery hub code (from Settings > Delivery hubs). Client mode only; required when `mode` is `'client'` and your business has more than one active delivery hub. In server mode, send `hub_code` from your backend to the [resolve call](https://geophrase.com/docs/resolve-endpoint). |
|
|
82
|
+
| `noteForAgent` | `string` | Optional | Note shown to your delivery agent, never to the customer. Client mode only; notes over 300 characters are cut. It is sent from the customer's device, so the customer can change it; send payment instructions, such as cash to collect, from your server or the dashboard. In server mode, send `note_for_agent` with your [resolve call](https://geophrase.com/docs/resolve-endpoint). |
|
|
83
|
+
| `phone` | `string` | Optional | Pre-fills the phone field with a 10-digit Indian mobile number. |
|
|
82
84
|
| `onSuccess` | `function` | **Yes** | Called upon completion. Returns an `Address` object (`mode: 'client'`) or a `Token` object (`mode: 'server'`). |
|
|
83
85
|
| `onError` | `function` | Optional | Called if the API fails or a network error occurs. Returns an `Error` object. |
|
|
84
86
|
| `onClose` | `function` | Optional | Called when the user closes the modal without completing the flow. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geophrase/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "React & Next.js hook for the Geophrase address picker. Drop-in widget that captures structured Indian addresses with coordinates to reduce RTO.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Geophrase",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"react": ">=16.8.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@geophrase/core": "^1.
|
|
47
|
+
"@geophrase/core": "^1.8.0"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
package/src/useGeophrase.js
CHANGED
|
@@ -29,7 +29,9 @@ export const useGeophrase = (options = {}) => {
|
|
|
29
29
|
mode: options.mode,
|
|
30
30
|
theme: options.theme,
|
|
31
31
|
key: options.key,
|
|
32
|
+
hubCode: options.hubCode,
|
|
32
33
|
orderId: options.orderId,
|
|
34
|
+
noteForAgent: options.noteForAgent,
|
|
33
35
|
phone: options.phone,
|
|
34
36
|
onSuccess: (data) => {
|
|
35
37
|
if (savedCallbacks.current.onSuccess) savedCallbacks.current.onSuccess(data);
|
|
@@ -52,7 +54,7 @@ export const useGeophrase = (options = {}) => {
|
|
|
52
54
|
}
|
|
53
55
|
};
|
|
54
56
|
// Include mode and theme in the dependency array so the instance rebuilds if they change state
|
|
55
|
-
}, [options.keyId, options.mode, options.theme, options.key, options.orderId, options.phone]);
|
|
57
|
+
}, [options.keyId, options.mode, options.theme, options.key, options.hubCode, options.orderId, options.noteForAgent, options.phone]);
|
|
56
58
|
|
|
57
59
|
const open = useCallback(() => {
|
|
58
60
|
if (geoInstance.current) {
|