Skip to content

Commit 0928780

Browse files
authored
Update to show ReprintReceiptData interface and add nodemon script (#3015)
* add `ReprintReceiptData` documentation to receipt block render. * fix example code for `pos.receipt-footer.block.render`. * fix related links for Cash tracking targets. * add nodemon for watching pos changes. * fix type guard on connectivity and locale API.
1 parent cacfac3 commit 0928780

File tree

12 files changed

+38
-21
lines changed

12 files changed

+38
-21
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"docs:admin:dev": "yarn workspace @shopify/ui-extensions docs:admin:dev",
2020
"docs:checkout": "yarn workspace @shopify/ui-extensions docs:checkout",
2121
"docs:point-of-sale": "yarn workspace @shopify/ui-extensions docs:point-of-sale",
22+
"docs:pos": "yarn docs:point-of-sale",
23+
"docs:pos:dev": "yarn workspace @shopify/ui-extensions docs:point-of-sale:dev",
2224
"docs:customer-account": "yarn workspace @shopify/ui-extensions docs:customer-account",
2325
"deploy:unstable": "changeset version --snapshot unstable && changeset publish --tag unstable --no-git-tag",
2426
"predeploy:internal": "yarn build",

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {useEffect, useRef, useState} from 'react';
22

3-
import {ConnectivityState} from '@shopify/ui-extensions/point-of-sale';
3+
import type {
4+
ConnectivityApiContent,
5+
ConnectivityState,
6+
} from '@shopify/ui-extensions/point-of-sale';
47
import {
58
StatefulRemoteSubscribable,
69
makeStatefulSubscribable,
@@ -19,7 +22,9 @@ let statefulSubscribable:
1922
/**
2023
* Verifies that the API has a Connectivity in it.
2124
*/
22-
const isConnectivityApi = (api: any): boolean => {
25+
const isConnectivityApi = (
26+
api: any,
27+
): api is {connectivity: ConnectivityApiContent} => {
2328
return 'connectivity' in api;
2429
};
2530

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
makeStatefulSubscribable,
66
} from '@remote-ui/async-subscription';
77

8+
import type {LocaleApiContent} from '@shopify/ui-extensions/point-of-sale';
89
import {useApi} from './api';
910

1011
/**
@@ -16,7 +17,7 @@ let statefulSubscribable: StatefulRemoteSubscribable<string> | undefined;
1617
/**
1718
* Verifies that the API has a Locale in it.
1819
*/
19-
const isLocaleApi = (api: any): boolean => {
20+
const isLocaleApi = (api: any): api is {locale: LocaleApiContent} => {
2021
return 'locale' in api;
2122
};
2223

packages/ui-extensions/docs/surfaces/point-of-sale/reference/examples/targets/pos-receipt-footer-block-render.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@ import {
77

88
export default extension('pos.receipt-footer.block.render', (root, api) => {
99
const block = root.createComponent(POSReceiptBlock);
10+
const transaction = api.transaction;
1011
const textTransactionType = root.createComponent(
1112
Text,
1213
{},
13-
`Transaction type: ${api.transaction.transactionType}`,
14+
`Transaction type: ${transaction.transactionType}`,
1415
);
1516
const textTaxTotal = root.createComponent(
1617
Text,
1718
{},
18-
`Total tax: ${api.transaction.taxTotal}`,
19+
`Total tax (${transaction.taxTotal.currency}): ${transaction.taxTotal.amount}`,
1920
);
2021
const qrCodeValue =
21-
api.transaction.transactionType === 'Exchange'
22-
? `exampleExchange=${encodeURIComponent(
23-
api.transaction.exchangeId ?? '',
24-
)}`
25-
: `exampleOrder=${encodeURIComponent(api.transaction.orderId ?? '')}`;
22+
transaction.transactionType === 'Exchange'
23+
? `exampleExchange=${encodeURIComponent(transaction.exchangeId ?? '')}`
24+
: `exampleOrder=${encodeURIComponent(transaction.orderId ?? '')}`;
2625

2726
const qrCode = root.createComponent(QRCode, {
2827
value: `https://www.shopify.com?${qrCodeValue}`,

packages/ui-extensions/docs/surfaces/point-of-sale/reference/examples/targets/pos-receipt-footer-block-render.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Block = () => {
1818
return (
1919
<POSReceiptBlock>
2020
<Text>{`Transaction type: ${transaction.transactionType}`}</Text>
21-
<Text>{`Total tax: ${transaction.taxTotal}`}</Text>
21+
<Text>{`Total tax (${transaction.taxTotal.currency}): ${transaction.taxTotal.amount}`}</Text>
2222
<QRCode value={`https://www.shopify.com?${qrCodeValue}`} />
2323
</POSReceiptBlock>
2424
);

packages/ui-extensions/docs/surfaces/point-of-sale/reference/targets/pos.cash-tracking-session-complete.event.observe.doc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const data: ReferenceEntityTemplateSchema = {
1515
name: ExtensionTargetType.PosCashTrackingSessionStartObserve,
1616
subtitle: 'Target',
1717
type: 'blocks',
18-
url: '/docs/api/pos-ui-extensions/targets/cash-tracking/pos-cash-tracking-session-start-observe',
18+
url: '/docs/api/pos-ui-extensions/targets/cash-tracking/pos-cash-tracking-session-start-event-observe',
1919
},
2020
],
2121
type: 'Target',

packages/ui-extensions/docs/surfaces/point-of-sale/reference/targets/pos.cash-tracking-session-start.event.observe.doc.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
2-
import {generateCodeBlock} from '../helpers/generateCodeBlock';
32
import {CUSTOM_DATA} from '../helpers/helper.docs';
43
import {ExtensionTargetType} from '../types/ExtensionTargetType';
54

@@ -16,7 +15,7 @@ const data: ReferenceEntityTemplateSchema = {
1615
name: ExtensionTargetType.PosCashTrackingSessionCompleteObserve,
1716
subtitle: 'Target',
1817
type: 'blocks',
19-
url: '/docs/api/pos-ui-extensions/targets/cash-tracking/pos-cash-tracking-session-complete-observe',
18+
url: '/docs/api/pos-ui-extensions/targets/cash-tracking/pos-cash-tracking-session-complete-event-observe',
2019
},
2120
],
2221
type: 'Target',

packages/ui-extensions/docs/surfaces/point-of-sale/reference/targets/pos.receipt-footer.block.render.doc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type {ReferenceEntityTemplateSchema} from '@shopify/generate-docs';
22
import {generateCodeBlock} from '../helpers/generateCodeBlock';
3-
import {TRANSACTION_COMPLETE_DEFINITION} from '../helpers/helper.docs';
3+
import {CUSTOM_DATA} from '../helpers/helper.docs';
44
import {ExtensionTargetType} from '../types/ExtensionTargetType';
55

66
const data: ReferenceEntityTemplateSchema = {
@@ -27,7 +27,7 @@ const data: ReferenceEntityTemplateSchema = {
2727
},
2828
],
2929
type: 'Target',
30-
...TRANSACTION_COMPLETE_DEFINITION,
30+
definitions: [CUSTOM_DATA('TransactionCompleteWithReprintData')],
3131
};
3232

3333
export default data;

packages/ui-extensions/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"gen-docs:admin": "bash ./docs/surfaces/admin/create-doc-files.sh \"admin\"",
88
"docs:checkout": "bash ./docs/surfaces/checkout/build-docs.sh",
99
"docs:point-of-sale": "bash ./docs/surfaces/point-of-sale/build-docs.sh",
10+
"docs:point-of-sale:dev": "nodemon --watch src/surfaces/point-of-sale/ --watch docs/surfaces/point-of-sale/ -e ts,tsx,json,png,txt --ignore '**/generated/**' --exec 'yarn docs:point-of-sale'",
1011
"docs:customer-account": "bash ./docs/surfaces/customer-account/build-docs.sh"
1112
},
1213
"main": "index.js",

packages/ui-extensions/src/surfaces/point-of-sale/data.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
export type {BaseData} from './event/data/BaseData';
22
export type {BaseApi} from './event/data/BaseApi';
33
export type {ReprintReceiptData} from './event/data/ReprintReceiptData';
4-
export type {TransactionCompleteData} from './event/data/TransactionCompleteData';
4+
export type {
5+
TransactionCompleteData,
6+
TransactionCompleteWithReprintData,
7+
} from './event/data/TransactionCompleteData';
58
export type {
69
CashTrackingSessionCompleteData,
710
CashTrackingSessionStartData,

0 commit comments

Comments
 (0)