Skip to content

Commit 6237dc7

Browse files
committed
Fixes
1 parent b9e365d commit 6237dc7

File tree

10 files changed

+66
-179
lines changed

10 files changed

+66
-179
lines changed

packages/ui-extensions-react/src/surfaces/point-of-sale/hooks/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export {
1414
useStatefulSubscribableLocale,
1515
destroyStatefulSubscribableLocale,
1616
} from './locale-api';
17-
export {useOrder} from './order-api';
1817

1918
export {
2019
useScannerDataSubscription,

packages/ui-extensions/docs/surfaces/point-of-sale/reference/apis/order-api.doc.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,16 @@ The Order API provides an extension with data about the current order.
3434
examples: [
3535
{
3636
codeblock: generateCodeBlockForOrderApi(
37-
'Basic usage of the Order API with useOrder hook',
37+
'Basic usage of the Order API in an action',
3838
'basic-usage',
3939
),
4040
},
4141
{
4242
codeblock: generateCodeBlockForOrderApi(
43-
'Display order details in a custom block',
43+
'Display order details in a block',
4444
'display-in-block',
4545
),
4646
},
47-
{
48-
codeblock: generateCodeBlockForOrderApi(
49-
'Use Order API with navigation',
50-
'with-navigation',
51-
),
52-
},
53-
{
54-
codeblock: generateCodeBlockForOrderApi(
55-
'Simple useOrder hook example',
56-
'use-order-hook',
57-
),
58-
},
5947
],
6048
},
6149
};
Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
import {
22
extension,
33
Screen,
4-
Navigator,
54
ScrollView,
65
Text,
7-
Section,
86
} from '@shopify/ui-extensions/point-of-sale';
97

10-
export default extension('pos.purchase.post.block.render', (root, api) => {
11-
// Access order information from the API
8+
export default extension('pos.purchase.post.action.render', (root, api) => {
129
const order = api.order;
1310

14-
const navigator = root.createComponent(Navigator, {});
15-
const screen = navigator.createComponent(Screen, {
16-
name: 'OrderDetails',
17-
title: 'Order Details',
18-
});
19-
const scrollView = screen.createComponent(ScrollView, {});
20-
const section = scrollView.createComponent(Section, {
21-
title: 'Order Information',
11+
const screen = root.createComponent(Screen, {
12+
name: 'PostPurchaseAction',
13+
title: 'Post Purchase Action',
2214
});
2315

24-
section.createComponent(Text, {}, `Order ID: ${order.id}`);
25-
section.createComponent(Text, {}, `Order Name: ${order.name}`);
16+
const scrollView = root.createComponent(ScrollView, {});
17+
18+
const orderName = root.createComponent(Text, {}, `Order Name: ${order.name}`);
19+
const orderId = root.createComponent(Text, {}, `Order ID: ${order.id}`);
20+
const orderCustomerId = root.createComponent(
21+
Text,
22+
{},
23+
`Order Customer ID: ${order.customerId}`,
24+
);
25+
26+
scrollView.append(orderName);
27+
scrollView.append(orderId);
28+
scrollView.append(orderCustomerId);
29+
30+
screen.append(scrollView);
2631

27-
if (order.customerId) {
28-
section.createComponent(Text, {}, `Customer ID: ${order.customerId}`);
29-
}
32+
root.append(screen);
3033

3134
root.mount();
3235
});

packages/ui-extensions/docs/surfaces/point-of-sale/reference/examples/order-api/basic-usage.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import {
66
ScrollView,
77
Text,
88
Section,
9-
useOrder,
9+
useApi,
1010
} from '@shopify/ui-extensions-react/point-of-sale';
1111

12-
const SmartGridModal = () => {
13-
// Use the useOrder hook to access order information
14-
const order = useOrder();
12+
const PostPurchaseAction = () => {
13+
const api = useApi<'pos.purchase.post.action.render'>();
14+
const order = api.order;
1515

1616
return (
1717
<Navigator>
18-
<Screen name="OrderDetails" title="Order Details">
18+
<Screen name="PostPurchaseAction" title="Post Purchase Action">
1919
<ScrollView>
2020
<Section title="Order Information">
2121
<Text>Order ID: {order.id}</Text>
@@ -28,6 +28,6 @@ const SmartGridModal = () => {
2828
);
2929
};
3030

31-
export default reactExtension('pos.purchase.post.block.render', () => (
32-
<SmartGridModal />
31+
export default reactExtension('pos.purchase.post.action.render', () => (
32+
<PostPurchaseAction />
3333
));
Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
import {
22
extension,
3-
POSBlock,
4-
POSBlockRow,
3+
Screen,
4+
Navigator,
5+
ScrollView,
6+
Text,
7+
Section,
58
} from '@shopify/ui-extensions/point-of-sale';
69

7-
export default extension('pos.order-details.block.render', (root, api) => {
10+
export default extension('pos.purchase.post.action.render', (root, api) => {
811
const order = api.order;
912

10-
const posBlock = root.createComponent(POSBlock, {});
11-
12-
posBlock.createComponent(POSBlockRow, {
13-
label: 'Order',
14-
value: order.name,
13+
const screen = root.createComponent(Screen, {
14+
name: 'PostPurchaseAction',
15+
title: 'Post Purchase Action',
1516
});
1617

17-
posBlock.createComponent(POSBlockRow, {
18-
label: 'Order ID',
19-
value: order.id.toString(),
20-
});
18+
const scrollView = root.createComponent(ScrollView, {});
19+
20+
const orderName = root.createComponent(Text, {}, `Order Name: ${order.name}`);
21+
const orderId = root.createComponent(Text, {}, `Order ID: ${order.id}`);
22+
const orderCustomerId = root.createComponent(
23+
Text,
24+
{},
25+
`Order Customer ID: ${order.customerId}`,
26+
);
27+
28+
scrollView.append(orderName);
29+
scrollView.append(orderId);
30+
scrollView.append(orderCustomerId);
31+
32+
screen.append(scrollView);
2133

22-
if (order.customerId) {
23-
posBlock.createComponent(POSBlockRow, {
24-
label: 'Customer ID',
25-
value: order.customerId.toString(),
26-
});
27-
}
34+
root.append(screen);
2835

2936
root.mount();
3037
});

packages/ui-extensions/docs/surfaces/point-of-sale/reference/examples/order-api/display-in-block.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,27 @@ import {
33
reactExtension,
44
POSBlock,
55
POSBlockRow,
6-
useOrder,
6+
useApi,
7+
Text,
78
} from '@shopify/ui-extensions-react/point-of-sale';
89

910
const OrderDetailsBlock = () => {
10-
// Use the useOrder hook directly
11-
const order = useOrder();
11+
const api = useApi<'pos.purchase.post.action.render'>();
12+
const order = api.order;
1213

1314
return (
1415
<POSBlock>
15-
<POSBlockRow label="Order" value={order.name} />
16-
<POSBlockRow label="Order ID" value={order.id.toString()} />
17-
{order.customerId && (
18-
<POSBlockRow label="Customer ID" value={order.customerId.toString()} />
19-
)}
16+
<POSBlockRow>
17+
<Text>Order {order.name}</Text>
18+
<Text>Order ID {order.id.toString()}</Text>
19+
{order.customerId && (
20+
<Text>Customer ID {order.customerId.toString()}</Text>
21+
)}
22+
</POSBlockRow>
2023
</POSBlock>
2124
);
2225
};
2326

24-
export default reactExtension('pos.order-details.block.render', () => (
27+
export default reactExtension('pos.purchase.post.block.render', () => (
2528
<OrderDetailsBlock />
2629
));

packages/ui-extensions/docs/surfaces/point-of-sale/reference/examples/order-api/use-order-hook.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/ui-extensions/docs/surfaces/point-of-sale/reference/examples/order-api/use-order-hook.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/ui-extensions/docs/surfaces/point-of-sale/reference/examples/order-api/with-navigation.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/ui-extensions/docs/surfaces/point-of-sale/reference/examples/order-api/with-navigation.tsx

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)