@zappie/checkout-fields 0.1.2 → 0.2.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/CHANGELOG.md +32 -0
- package/dist/contact.js +1 -1
- package/dist/contact.js.map +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @zappie/checkout-fields
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7980f3c: A shopper can order a pickup or a delivery for someone else. The order goes out under that person's name and phone, and the signed-in customer still pays for it and owns it.
|
|
8
|
+
|
|
9
|
+
- `@zappie/sdk`: a checkout request takes `contact_name` beside `contact_phone`.
|
|
10
|
+
- `@zappie/foundations`: `flow.contact.recipient` is the "Ordering for someone else?" switch with their name and phone, labelled `Deliver to` or `Collected by`. It's left out for an in-venue order. While it's on, Pay asks for both, with problems keyed `recipient_name` and `recipient_phone`, the shopper's own phone isn't asked, and the checkout sends them as `contact_name` and `contact_phone`. The switch and what's typed are kept for the session, like the contact details. `recipientProblems()` checks a dialog's own draft of them the same way.
|
|
11
|
+
- `@zappie/checkout-fields`: `recipientProblemText()` words those two problems, and `contactProblemTexts()` uses it. `useContactDraft()` asks for no phone of the shopper's own while the switch is on.
|
|
12
|
+
- `@zappie/starter`: the bag's Your details has the switch and the two fields.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [7980f3c]
|
|
17
|
+
- @zappie/sdk@0.27.0
|
|
18
|
+
- @zappie/foundations@0.26.0
|
|
19
|
+
|
|
20
|
+
## 0.1.4
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [80af2eb]
|
|
25
|
+
- @zappie/sdk@0.26.0
|
|
26
|
+
- @zappie/foundations@0.25.0
|
|
27
|
+
|
|
28
|
+
## 0.1.3
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [6186e4f]
|
|
33
|
+
- @zappie/foundations@0.24.0
|
|
34
|
+
|
|
3
35
|
## 0.1.2
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/dist/contact.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{contactProblems}from"@zappie/foundations/checkout";import{useState}from"react";function contactProblemText(problem,field){if(!problem){return void 0}if(!field){return problem==="invalid"?"Check this number":"Add your phone number"}if(problem==="invalid"){return field.type==="email"?"Check this email address":`Check your ${field.label.toLowerCase()}`}return`Add your ${field.label.toLowerCase()}`}function contactProblemTexts(fields,problems){const text={};for(const[key,problem]of Object.entries(problems)){const message=contactProblemText(problem,key==="phone"?void 0:fields.find(field=>field.key===key));if(message){text[key]=message}}return text}function useContactDraft(contact,focus,dialCode="+234"){const[phone,setPhone]=useState(contact.phone.startsWith(dialCode)?contact.phone.slice(dialCode.length):contact.phone);const[values,setValues]=useState(contact.values);const[tried,setTried]=useState(contact.shown.has(focus));const problems=contactProblems(contact.fields,values,phone,contact.accountPhone,dialCode);return{phone,setPhone,values,setValue:(key,value)=>setValues({...values,[key]:value}),problem:key=>tried?contactProblemText(problems[key],key==="phone"?void 0:contact.fields.find(field=>field.key===key)):void 0,save:()=>{const first=Object.keys(problems)[0];if(first){setTried(true);return first}contact.setPhone(phone);for(const field of contact.fields){contact.setField(field.key,values[field.key]??"")}for(const key of["phone",...contact.fields.map(field=>field.key)]){contact.show(key)}return void 0}}}export{contactProblemText,contactProblemTexts,useContactDraft};
|
|
1
|
+
"use client";import{contactProblems}from"@zappie/foundations/checkout";import{useState}from"react";function contactProblemText(problem,field){if(!problem){return void 0}if(!field){return problem==="invalid"?"Check this number":"Add your phone number"}if(problem==="invalid"){return field.type==="email"?"Check this email address":`Check your ${field.label.toLowerCase()}`}return`Add your ${field.label.toLowerCase()}`}function recipientProblemText(key,problem){if(!problem){return void 0}if(key==="recipient_name"){return problem==="invalid"?"Use 100 characters or fewer":"Add their name"}return problem==="invalid"?"Check this number":"Add their phone number"}function contactProblemTexts(fields,problems){const text={};for(const[key,problem]of Object.entries(problems)){const message=key.startsWith("recipient_")?recipientProblemText(key,problem):contactProblemText(problem,key==="phone"?void 0:fields.find(field=>field.key===key));if(message){text[key]=message}}return text}function useContactDraft(contact,focus,dialCode="+234"){const[phone,setPhone]=useState(contact.phone.startsWith(dialCode)?contact.phone.slice(dialCode.length):contact.phone);const[values,setValues]=useState(contact.values);const[tried,setTried]=useState(contact.shown.has(focus));const problems=contactProblems(contact.fields,values,phone,contact.accountPhone,dialCode);if(contact.recipient?.on){delete problems.phone}return{phone,setPhone,values,setValue:(key,value)=>setValues({...values,[key]:value}),problem:key=>tried?contactProblemText(problems[key],key==="phone"?void 0:contact.fields.find(field=>field.key===key)):void 0,save:()=>{const first=Object.keys(problems)[0];if(first){setTried(true);return first}contact.setPhone(phone);for(const field of contact.fields){contact.setField(field.key,values[field.key]??"")}for(const key of["phone",...contact.fields.map(field=>field.key)]){contact.show(key)}return void 0}}}export{contactProblemText,contactProblemTexts,recipientProblemText,useContactDraft};
|
|
2
2
|
//# sourceMappingURL=contact.js.map
|
package/dist/contact.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/contact.ts"],
|
|
4
|
-
"mappings": "aACA,OACE,oBAKK,+BACP,OAAS,aAAgB,QAQlB,SAAS,mBACd,QACA,MACoB,CACpB,GAAI,CAAC,QAAS,CACZ,OAAO,MACT,CACA,GAAI,CAAC,MAAO,CACV,OAAO,UAAY,UACf,oBACA,uBACN,CACA,GAAI,UAAY,UAAW,CACzB,OAAO,MAAM,OAAS,QAClB,2BACA,cAAc,MAAM,MAAM,YAAY,CAAC,EAC7C,CACA,MAA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,QAAQ,WAAW,GAAI,CACzB,OAAO,SAAS,KAClB,CACA,MAAO,CACL,MACA,SACA,OACA,SAAU,CAAC,IAAK,QAAU,UAAU,CAAE,GAAG,OAAQ,CAAC,GAAG,EAAG,KAAM,CAAC,EAC/D,QAAU,KACR,MACI,mBACE,SAAS,GAAG,EACZ,MAAQ,QACJ,OACA,QAAQ,OAAO,KAAM,OAAU,MAAM,MAAQ,GAAG,CACtD,EACA,OACN,KAAM,IAAM,CACV,MAAM,MAAQ,OAAO,KAAK,QAAQ,EAAE,CAAC,EACrC,GAAI,MAAO,CACT,SAAS,IAAI,EACb,OAAO,KACT,CACA,QAAQ,SAAS,KAAK,EACtB,UAAW,SAAS,QAAQ,OAAQ,CAClC,QAAQ,SAAS,MAAM,IAAK,OAAO,MAAM,GAAG,GAAK,EAAE,CACrD,CACA,UAAW,MAAO,CAChB,QACA,GAAG,QAAQ,OAAO,IAAK,OAAU,MAAM,GAAG,CAC5C,EAAG,CACD,QAAQ,KAAK,GAAG,CAClB,CACA,OAAO,MACT,CACF,CACF",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -71,7 +71,16 @@ declare function useAddressSuggestions(search: AddressPickerState["search"], que
|
|
|
71
71
|
*/
|
|
72
72
|
declare function contactProblemText(problem: ContactProblem | undefined, field?: ContactField): string | undefined;
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* What to tell the shopper about the person they order for, by `recipient_name` or
|
|
75
|
+
* `recipient_phone`, or undefined when that detail doesn't stop Pay.
|
|
76
|
+
*
|
|
77
|
+
* @param key - `recipient_name` or `recipient_phone`.
|
|
78
|
+
* @param problem - Its problem, from `flow.contact.problems`.
|
|
79
|
+
*/
|
|
80
|
+
declare function recipientProblemText(key: string, problem: ContactProblem | undefined): string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* `contactProblemText` for every detail that stops Pay, by key, with `phone` for the phone and
|
|
83
|
+
* `recipient_name` and `recipient_phone` for the person the shopper orders for.
|
|
75
84
|
*
|
|
76
85
|
* @param fields - The business's contact fields.
|
|
77
86
|
* @param problems - `flow.contact.problems`.
|
|
@@ -216,5 +225,5 @@ declare function useScheduleStrip<D extends ScheduleDay>(days: readonly D[], onD
|
|
|
216
225
|
*/
|
|
217
226
|
declare function scheduledLabel(at: string, timezone: string, now?: Date): string;
|
|
218
227
|
|
|
219
|
-
export { DeliveryAddressMap, contactProblemText, contactProblemTexts, deliveryAddress, locationError, orderTimeChoice, scheduledLabel, useAddressPicker, useAddressSuggestions, useContactDraft, useEscapeClose, useRegionSearch, useScheduleStrip };
|
|
228
|
+
export { DeliveryAddressMap, contactProblemText, contactProblemTexts, deliveryAddress, locationError, orderTimeChoice, recipientProblemText, scheduledLabel, useAddressPicker, useAddressSuggestions, useContactDraft, useEscapeClose, useRegionSearch, useScheduleStrip };
|
|
220
229
|
export type { AddressPickerState, AddressSuggestion, AddressSuggestionsOptions, ContactDraft, DeliveryAddressMapProps, DeliveryRegion, OrderTimeChoice, ScheduleStrip };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{deliveryAddress,locationError,useAddressPicker,useAddressSuggestions}from"./address.js";import{contactProblemText,contactProblemTexts,useContactDraft}from"./contact.js";import{DeliveryAddressMap}from"./delivery-map.js";import{useEscapeClose}from"./escape.js";import{orderTimeChoice}from"./order-time.js";import{useRegionSearch}from"./region.js";import{scheduledLabel,useScheduleStrip}from"./schedule.js";export{DeliveryAddressMap,contactProblemText,contactProblemTexts,deliveryAddress,locationError,orderTimeChoice,scheduledLabel,useAddressPicker,useAddressSuggestions,useContactDraft,useEscapeClose,useRegionSearch,useScheduleStrip};
|
|
1
|
+
"use client";import{deliveryAddress,locationError,useAddressPicker,useAddressSuggestions}from"./address.js";import{contactProblemText,contactProblemTexts,recipientProblemText,useContactDraft}from"./contact.js";import{DeliveryAddressMap}from"./delivery-map.js";import{useEscapeClose}from"./escape.js";import{orderTimeChoice}from"./order-time.js";import{useRegionSearch}from"./region.js";import{scheduledLabel,useScheduleStrip}from"./schedule.js";export{DeliveryAddressMap,contactProblemText,contactProblemTexts,deliveryAddress,locationError,orderTimeChoice,recipientProblemText,scheduledLabel,useAddressPicker,useAddressSuggestions,useContactDraft,useEscapeClose,useRegionSearch,useScheduleStrip};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"mappings": "aAIA,OACE,gBACA,cACA,iBACA,0BACK,eAMP,OACE,mBACA,oBACA,oBACK,eAEP,OAAS,uBAA0B,oBAEnC,OAAS,mBAAsB,cAC/B,OAAS,oBAAuB,kBAEhC,OAAS,oBAAuB,cAEhC,OAAS,eAAgB,qBAAwB",
|
|
4
|
+
"mappings": "aAIA,OACE,gBACA,cACA,iBACA,0BACK,eAMP,OACE,mBACA,oBACA,qBACA,oBACK,eAEP,OAAS,uBAA0B,oBAEnC,OAAS,mBAAsB,cAC/B,OAAS,oBAAuB,kBAEhC,OAAS,oBAAuB,cAEhC,OAAS,eAAgB,qBAAwB",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/checkout-fields",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "UI-less checkout field behaviour for Zappie storefronts: the address search and its map, the contact draft and the schedule's days.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
],
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": "^18.2.0 || ^19.0.0",
|
|
23
|
-
"@zappie/foundations": "^0.
|
|
24
|
-
"@zappie/sdk": "^0.
|
|
23
|
+
"@zappie/foundations": "^0.26.0",
|
|
24
|
+
"@zappie/sdk": "^0.27.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@zappie/
|
|
28
|
-
"@zappie/
|
|
27
|
+
"@zappie/foundations": "0.26.0",
|
|
28
|
+
"@zappie/sdk": "0.27.0"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|