@zappie/foundations 0.13.0 → 0.14.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 +15 -0
- package/README.md +37 -0
- package/dist/order/index.d.ts +200 -0
- package/dist/order/index.js +576 -0
- package/dist/order/index.js.map +6 -0
- package/dist/order/model.js +84 -0
- package/dist/order/model.js.map +6 -0
- package/dist/order/use-customer-order.js +56 -0
- package/dist/order/use-customer-order.js.map +6 -0
- package/dist/version.js +1 -1
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @zappie/foundations
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d9f3c7d: Order details on storefronts. `CustomerOrder` gains `reference`, the order number such as `#1042` to show instead of the id, and the status type gains `delivery_failed`. Each timeline step has a `step`, `title` and `description`, and `next_step` names the step to come. The order also carries `ready_at`, `delivery_instructions`, `charges`, `discounts`, `payments`, `voided_lines` and `amount_due`. Each line has `voided`, `texts` and its share of each charge, and each choice its `group_name`. `watchOrder` passes every field through. `customer.payBalance(orderId, { useWalletBalance, idempotencyKey })` raises a payment for what is left and returns the payment page's `url`. `customer.reorder(orderId)` rebuilds the order as bag lines at today's prices, and `customer.receiptUrl(orderId)` gives the receipt's address for a download link. New `@zappie/sdk/customer/reorder` entry: `addReorderToCart(zappie, reorder)` puts those lines in the bag and returns the lines it added and every line it left out, with the issues that say why.
|
|
8
|
+
|
|
9
|
+
New `@zappie/foundations/order` entry with the order details parts, without styles: `Order.Root`, `Order.Reference`, `Order.Status`, `Order.Timeline`, `Order.Fulfilment`, `Order.Lines`, `Order.Totals`, `Order.Payments` and `Order.Actions` with `Order.Receipt`, `Order.PayBalance` and `Order.OrderAgain`, plus `OrderDetails`, which puts them in one default layout, `useCustomerOrder` and `orderTotals`.
|
|
10
|
+
|
|
11
|
+
The kit's order status shows the order number and every part of the order details through the foundations parts (order-status 2.0.0, order-page 1.1.0). The orders page names each order by its number (orders-page 1.0.1).
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [d9f3c7d]
|
|
16
|
+
- @zappie/sdk@0.17.0
|
|
17
|
+
|
|
3
18
|
## 0.13.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ Want ready-made, styled components instead? Copy them into your project from the
|
|
|
38
38
|
| `@zappie/foundations/branch-switch` | Choosing a branch in a React Router site without waiting for the server |
|
|
39
39
|
| `@zappie/foundations/checkout` | Checkout behaviour for a bag or a cart page, with no markup |
|
|
40
40
|
| `@zappie/foundations/loyalty` | The rewards sheet's parts, the bag's rewards row and the claim toast |
|
|
41
|
+
| `@zappie/foundations/order` | A customer's order details page, as parts or one default layout |
|
|
41
42
|
| `@zappie/foundations/rich-text` | Sanitising and parsing merchant rich text before you render it |
|
|
42
43
|
|
|
43
44
|
## Docs
|
|
@@ -207,6 +208,42 @@ On the order confirmation, `ClaimToast` (or `useClaimToast`) claims a paid
|
|
|
207
208
|
order's points once and says "You earned N points". Call them inside a
|
|
208
209
|
`ZappieProvider`.
|
|
209
210
|
|
|
211
|
+
## Order details
|
|
212
|
+
|
|
213
|
+
`@zappie/foundations/order` shows a customer's order, with no styles.
|
|
214
|
+
`Order.Root` takes the customer client and the order's id, reads the order and
|
|
215
|
+
follows it live until it ends. Inside it, `Order.Reference` shows the order
|
|
216
|
+
number, such as `#1042`. `Order.Status` is a polite live region with the
|
|
217
|
+
current step. `Order.Timeline` lists each step with its title, description
|
|
218
|
+
and time, then the next step with `data-state="next"`, which you show greyed.
|
|
219
|
+
`Order.Fulfilment` shows delivery or pickup, the address, the delivery note,
|
|
220
|
+
the scheduled and ready times, the contact phone and the branch with a link
|
|
221
|
+
that calls it. `Order.Lines` shows each item with its choices under their
|
|
222
|
+
group names, typed text, its share of each charge and its note. Lines the
|
|
223
|
+
business removed follow, struck through and labelled. `Order.Totals` shows
|
|
224
|
+
the subtotal, each charge, delivery, each discount, the total, what was paid
|
|
225
|
+
and what is due, and `Order.Payments` lists the payments.
|
|
226
|
+
|
|
227
|
+
`Order.Actions` holds `Order.Receipt`, `Order.PayBalance` while something is
|
|
228
|
+
due, which sends the customer to the payment page, and `Order.OrderAgain`,
|
|
229
|
+
which puts the items in the bag and names any it left out. Pass `loyalty`
|
|
230
|
+
where the site has it, to claim a paid order's points. `OrderDetails` puts
|
|
231
|
+
every part in one default layout. Style the parts with your own tokens through
|
|
232
|
+
their `data-state`, `data-kind` and `data-part` attributes. Each part renders
|
|
233
|
+
nothing until the order is read, except `Order.Status`. `useCustomerOrder`
|
|
234
|
+
and `orderTotals` give you the same data for your own markup. Call them
|
|
235
|
+
inside a `ZappieProvider`.
|
|
236
|
+
|
|
237
|
+
```tsx
|
|
238
|
+
import { OrderDetails } from "@zappie/foundations/order";
|
|
239
|
+
|
|
240
|
+
<OrderDetails
|
|
241
|
+
customer={customer}
|
|
242
|
+
orderId={orderId}
|
|
243
|
+
onReorder={() => navigate("/bag")}
|
|
244
|
+
/>;
|
|
245
|
+
```
|
|
246
|
+
|
|
210
247
|
## Branch switch
|
|
211
248
|
|
|
212
249
|
Choosing a branch shows that branch's menu without waiting for the server. A
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { P as PartOwnedAttributes } from '../slot-CHfqzPTd.js';
|
|
2
|
+
import { PartProps } from '../index.js';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { Money, Branch } from '@zappie/sdk';
|
|
6
|
+
import { CustomerOrder, Money as Money$1, CustomerClient, OrderTimelineStep, OrderLine, OrderPayment } from '@zappie/sdk/customer';
|
|
7
|
+
import { ReorderResult } from '@zappie/sdk/customer/reorder';
|
|
8
|
+
|
|
9
|
+
/** An order amount as SDK money, ready for `format.money` or `Money`. */
|
|
10
|
+
declare const orderMoney: (value: Money$1) => Money;
|
|
11
|
+
/** One row of an order's totals. */
|
|
12
|
+
type OrderTotalRow = {
|
|
13
|
+
kind: "subtotal" | "charge" | "delivery" | "discount" | "total" | "paid" | "due";
|
|
14
|
+
label: string;
|
|
15
|
+
/** Negative for a discount. Zero for a waived charge. */
|
|
16
|
+
amount: Money;
|
|
17
|
+
/** `included` when the prices already hold the charge, `waived` when the business waived it. */
|
|
18
|
+
note?: "included" | "waived";
|
|
19
|
+
/** The promo code the customer entered, on a discount that came with one. */
|
|
20
|
+
promoCode?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* An order's totals as rows: the subtotal, each charge, delivery, each discount, the total, then
|
|
24
|
+
* what was paid and what is still due. Included and waived charges add nothing, so the rows above
|
|
25
|
+
* the total add up to it. Voided lines are in no row.
|
|
26
|
+
*
|
|
27
|
+
* @param order - The order.
|
|
28
|
+
* @returns The rows, in the order to show them.
|
|
29
|
+
*/
|
|
30
|
+
declare function orderTotals(order: CustomerOrder): OrderTotalRow[];
|
|
31
|
+
/** Whether the order has ended: completed, cancelled or rejected. */
|
|
32
|
+
declare const orderEnded: (order: CustomerOrder) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The order's current step, as a title and a description to show. The last timeline step, or the
|
|
35
|
+
* status in words when the timeline is empty.
|
|
36
|
+
*/
|
|
37
|
+
declare function currentStep(order: CustomerOrder): {
|
|
38
|
+
title: string;
|
|
39
|
+
description: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A time on the order in words, such as "25 Nov, 14:05", in the branch's time zone so the server
|
|
43
|
+
* and the browser render the same text.
|
|
44
|
+
*/
|
|
45
|
+
declare function orderTime(iso: string, timeZone?: string): string;
|
|
46
|
+
|
|
47
|
+
/** Where reading an order stands. */
|
|
48
|
+
type CustomerOrderStatus = "loading" | "ready" | "not_found" | "error";
|
|
49
|
+
/** An order as `useCustomerOrder` reads and follows it. */
|
|
50
|
+
type CustomerOrderState = {
|
|
51
|
+
order: CustomerOrder | undefined;
|
|
52
|
+
status: CustomerOrderStatus;
|
|
53
|
+
/** The last read's failure, while `status` is `not_found` or `error`. */
|
|
54
|
+
error: unknown;
|
|
55
|
+
/** Read the order again after a failure. */
|
|
56
|
+
retry(): void;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Read a customer's order and follow it live until it ends. Each change replaces `order`, so the
|
|
60
|
+
* page updates in place. A 404 is `not_found`: the order is someone else's or doesn't exist.
|
|
61
|
+
*
|
|
62
|
+
* @param customer - The customer client.
|
|
63
|
+
* @param orderId - The order's id.
|
|
64
|
+
* @param options - An order the server already read, shown until the first read lands.
|
|
65
|
+
* @returns The order, where reading it stands, and `retry`.
|
|
66
|
+
*/
|
|
67
|
+
declare function useCustomerOrder(customer: CustomerClient, orderId: string, options?: {
|
|
68
|
+
initialOrder?: CustomerOrder;
|
|
69
|
+
}): CustomerOrderState;
|
|
70
|
+
|
|
71
|
+
/** What every order part reads from `Order.Root`. */
|
|
72
|
+
type OrderContext = CustomerOrderState & {
|
|
73
|
+
customer: CustomerClient;
|
|
74
|
+
/** The order's branch from the store, for its name, phone and time zone. */
|
|
75
|
+
branch: Branch | undefined;
|
|
76
|
+
/** The time zone the order's times show in: the branch's, else the store's. */
|
|
77
|
+
timeZone: string | undefined;
|
|
78
|
+
};
|
|
79
|
+
/** The order `Order.Root` shows, while it has one. Throws outside `Order.Root`. */
|
|
80
|
+
declare function useOrder(): CustomerOrder | undefined;
|
|
81
|
+
declare function Root({ customer, orderId, initialOrder, ...props }: PartProps<OrderContext> & {
|
|
82
|
+
customer: CustomerClient;
|
|
83
|
+
orderId: string;
|
|
84
|
+
/** An order the server already read, shown until the first read lands. */
|
|
85
|
+
initialOrder?: CustomerOrder;
|
|
86
|
+
}): react.JSX.Element;
|
|
87
|
+
/** The state `Order.Status` passes to a render function. */
|
|
88
|
+
type OrderStatusState = {
|
|
89
|
+
status: CustomerOrder["status"] | "loading" | "not_found" | "error";
|
|
90
|
+
title: string;
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
/** The state `Order.Timeline` passes to a render function. */
|
|
94
|
+
type OrderTimelineState = {
|
|
95
|
+
steps: OrderTimelineStep[];
|
|
96
|
+
next: CustomerOrder["next_step"];
|
|
97
|
+
};
|
|
98
|
+
/** One fact about how the order reaches the customer. */
|
|
99
|
+
type OrderFulfilmentRow = {
|
|
100
|
+
kind: "type" | "address" | "note" | "scheduled" | "ready" | "eta" | "contact" | "branch";
|
|
101
|
+
label: string;
|
|
102
|
+
value: string;
|
|
103
|
+
};
|
|
104
|
+
/** What an order action's render function gets. */
|
|
105
|
+
type OrderActionState = {
|
|
106
|
+
busy: boolean;
|
|
107
|
+
/** The last failure, in the API's words. */
|
|
108
|
+
error: string | undefined;
|
|
109
|
+
};
|
|
110
|
+
/** What an Order again result says: what went in, and which items didn't. */
|
|
111
|
+
declare function reorderNotice(result: ReorderResult): string;
|
|
112
|
+
/**
|
|
113
|
+
* A customer's order, without styles. `Order.Root` reads it and follows it live, and the parts show
|
|
114
|
+
* it: the number, the status, the timeline, how it reaches the customer, the items, the totals, the
|
|
115
|
+
* payments and the actions. Style each part with your own tokens through its `data-*` attributes.
|
|
116
|
+
* Each part renders nothing until the order is read, except `Status`, which says it is loading.
|
|
117
|
+
*/
|
|
118
|
+
declare const Order: {
|
|
119
|
+
Root: typeof Root;
|
|
120
|
+
Reference: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
121
|
+
asChild?: boolean;
|
|
122
|
+
children?: ReactNode | ((state: {
|
|
123
|
+
reference: string;
|
|
124
|
+
}) => ReactNode);
|
|
125
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
126
|
+
Status: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
127
|
+
asChild?: boolean;
|
|
128
|
+
children?: ReactNode | ((state: OrderStatusState) => ReactNode);
|
|
129
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
130
|
+
Timeline: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
131
|
+
asChild?: boolean;
|
|
132
|
+
children?: ReactNode | ((state: OrderTimelineState) => ReactNode);
|
|
133
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
134
|
+
Fulfilment: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
135
|
+
asChild?: boolean;
|
|
136
|
+
children?: ReactNode | ((state: {
|
|
137
|
+
rows: OrderFulfilmentRow[];
|
|
138
|
+
branch: Branch | undefined;
|
|
139
|
+
}) => ReactNode);
|
|
140
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
141
|
+
Lines: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
142
|
+
asChild?: boolean;
|
|
143
|
+
children?: ReactNode | ((state: {
|
|
144
|
+
lines: OrderLine[];
|
|
145
|
+
voided: OrderLine[];
|
|
146
|
+
}) => ReactNode);
|
|
147
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
148
|
+
Totals: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
149
|
+
asChild?: boolean;
|
|
150
|
+
children?: ReactNode | ((state: {
|
|
151
|
+
rows: OrderTotalRow[];
|
|
152
|
+
}) => ReactNode);
|
|
153
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
154
|
+
Payments: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
155
|
+
asChild?: boolean;
|
|
156
|
+
children?: ReactNode | ((state: {
|
|
157
|
+
payments: OrderPayment[];
|
|
158
|
+
}) => ReactNode);
|
|
159
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
160
|
+
Actions: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
161
|
+
asChild?: boolean;
|
|
162
|
+
children?: ReactNode | ((state: Record<string, never>) => ReactNode);
|
|
163
|
+
} & {
|
|
164
|
+
/** Claim the order's loyalty points once it is paid. Pass it where the site has loyalty. */
|
|
165
|
+
loyalty?: boolean;
|
|
166
|
+
onReorder?: (result: ReorderResult) => void;
|
|
167
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
168
|
+
Receipt: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
169
|
+
asChild?: boolean;
|
|
170
|
+
children?: ReactNode | ((state: {
|
|
171
|
+
shared: boolean;
|
|
172
|
+
}) => ReactNode);
|
|
173
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
174
|
+
PayBalance: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
175
|
+
asChild?: boolean;
|
|
176
|
+
children?: ReactNode | ((state: OrderActionState) => ReactNode);
|
|
177
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
178
|
+
OrderAgain: react.ForwardRefExoticComponent<Omit<react.AllHTMLAttributes<HTMLElement>, PartOwnedAttributes> & {
|
|
179
|
+
asChild?: boolean;
|
|
180
|
+
children?: ReactNode | ((state: OrderActionState & {
|
|
181
|
+
result: ReorderResult | undefined;
|
|
182
|
+
}) => ReactNode);
|
|
183
|
+
} & {
|
|
184
|
+
onReorder?: (result: ReorderResult) => void;
|
|
185
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Every order part in one default layout: the number and status, the timeline, the fulfilment, the
|
|
189
|
+
* items, the totals, the payments and the actions. Pass `loyalty` where the site has it.
|
|
190
|
+
*/
|
|
191
|
+
declare function OrderDetails({ customer, orderId, initialOrder, loyalty, onReorder, ...props }: PartProps<OrderContext> & {
|
|
192
|
+
customer: CustomerClient;
|
|
193
|
+
orderId: string;
|
|
194
|
+
initialOrder?: CustomerOrder;
|
|
195
|
+
loyalty?: boolean;
|
|
196
|
+
onReorder?: (result: ReorderResult) => void;
|
|
197
|
+
}): react.JSX.Element;
|
|
198
|
+
|
|
199
|
+
export { Order, OrderDetails, currentStep, orderEnded, orderMoney, orderTime, orderTotals, reorderNotice, useCustomerOrder, useOrder };
|
|
200
|
+
export type { CustomerOrderState, CustomerOrderStatus, OrderActionState, OrderContext, OrderFulfilmentRow, OrderStatusState, OrderTimelineState, OrderTotalRow };
|
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/order/index.tsx
|
|
4
|
+
import { format } from "@zappie/sdk";
|
|
5
|
+
import {
|
|
6
|
+
addReorderToCart
|
|
7
|
+
} from "@zappie/sdk/customer/reorder";
|
|
8
|
+
import { useStore, useZappie } from "@zappie/sdk/react";
|
|
9
|
+
import { canShareReceipt } from "@zappie/sdk/receipts";
|
|
10
|
+
import { redirectToCheckout } from "@zappie/sdk/redirect";
|
|
11
|
+
import {
|
|
12
|
+
createContext,
|
|
13
|
+
forwardRef,
|
|
14
|
+
useContext,
|
|
15
|
+
useRef,
|
|
16
|
+
useState
|
|
17
|
+
} from "react";
|
|
18
|
+
import { part } from "../internal/slot.js";
|
|
19
|
+
import { ClaimToast } from "../loyalty/index.js";
|
|
20
|
+
import {
|
|
21
|
+
currentStep,
|
|
22
|
+
orderMoney,
|
|
23
|
+
orderTime,
|
|
24
|
+
orderTotals
|
|
25
|
+
} from "./model.js";
|
|
26
|
+
import {
|
|
27
|
+
useCustomerOrder
|
|
28
|
+
} from "./use-customer-order.js";
|
|
29
|
+
import {
|
|
30
|
+
currentStep as currentStep2,
|
|
31
|
+
orderEnded,
|
|
32
|
+
orderMoney as orderMoney2,
|
|
33
|
+
orderTime as orderTime2,
|
|
34
|
+
orderTotals as orderTotals2
|
|
35
|
+
} from "./model.js";
|
|
36
|
+
import { useCustomerOrder as useCustomerOrder2 } from "./use-customer-order.js";
|
|
37
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
38
|
+
var Context = /* @__PURE__ */ createContext(null);
|
|
39
|
+
function useOrderContext() {
|
|
40
|
+
const value = useContext(Context);
|
|
41
|
+
if (!value) {
|
|
42
|
+
throw new Error("Order parts require Order.Root");
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
function useOrder() {
|
|
47
|
+
return useOrderContext().order;
|
|
48
|
+
}
|
|
49
|
+
var money = (value) => format.money(orderMoney(value));
|
|
50
|
+
function Root({
|
|
51
|
+
customer,
|
|
52
|
+
orderId,
|
|
53
|
+
initialOrder,
|
|
54
|
+
...props
|
|
55
|
+
}) {
|
|
56
|
+
const state = useCustomerOrder(
|
|
57
|
+
customer,
|
|
58
|
+
orderId,
|
|
59
|
+
initialOrder ? { initialOrder } : {}
|
|
60
|
+
);
|
|
61
|
+
const store = useStore().data;
|
|
62
|
+
const branch = store?.branches.find((b) => b.id === state.order?.branch_id);
|
|
63
|
+
const value = {
|
|
64
|
+
...state,
|
|
65
|
+
customer,
|
|
66
|
+
branch,
|
|
67
|
+
timeZone: branch?.timezone ?? store?.timezone
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value, children: part("div", props, value, {
|
|
70
|
+
"data-state": state.status,
|
|
71
|
+
"aria-busy": state.status === "loading" || void 0
|
|
72
|
+
}) });
|
|
73
|
+
}
|
|
74
|
+
function withOrder(name, render) {
|
|
75
|
+
const Part = forwardRef((props, ref) => {
|
|
76
|
+
const context = useOrderContext();
|
|
77
|
+
return context.order ? render(context.order, context, props, ref) : null;
|
|
78
|
+
});
|
|
79
|
+
Part.displayName = `Order.${name}`;
|
|
80
|
+
return Part;
|
|
81
|
+
}
|
|
82
|
+
var Reference = /* @__PURE__ */ withOrder(
|
|
83
|
+
"Reference",
|
|
84
|
+
(order, _, props, ref) => part(
|
|
85
|
+
"span",
|
|
86
|
+
{ ...props, children: props.children ?? order.reference },
|
|
87
|
+
{ reference: order.reference },
|
|
88
|
+
{},
|
|
89
|
+
ref
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
var Status = /* @__PURE__ */ forwardRef(function Status2(props, ref) {
|
|
93
|
+
const { order, status } = useOrderContext();
|
|
94
|
+
const state = order ? { status: order.status, ...currentStep(order) } : {
|
|
95
|
+
status,
|
|
96
|
+
title: status === "not_found" ? "We couldn't find this order." : status === "error" ? "We couldn't load this order. Try again." : "Loading your order",
|
|
97
|
+
description: ""
|
|
98
|
+
};
|
|
99
|
+
return part(
|
|
100
|
+
"p",
|
|
101
|
+
{ ...props, children: props.children ?? state.title },
|
|
102
|
+
state,
|
|
103
|
+
{ role: "status", "aria-live": "polite", "data-status": state.status },
|
|
104
|
+
ref
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
var Timeline = /* @__PURE__ */ withOrder(
|
|
108
|
+
"Timeline",
|
|
109
|
+
(order, { timeZone }, props, ref) => {
|
|
110
|
+
const steps = order.timeline;
|
|
111
|
+
const next = order.next_step;
|
|
112
|
+
return part(
|
|
113
|
+
"ol",
|
|
114
|
+
{
|
|
115
|
+
...props,
|
|
116
|
+
children: props.children ?? [
|
|
117
|
+
...steps.map((step, index) => {
|
|
118
|
+
const current = index === steps.length - 1;
|
|
119
|
+
return /* @__PURE__ */ jsxs(
|
|
120
|
+
"li",
|
|
121
|
+
{
|
|
122
|
+
"data-state": current ? "current" : "done",
|
|
123
|
+
"data-step": step.step,
|
|
124
|
+
"aria-current": current ? "step" : void 0,
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ jsx("span", { "data-part": "title", children: step.title }),
|
|
127
|
+
" ",
|
|
128
|
+
/* @__PURE__ */ jsx("time", { dateTime: step.at, children: orderTime(step.at, timeZone) }),
|
|
129
|
+
step.description ? /* @__PURE__ */ jsx("span", { "data-part": "description", children: step.description }) : null
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
`${step.step}:${step.at}:${index}`
|
|
133
|
+
);
|
|
134
|
+
}),
|
|
135
|
+
next ? /* @__PURE__ */ jsxs("li", { "data-state": "next", "data-step": next.step, children: [
|
|
136
|
+
/* @__PURE__ */ jsx("span", { "data-part": "title", children: next.title }),
|
|
137
|
+
" ",
|
|
138
|
+
/* @__PURE__ */ jsx("span", { "data-part": "label", children: "Next" }),
|
|
139
|
+
next.description ? /* @__PURE__ */ jsx("span", { "data-part": "description", children: next.description }) : null
|
|
140
|
+
] }, "next") : null
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{ steps, next },
|
|
144
|
+
{ "aria-label": "Order progress" },
|
|
145
|
+
ref
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
var Fulfilment = /* @__PURE__ */ withOrder("Fulfilment", (order, { branch, timeZone }, props, ref) => {
|
|
150
|
+
const delivery = order.fulfilment === "delivery";
|
|
151
|
+
const facts = [
|
|
152
|
+
["type", "Fulfilment", delivery ? "Delivery" : "Pickup"],
|
|
153
|
+
[
|
|
154
|
+
"address",
|
|
155
|
+
delivery ? "Deliver to" : "Pick up from",
|
|
156
|
+
delivery ? order.dropoff_address?.line1 : branch?.address
|
|
157
|
+
],
|
|
158
|
+
["note", "Delivery note", order.delivery_instructions],
|
|
159
|
+
[
|
|
160
|
+
"scheduled",
|
|
161
|
+
"Scheduled for",
|
|
162
|
+
order.scheduled_at && orderTime(order.scheduled_at, timeZone)
|
|
163
|
+
],
|
|
164
|
+
[
|
|
165
|
+
"ready",
|
|
166
|
+
"Ready by",
|
|
167
|
+
order.ready_at && orderTime(order.ready_at, timeZone)
|
|
168
|
+
],
|
|
169
|
+
[
|
|
170
|
+
"eta",
|
|
171
|
+
delivery ? "Arrives in" : "Ready in",
|
|
172
|
+
order.eta_minutes === void 0 ? void 0 : `About ${order.eta_minutes} min`
|
|
173
|
+
],
|
|
174
|
+
["contact", "Contact phone", order.contact_phone],
|
|
175
|
+
["branch", "Branch", branch?.name]
|
|
176
|
+
];
|
|
177
|
+
const rows = facts.flatMap(
|
|
178
|
+
([kind, label, value]) => value ? [{ kind, label, value }] : []
|
|
179
|
+
);
|
|
180
|
+
return part(
|
|
181
|
+
"dl",
|
|
182
|
+
{
|
|
183
|
+
...props,
|
|
184
|
+
children: props.children ?? rows.map((row) => /* @__PURE__ */ jsxs("div", { "data-kind": row.kind, children: [
|
|
185
|
+
/* @__PURE__ */ jsx("dt", { children: row.label }),
|
|
186
|
+
/* @__PURE__ */ jsxs("dd", { children: [
|
|
187
|
+
row.value,
|
|
188
|
+
row.kind === "branch" && branch?.phone ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
189
|
+
" ",
|
|
190
|
+
/* @__PURE__ */ jsxs("a", { href: `tel:${branch.phone.replace(/[^\d+]/g, "")}`, children: [
|
|
191
|
+
"Call ",
|
|
192
|
+
branch.name
|
|
193
|
+
] })
|
|
194
|
+
] }) : null
|
|
195
|
+
] })
|
|
196
|
+
] }, row.kind))
|
|
197
|
+
},
|
|
198
|
+
{ rows, branch },
|
|
199
|
+
{},
|
|
200
|
+
ref
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
function LineDetail({ line }) {
|
|
204
|
+
const groups = /* @__PURE__ */ new Map();
|
|
205
|
+
for (const choice of line.choices) {
|
|
206
|
+
const name = (choice.quantity > 1 ? `${choice.quantity} \xD7 ` : "") + choice.name + (choice.price.amount_minor > 0 ? ` (+${money(choice.price)})` : "");
|
|
207
|
+
groups.set(choice.group_name, [
|
|
208
|
+
...groups.get(choice.group_name) ?? [],
|
|
209
|
+
name
|
|
210
|
+
]);
|
|
211
|
+
}
|
|
212
|
+
const details = [
|
|
213
|
+
...[...groups].map(([group, names]) => [
|
|
214
|
+
"choice",
|
|
215
|
+
group,
|
|
216
|
+
names.join(", ")
|
|
217
|
+
]),
|
|
218
|
+
...line.texts.map((text) => [
|
|
219
|
+
"text",
|
|
220
|
+
text.group_name,
|
|
221
|
+
text.value
|
|
222
|
+
]),
|
|
223
|
+
...line.charges.map((charge) => [
|
|
224
|
+
"charge",
|
|
225
|
+
charge.label,
|
|
226
|
+
`${money(charge.amount)}${charge.included ? " included" : ""}`
|
|
227
|
+
])
|
|
228
|
+
];
|
|
229
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
230
|
+
details.length ? /* @__PURE__ */ jsx("dl", { "data-part": "details", children: details.map(([kind, label, value], index) => /* @__PURE__ */ jsxs("div", { "data-kind": kind, children: [
|
|
231
|
+
/* @__PURE__ */ jsx("dt", { children: label }),
|
|
232
|
+
/* @__PURE__ */ jsx("dd", { children: value })
|
|
233
|
+
] }, `${kind}:${label}:${index}`)) }) : null,
|
|
234
|
+
line.notes ? /* @__PURE__ */ jsxs("p", { "data-part": "note", children: [
|
|
235
|
+
"Note: ",
|
|
236
|
+
line.notes
|
|
237
|
+
] }) : null
|
|
238
|
+
] });
|
|
239
|
+
}
|
|
240
|
+
var Lines = /* @__PURE__ */ withOrder("Lines", (order, _, props, ref) => {
|
|
241
|
+
const voided = order.voided_lines;
|
|
242
|
+
const row = (line, index, removed) => {
|
|
243
|
+
const head = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
244
|
+
/* @__PURE__ */ jsxs("span", { "data-part": "quantity", children: [
|
|
245
|
+
line.quantity,
|
|
246
|
+
" \xD7"
|
|
247
|
+
] }),
|
|
248
|
+
" ",
|
|
249
|
+
/* @__PURE__ */ jsx("span", { "data-part": "name", children: line.name }),
|
|
250
|
+
" ",
|
|
251
|
+
/* @__PURE__ */ jsx("data", { "data-part": "total", value: String(line.total.amount_minor), children: money(line.total) })
|
|
252
|
+
] });
|
|
253
|
+
return /* @__PURE__ */ jsxs(
|
|
254
|
+
"li",
|
|
255
|
+
{
|
|
256
|
+
"data-state": removed ? "voided" : void 0,
|
|
257
|
+
children: [
|
|
258
|
+
removed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
259
|
+
/* @__PURE__ */ jsx("s", { children: head }),
|
|
260
|
+
" ",
|
|
261
|
+
/* @__PURE__ */ jsx("span", { "data-part": "label", children: "Removed" })
|
|
262
|
+
] }) : head,
|
|
263
|
+
/* @__PURE__ */ jsx(LineDetail, { line })
|
|
264
|
+
]
|
|
265
|
+
},
|
|
266
|
+
`${removed ? "v" : "l"}:${line.item_id}:${index}`
|
|
267
|
+
);
|
|
268
|
+
};
|
|
269
|
+
return part(
|
|
270
|
+
"ul",
|
|
271
|
+
{
|
|
272
|
+
...props,
|
|
273
|
+
children: props.children ?? [
|
|
274
|
+
...order.lines.map((line, index) => row(line, index, false)),
|
|
275
|
+
...voided.map((line, index) => row(line, index, true))
|
|
276
|
+
]
|
|
277
|
+
},
|
|
278
|
+
{ lines: order.lines, voided },
|
|
279
|
+
{ "aria-label": "Items" },
|
|
280
|
+
ref
|
|
281
|
+
);
|
|
282
|
+
});
|
|
283
|
+
var Totals = /* @__PURE__ */ withOrder(
|
|
284
|
+
"Totals",
|
|
285
|
+
(order, _, props, ref) => {
|
|
286
|
+
const rows = orderTotals(order);
|
|
287
|
+
return part(
|
|
288
|
+
"dl",
|
|
289
|
+
{
|
|
290
|
+
...props,
|
|
291
|
+
children: props.children ?? rows.map((row, index) => /* @__PURE__ */ jsxs(
|
|
292
|
+
"div",
|
|
293
|
+
{
|
|
294
|
+
"data-kind": row.kind,
|
|
295
|
+
"data-note": row.note,
|
|
296
|
+
children: [
|
|
297
|
+
/* @__PURE__ */ jsxs("dt", { children: [
|
|
298
|
+
row.label,
|
|
299
|
+
row.promoCode ? ` (${row.promoCode})` : "",
|
|
300
|
+
row.note === "included" ? " (included)" : ""
|
|
301
|
+
] }),
|
|
302
|
+
/* @__PURE__ */ jsx("dd", { children: row.note === "waived" ? "Waived" : /* @__PURE__ */ jsx("data", { value: String(row.amount.amountMinor), children: format.money(row.amount) }) })
|
|
303
|
+
]
|
|
304
|
+
},
|
|
305
|
+
`${row.kind}:${index}`
|
|
306
|
+
))
|
|
307
|
+
},
|
|
308
|
+
{ rows },
|
|
309
|
+
{},
|
|
310
|
+
ref
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
var Payments = /* @__PURE__ */ withOrder(
|
|
315
|
+
"Payments",
|
|
316
|
+
(order, { timeZone }, props, ref) => order.payments.length ? part(
|
|
317
|
+
"ul",
|
|
318
|
+
{
|
|
319
|
+
...props,
|
|
320
|
+
children: props.children ?? order.payments.map((payment, index) => /* @__PURE__ */ jsxs(
|
|
321
|
+
"li",
|
|
322
|
+
{
|
|
323
|
+
"data-state": payment.status,
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsx("span", { "data-part": "method", children: payment.method }),
|
|
326
|
+
" ",
|
|
327
|
+
/* @__PURE__ */ jsx("data", { value: String(payment.amount.amount_minor), children: money(payment.amount) }),
|
|
328
|
+
" ",
|
|
329
|
+
/* @__PURE__ */ jsx("time", { dateTime: payment.paid_at, children: orderTime(payment.paid_at, timeZone) }),
|
|
330
|
+
payment.status === "refunded" ? /* @__PURE__ */ jsx("span", { "data-part": "label", children: " Refunded" }) : null
|
|
331
|
+
]
|
|
332
|
+
},
|
|
333
|
+
`${payment.paid_at}:${index}`
|
|
334
|
+
))
|
|
335
|
+
},
|
|
336
|
+
{ payments: order.payments },
|
|
337
|
+
{ "aria-label": "Payments" },
|
|
338
|
+
ref
|
|
339
|
+
) : null
|
|
340
|
+
);
|
|
341
|
+
var message = (error, fallback) => error instanceof Error && error.message ? error.message : fallback;
|
|
342
|
+
function useAction() {
|
|
343
|
+
const [busy, setBusy] = useState(false);
|
|
344
|
+
const [error, setError] = useState();
|
|
345
|
+
const running = useRef(false);
|
|
346
|
+
const run = async (action, fallback) => {
|
|
347
|
+
if (running.current) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
running.current = true;
|
|
351
|
+
setBusy(true);
|
|
352
|
+
setError(void 0);
|
|
353
|
+
try {
|
|
354
|
+
await action();
|
|
355
|
+
} catch (failure) {
|
|
356
|
+
setError(message(failure, fallback));
|
|
357
|
+
} finally {
|
|
358
|
+
running.current = false;
|
|
359
|
+
setBusy(false);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
return { busy, error, run };
|
|
363
|
+
}
|
|
364
|
+
function actionButton(props, ref, state, label, onClick, extra = {}) {
|
|
365
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
366
|
+
part(
|
|
367
|
+
"button",
|
|
368
|
+
{ ...props, children: props.children ?? label },
|
|
369
|
+
state,
|
|
370
|
+
{
|
|
371
|
+
type: "button",
|
|
372
|
+
"aria-busy": state.busy || void 0,
|
|
373
|
+
"aria-disabled": state.busy || void 0,
|
|
374
|
+
"data-state": state.busy ? "busy" : "idle",
|
|
375
|
+
onClick: () => {
|
|
376
|
+
if (!state.busy) {
|
|
377
|
+
onClick();
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
...extra
|
|
381
|
+
},
|
|
382
|
+
ref
|
|
383
|
+
),
|
|
384
|
+
state.error ? /* @__PURE__ */ jsx("span", { role: "alert", children: state.error }) : null
|
|
385
|
+
] });
|
|
386
|
+
}
|
|
387
|
+
var Receipt = /* @__PURE__ */ forwardRef(function Receipt2(props, ref) {
|
|
388
|
+
const { order, customer } = useOrderContext();
|
|
389
|
+
const [file, setFile] = useState();
|
|
390
|
+
if (!order) {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
const share = (event) => {
|
|
394
|
+
if (!canShareReceipt()) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
event.preventDefault();
|
|
398
|
+
(file ? Promise.resolve(file) : customer.receipt(order.id)).then((value) => {
|
|
399
|
+
setFile(value);
|
|
400
|
+
return navigator.share({ files: [value] });
|
|
401
|
+
}).catch(() => void 0);
|
|
402
|
+
};
|
|
403
|
+
return part(
|
|
404
|
+
"a",
|
|
405
|
+
{
|
|
406
|
+
...props,
|
|
407
|
+
children: props.children ?? (file ? "Share receipt" : "Download receipt")
|
|
408
|
+
},
|
|
409
|
+
{ shared: Boolean(file) },
|
|
410
|
+
{
|
|
411
|
+
href: customer.receiptUrl(order.id),
|
|
412
|
+
download: "",
|
|
413
|
+
onClick: share
|
|
414
|
+
},
|
|
415
|
+
ref
|
|
416
|
+
);
|
|
417
|
+
});
|
|
418
|
+
var PayBalance = /* @__PURE__ */ withOrder(
|
|
419
|
+
"PayBalance",
|
|
420
|
+
(order, { customer }, props, ref) => order.amount_due.amount_minor > 0 ? /* @__PURE__ */ jsx(
|
|
421
|
+
PayButton,
|
|
422
|
+
{
|
|
423
|
+
order,
|
|
424
|
+
customer,
|
|
425
|
+
props,
|
|
426
|
+
forward: ref
|
|
427
|
+
}
|
|
428
|
+
) : null
|
|
429
|
+
);
|
|
430
|
+
function PayButton({
|
|
431
|
+
order,
|
|
432
|
+
customer,
|
|
433
|
+
props,
|
|
434
|
+
forward
|
|
435
|
+
}) {
|
|
436
|
+
const action = useAction();
|
|
437
|
+
const keys = useRef(/* @__PURE__ */ new Map());
|
|
438
|
+
const due = `${order.id}:${order.amount_due.amount_minor}`;
|
|
439
|
+
return actionButton(
|
|
440
|
+
props,
|
|
441
|
+
forward,
|
|
442
|
+
action,
|
|
443
|
+
`Pay ${money(order.amount_due)}`,
|
|
444
|
+
() => void action.run(async () => {
|
|
445
|
+
if (!keys.current.has(due)) {
|
|
446
|
+
keys.current.set(due, crypto.randomUUID());
|
|
447
|
+
}
|
|
448
|
+
const payment = await customer.payBalance(order.id, {
|
|
449
|
+
idempotencyKey: keys.current.get(due)
|
|
450
|
+
});
|
|
451
|
+
redirectToCheckout(payment.url);
|
|
452
|
+
}, "We couldn't start the payment. Try again.")
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
var OrderAgain = /* @__PURE__ */ forwardRef(function OrderAgain2({ onReorder, ...props }, ref) {
|
|
456
|
+
const { order, customer } = useOrderContext();
|
|
457
|
+
const zappie = useZappie();
|
|
458
|
+
const action = useAction();
|
|
459
|
+
const [result, setResult] = useState();
|
|
460
|
+
if (!order) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
const notice = result ? reorderNotice(result) : "";
|
|
464
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
465
|
+
actionButton(
|
|
466
|
+
props,
|
|
467
|
+
ref,
|
|
468
|
+
{ ...action, result },
|
|
469
|
+
"Order again",
|
|
470
|
+
() => void action.run(async () => {
|
|
471
|
+
const next = await addReorderToCart(
|
|
472
|
+
zappie,
|
|
473
|
+
await customer.reorder(order.id)
|
|
474
|
+
);
|
|
475
|
+
setResult(next);
|
|
476
|
+
onReorder?.(next);
|
|
477
|
+
}, "We couldn't add these items to your bag. Try again.")
|
|
478
|
+
),
|
|
479
|
+
/* @__PURE__ */ jsx("span", { role: "status", "data-part": "notice", children: notice })
|
|
480
|
+
] });
|
|
481
|
+
});
|
|
482
|
+
function reorderNotice(result) {
|
|
483
|
+
const count = result.added.reduce((n, line) => n + line.quantity, 0);
|
|
484
|
+
const added = count ? `Added ${count} ${count === 1 ? "item" : "items"} to your bag.` : "None of these items can be ordered right now.";
|
|
485
|
+
const names = result.dropped.map((line) => line.name);
|
|
486
|
+
return names.length && count ? `${added} ${listNames(names)} ${names.length === 1 ? "isn't" : "aren't"} available any more.` : added;
|
|
487
|
+
}
|
|
488
|
+
function listNames(names) {
|
|
489
|
+
return names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0];
|
|
490
|
+
}
|
|
491
|
+
var Actions = /* @__PURE__ */ forwardRef(function Actions2({ loyalty, onReorder, ...props }, ref) {
|
|
492
|
+
const { order } = useOrderContext();
|
|
493
|
+
return order ? part(
|
|
494
|
+
"div",
|
|
495
|
+
{
|
|
496
|
+
...props,
|
|
497
|
+
children: props.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
498
|
+
/* @__PURE__ */ jsx(PayBalance, {}),
|
|
499
|
+
/* @__PURE__ */ jsx(Receipt, {}),
|
|
500
|
+
/* @__PURE__ */ jsx(OrderAgain, { ...onReorder ? { onReorder } : {} }),
|
|
501
|
+
loyalty ? /* @__PURE__ */ jsx(ClaimToast, { orderId: order.id, paid: order.paid }) : null
|
|
502
|
+
] })
|
|
503
|
+
},
|
|
504
|
+
{},
|
|
505
|
+
{ role: "group", "aria-label": "Order actions" },
|
|
506
|
+
ref
|
|
507
|
+
) : null;
|
|
508
|
+
});
|
|
509
|
+
var Order = {
|
|
510
|
+
Root,
|
|
511
|
+
Reference,
|
|
512
|
+
Status,
|
|
513
|
+
Timeline,
|
|
514
|
+
Fulfilment,
|
|
515
|
+
Lines,
|
|
516
|
+
Totals,
|
|
517
|
+
Payments,
|
|
518
|
+
Actions,
|
|
519
|
+
Receipt,
|
|
520
|
+
PayBalance,
|
|
521
|
+
OrderAgain
|
|
522
|
+
};
|
|
523
|
+
function OrderDetails({
|
|
524
|
+
customer,
|
|
525
|
+
orderId,
|
|
526
|
+
initialOrder,
|
|
527
|
+
loyalty,
|
|
528
|
+
onReorder,
|
|
529
|
+
...props
|
|
530
|
+
}) {
|
|
531
|
+
return /* @__PURE__ */ jsx(
|
|
532
|
+
Root,
|
|
533
|
+
{
|
|
534
|
+
customer,
|
|
535
|
+
orderId,
|
|
536
|
+
...initialOrder ? { initialOrder } : {},
|
|
537
|
+
...props,
|
|
538
|
+
children: props.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
539
|
+
/* @__PURE__ */ jsxs("header", { "data-part": "header", children: [
|
|
540
|
+
/* @__PURE__ */ jsxs("h1", { children: [
|
|
541
|
+
"Order ",
|
|
542
|
+
/* @__PURE__ */ jsx(Reference, {})
|
|
543
|
+
] }),
|
|
544
|
+
/* @__PURE__ */ jsx(Status, {})
|
|
545
|
+
] }),
|
|
546
|
+
/* @__PURE__ */ jsx("section", { "aria-label": "Progress", children: /* @__PURE__ */ jsx(Timeline, {}) }),
|
|
547
|
+
/* @__PURE__ */ jsx("section", { "aria-label": "Fulfilment", children: /* @__PURE__ */ jsx(Fulfilment, {}) }),
|
|
548
|
+
/* @__PURE__ */ jsx("section", { "aria-label": "Items", children: /* @__PURE__ */ jsx(Lines, {}) }),
|
|
549
|
+
/* @__PURE__ */ jsxs("section", { "aria-label": "Totals", children: [
|
|
550
|
+
/* @__PURE__ */ jsx(Totals, {}),
|
|
551
|
+
/* @__PURE__ */ jsx(Payments, {})
|
|
552
|
+
] }),
|
|
553
|
+
/* @__PURE__ */ jsx(
|
|
554
|
+
Actions,
|
|
555
|
+
{
|
|
556
|
+
...loyalty ? { loyalty } : {},
|
|
557
|
+
...onReorder ? { onReorder } : {}
|
|
558
|
+
}
|
|
559
|
+
)
|
|
560
|
+
] })
|
|
561
|
+
}
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
export {
|
|
565
|
+
Order,
|
|
566
|
+
OrderDetails,
|
|
567
|
+
currentStep2 as currentStep,
|
|
568
|
+
orderEnded,
|
|
569
|
+
orderMoney2 as orderMoney,
|
|
570
|
+
orderTime2 as orderTime,
|
|
571
|
+
orderTotals2 as orderTotals,
|
|
572
|
+
reorderNotice,
|
|
573
|
+
useCustomerOrder2 as useCustomerOrder,
|
|
574
|
+
useOrder
|
|
575
|
+
};
|
|
576
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/order/index.tsx"],
|
|
4
|
+
"mappings": ";;;AACA,SAAS,cAA2B;AAQpC;AAAA,EACE;AAAA,OAEK;AACP,SAAS,UAAU,iBAAiB;AACpC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,YAA4B;AACrC,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,OAEK;AAEP;AAAA,EACE,eAAAA;AAAA,EACA;AAAA,EACA,cAAAC;AAAA,E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AEJ;",
|
|
5
|
+
"names": ["currentStep", "orderMoney", "orderTime", "orderTotals", "useCustomerOrder", "Status", "Receipt", "OrderAgain", "Actions"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// src/order/model.ts
|
|
2
|
+
import { money } from "@zappie/sdk";
|
|
3
|
+
var orderMoney = (value) => money(value.amount_minor, value.currency);
|
|
4
|
+
function orderTotals(order) {
|
|
5
|
+
const rows = [
|
|
6
|
+
{ kind: "subtotal", label: "Subtotal", amount: orderMoney(order.subtotal) }
|
|
7
|
+
];
|
|
8
|
+
let delivery = false;
|
|
9
|
+
for (const charge of order.charges) {
|
|
10
|
+
const isDelivery = charge.code === "delivery";
|
|
11
|
+
delivery || (delivery = isDelivery);
|
|
12
|
+
rows.push({
|
|
13
|
+
kind: isDelivery ? "delivery" : "charge",
|
|
14
|
+
label: charge.label,
|
|
15
|
+
amount: orderMoney(charge.amount),
|
|
16
|
+
...charge.waived ? { note: "waived" } : charge.included ? { note: "included" } : {}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (!delivery && order.delivery_fee.amount_minor > 0) {
|
|
20
|
+
rows.push({
|
|
21
|
+
kind: "delivery",
|
|
22
|
+
label: "Delivery",
|
|
23
|
+
amount: orderMoney(order.delivery_fee)
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const discounts = order.discounts.length ? order.discounts : order.discount.amount_minor > 0 ? [{ label: "Discount", amount: order.discount }] : [];
|
|
27
|
+
for (const discount of discounts) {
|
|
28
|
+
rows.push({
|
|
29
|
+
kind: "discount",
|
|
30
|
+
label: discount.label,
|
|
31
|
+
amount: orderMoney({
|
|
32
|
+
...discount.amount,
|
|
33
|
+
amount_minor: -discount.amount.amount_minor
|
|
34
|
+
}),
|
|
35
|
+
..."promo_code" in discount && discount.promo_code ? { promoCode: discount.promo_code } : {}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
rows.push({ kind: "total", label: "Total", amount: orderMoney(order.total) });
|
|
39
|
+
if (order.amount_paid.amount_minor > 0) {
|
|
40
|
+
rows.push({
|
|
41
|
+
kind: "paid",
|
|
42
|
+
label: "Paid",
|
|
43
|
+
amount: orderMoney(order.amount_paid)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (order.amount_due.amount_minor > 0) {
|
|
47
|
+
rows.push({
|
|
48
|
+
kind: "due",
|
|
49
|
+
label: "Amount due",
|
|
50
|
+
amount: orderMoney(order.amount_due)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return rows;
|
|
54
|
+
}
|
|
55
|
+
var ended = /* @__PURE__ */ new Set(["completed", "cancelled", "rejected"]);
|
|
56
|
+
var orderEnded = (order) => ended.has(order.status);
|
|
57
|
+
function currentStep(order) {
|
|
58
|
+
const last = order.timeline.at(-1);
|
|
59
|
+
return last ? { title: last.title, description: last.description } : {
|
|
60
|
+
title: order.status.replaceAll("_", " ").replace(/^./, (first) => first.toUpperCase()),
|
|
61
|
+
description: ""
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function orderTime(iso, timeZone) {
|
|
65
|
+
const date = new Date(iso);
|
|
66
|
+
if (Number.isNaN(date.getTime())) {
|
|
67
|
+
return iso;
|
|
68
|
+
}
|
|
69
|
+
return new Intl.DateTimeFormat("en-GB", {
|
|
70
|
+
day: "numeric",
|
|
71
|
+
month: "short",
|
|
72
|
+
hour: "2-digit",
|
|
73
|
+
minute: "2-digit",
|
|
74
|
+
...timeZone ? { timeZone } : {}
|
|
75
|
+
}).format(date);
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
currentStep,
|
|
79
|
+
orderEnded,
|
|
80
|
+
orderMoney,
|
|
81
|
+
orderTime,
|
|
82
|
+
orderTotals
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/order/model.ts"],
|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AAC5E,MAAI,MAAM,YAAY,eAAe,GAAG;AACtC,SAAK,KAAK;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ,WAAW,MAAM,WAAW;AAAA,IACtC,CAAC;AAAA,EACH;AACA,MAAI,MAAM,WAAW,eAAe,GAAG;AACrC,SAAK,KAAK;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ,WAAW,MAAM,UAAU;AAAA,IACrC,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,IAAM,QAAQ,oBAAI,IAAI,CAAC,aAAa,aAAa,UAAU,CAAC;AAGrD,IAAM,aAAa,CAAC,UAAyB,MAAM,IAAI,MAAM,MAAM;AAMnE,SAAS,YAAY,OAG1B;AACA,QAAM,OAAO,MAAM,SAAS,GAAG,EAAE;AACjC,SAAO,OACH,EAAE,OAAO,KAAK,OAAO,aAAa,KAAK,YAAY,IACnD;AAAA,IACE,OAAO,MAAM,OACV,WAAW,KAAK,GAAG,EACnB,QAAQ,MAAM,CAAC,UAAU,MAAM,YAAY,CAAC;AAAA,IAC/C,aAAa;AAAA,EACf;AACN;AAMO,SAAS,UAAU,KAAa,UAA2B;AAChE,QAAM,OAAO,IAAI,KAAK,GAAG;AACzB,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,GAAG;AAChC,WAAO;AAAA,EACT;AACA,SAAO,IAAI,KAAK,eAAe,SAAS;AAAA,IACtC,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,GAAI,WAAW,EAAE,SAAS,IAAI,CAAC;AAAA,EACjC,CAAC,EAAE,OAAO,IAAI;AAChB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/order/use-customer-order.ts
|
|
4
|
+
import { useCallback, useEffect, useState } from "react";
|
|
5
|
+
import { orderEnded } from "./model.js";
|
|
6
|
+
function useCustomerOrder(customer, orderId, options = {}) {
|
|
7
|
+
const initial = options.initialOrder?.id === orderId ? options.initialOrder : void 0;
|
|
8
|
+
const [state, setState] = useState({ id: orderId, order: initial, error: void 0 });
|
|
9
|
+
const [attempt, setAttempt] = useState(0);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const abort = new AbortController();
|
|
12
|
+
const show = (order2) => {
|
|
13
|
+
if (!abort.signal.aborted) {
|
|
14
|
+
setState({ id: orderId, order: order2, error: void 0 });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
let stop;
|
|
18
|
+
customer.order(orderId, abort.signal).then(
|
|
19
|
+
(order2) => {
|
|
20
|
+
show(order2);
|
|
21
|
+
if (!abort.signal.aborted && !orderEnded(order2)) {
|
|
22
|
+
stop = customer.watchOrder(orderId, {
|
|
23
|
+
signal: abort.signal,
|
|
24
|
+
onOrder: show
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
(error2) => {
|
|
29
|
+
if (!abort.signal.aborted) {
|
|
30
|
+
setState((last) => ({
|
|
31
|
+
id: orderId,
|
|
32
|
+
order: last.id === orderId ? last.order : void 0,
|
|
33
|
+
error: error2
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
return () => {
|
|
39
|
+
abort.abort();
|
|
40
|
+
stop?.();
|
|
41
|
+
};
|
|
42
|
+
}, [customer, orderId, attempt]);
|
|
43
|
+
const retry = useCallback(() => setAttempt((value) => value + 1), []);
|
|
44
|
+
const order = state.id === orderId ? state.order : initial;
|
|
45
|
+
const error = state.id === orderId ? state.error : void 0;
|
|
46
|
+
return {
|
|
47
|
+
order,
|
|
48
|
+
error,
|
|
49
|
+
status: error === void 0 ? order ? "ready" : "loading" : error.status === 404 ? "not_found" : "error",
|
|
50
|
+
retry
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
useCustomerOrder
|
|
55
|
+
};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,CAAC,UAAU,SAAS,OAAO,CAAC;AAC/B,QAAM,QAAQ,YAAY,MAAM,WAAW,CAAC,UAAU,QAAQ,CAAC,GAAG,CAAC,CAAC;AACpE,QAAM,QAAQ,MAAM,OAAO,UAAU,MAAM,QAAQ;AACnD,QAAM,QAAQ,MAAM,OAAO,UAAU,MAAM,QAAQ;AACnD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,QACE,UAAU,SACN,QACE,UACA,YACD,MAA8B,WAAW,MACxC,cACA;AAAA,IACR;AAAA,EACF;AACF;",
|
|
5
|
+
"names": ["order", "error"]
|
|
6
|
+
}
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappie/foundations",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "UI-less React primitives for Zappie storefronts: behaviour, state and accessibility without styles.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"types": "./dist/loyalty/index.d.ts",
|
|
30
30
|
"import": "./dist/loyalty/index.js"
|
|
31
31
|
},
|
|
32
|
+
"./order": {
|
|
33
|
+
"types": "./dist/order/index.d.ts",
|
|
34
|
+
"import": "./dist/order/index.js"
|
|
35
|
+
},
|
|
32
36
|
"./phone": {
|
|
33
37
|
"types": "./dist/phone/index.d.ts",
|
|
34
38
|
"import": "./dist/phone/index.js"
|
|
@@ -61,7 +65,7 @@
|
|
|
61
65
|
"peerDependencies": {
|
|
62
66
|
"react": "^18.2.0 || ^19.0.0",
|
|
63
67
|
"react-dom": "^18.2.0 || ^19.0.0",
|
|
64
|
-
"@zappie/sdk": "^0.
|
|
68
|
+
"@zappie/sdk": "^0.17.0"
|
|
65
69
|
},
|
|
66
70
|
"repository": {
|
|
67
71
|
"type": "git",
|
|
@@ -71,7 +75,7 @@
|
|
|
71
75
|
"devDependencies": {
|
|
72
76
|
"@types/google.maps": "^3.66.7",
|
|
73
77
|
"esbuild": "^0.28.2",
|
|
74
|
-
"@zappie/sdk": "0.
|
|
78
|
+
"@zappie/sdk": "0.17.0"
|
|
75
79
|
},
|
|
76
80
|
"license": "MIT",
|
|
77
81
|
"homepage": "https://github.com/zappie/storefront-packages#readme",
|