-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from ResaleAI/plugin-api-updates
Plugin api updates
- Loading branch information
Showing
218 changed files
with
1,407 additions
and
14,952 deletions.
There are no files selected for viewing
21 changes: 10 additions & 11 deletions
21
examples/movie-theater-node/components/AdmissionDisclaimer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import ReceiptComponent from '@resaleai/receipt-components'; | ||
import { rc } from '@resaleai/receipt-components'; | ||
|
||
const AdmissionDisclaimer = new ReceiptComponent('AdmissionDisclaimer', { | ||
render: () => ` | ||
<align mode="center"> | ||
*************************** | ||
<br /> | ||
Not valid for admission | ||
<br /> | ||
*************************** | ||
</align>`, | ||
}); | ||
function AdmissionDisclaimer(_props: null) { | ||
return rc('align', { mode: 'center' }, [ | ||
rc('textLiteral', { text: '***************************' }), | ||
rc('break'), | ||
rc('textLiteral', { text: 'Not valid for admission' }), | ||
rc('break'), | ||
rc('textLiteral', { text: '***************************' }), | ||
]) | ||
} | ||
|
||
export default AdmissionDisclaimer; |
222 changes: 111 additions & 111 deletions
222
examples/movie-theater-node/components/LineItemList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,118 @@ | ||
import ReceiptComponent from '@resaleai/receipt-components'; | ||
import hr from './hr'; | ||
import { serializeObject } from '../util'; | ||
import { LineItem } from '../types'; | ||
// import ReceiptComponent from '@resaleai/receipt-components'; | ||
// import hr from './hr'; | ||
// import { serializeObject } from '../util'; | ||
// import { LineItem } from '../types'; | ||
|
||
interface LineItemListItemProps { | ||
item: string; | ||
} | ||
// interface LineItemListItemProps { | ||
// item: string; | ||
// } | ||
|
||
interface LineItemListProps { | ||
items: string; | ||
paymentMethod: string; | ||
} | ||
// interface LineItemListProps { | ||
// items: string; | ||
// paymentMethod: string; | ||
// } | ||
|
||
const LineItemListItem = new ReceiptComponent<LineItemListItemProps>( | ||
'LineItemListItem', | ||
{ | ||
render: (props) => { | ||
const item = JSON.parse(props.item); | ||
// const LineItemListItem = new ReceiptComponent<LineItemListItemProps>( | ||
// 'LineItemListItem', | ||
// { | ||
// render: (props) => { | ||
// const item = JSON.parse(props.item); | ||
|
||
const template = ` | ||
<row> | ||
<col cols="7"> | ||
${item.name} | ||
</col> | ||
<col cols="1" justify="center"> | ||
${item.quantity} | ||
</col> | ||
<col cols="2" justify="right"> | ||
${item.price.toFixed(2)} | ||
</col> | ||
</row> | ||
`; | ||
return template; | ||
}, | ||
} | ||
); | ||
// const template = ` | ||
// <row> | ||
// <col cols="7"> | ||
// ${item.name} | ||
// </col> | ||
// <col cols="1" justify="center"> | ||
// ${item.quantity} | ||
// </col> | ||
// <col cols="2" justify="right"> | ||
// ${item.price.toFixed(2)} | ||
// </col> | ||
// </row> | ||
// `; | ||
// return template; | ||
// }, | ||
// } | ||
// ); | ||
|
||
const LineItemList = new ReceiptComponent<LineItemListProps>('LineItemList', { | ||
render: (props) => { | ||
const items: LineItem[] = JSON.parse(props.items); | ||
const subtotal = items.reduce((acc, item) => acc + item.price, 0); | ||
const tax = subtotal * 0.07; | ||
const total = subtotal + tax; | ||
// const LineItemList = new ReceiptComponent<LineItemListProps>('LineItemList', { | ||
// render: (props) => { | ||
// const items: LineItem[] = JSON.parse(props.items); | ||
// const subtotal = items.reduce((acc, item) => acc + item.price, 0); | ||
// const tax = subtotal * 0.07; | ||
// const total = subtotal + tax; | ||
|
||
const template = ` | ||
<fragment> | ||
<hr /> | ||
<br /> | ||
<text bold> | ||
<row> | ||
<col cols="7"> | ||
Item | ||
</col> | ||
<col cols="1" justify="center"> | ||
Qty | ||
</col> | ||
<col cols="2" justify="right"> | ||
Price | ||
</col> | ||
</row> | ||
</text> | ||
<br /> | ||
<hr /> | ||
<row> | ||
${items | ||
.map( | ||
(item) => `<LineItemListItem item="${serializeObject(item)}" /><br />` | ||
) | ||
.join('\n')} | ||
<col cols="8"></col> | ||
<col cols="2" justify="right"> | ||
------- | ||
</col> | ||
<col cols="5"> | ||
</col> | ||
<col cols="3"> | ||
Subtotal: | ||
</col> | ||
<col cols="2" justify="right"> | ||
${subtotal.toFixed(2)} | ||
</col> | ||
<col cols="5"> | ||
</col> | ||
<col cols="3"> | ||
TAX: | ||
</col> | ||
<col cols="2" justify="right"> | ||
${tax.toFixed(2)} | ||
</col> | ||
<col cols="5"> | ||
</col> | ||
<col cols="3"> | ||
<scale height="2"> | ||
TOTAL: | ||
</scale> | ||
</col> | ||
<col cols="2" justify="right"> | ||
<scale height="2"> | ||
${total.toFixed(2)} | ||
</scale> | ||
</col> | ||
</row> | ||
<br /> | ||
<text bold> | ||
Payments: | ||
</text> | ||
<br /> | ||
<text> ${props.paymentMethod} ${total.toFixed(2)}</text> | ||
<br /> | ||
</fragment> | ||
`; | ||
return template; | ||
}, | ||
components: [LineItemListItem, hr], | ||
}); | ||
// const template = ` | ||
// <fragment> | ||
// <hr /> | ||
// <br /> | ||
// <text bold> | ||
// <row> | ||
// <col cols="7"> | ||
// Item | ||
// </col> | ||
// <col cols="1" justify="center"> | ||
// Qty | ||
// </col> | ||
// <col cols="2" justify="right"> | ||
// Price | ||
// </col> | ||
// </row> | ||
// </text> | ||
// <br /> | ||
// <hr /> | ||
// <row> | ||
// ${items | ||
// .map( | ||
// (item) => `<LineItemListItem item="${serializeObject(item)}" /><br />` | ||
// ) | ||
// .join('\n')} | ||
// <col cols="8"></col> | ||
// <col cols="2" justify="right"> | ||
// ------- | ||
// </col> | ||
// <col cols="5"> | ||
// </col> | ||
// <col cols="3"> | ||
// Subtotal: | ||
// </col> | ||
// <col cols="2" justify="right"> | ||
// ${subtotal.toFixed(2)} | ||
// </col> | ||
// <col cols="5"> | ||
// </col> | ||
// <col cols="3"> | ||
// TAX: | ||
// </col> | ||
// <col cols="2" justify="right"> | ||
// ${tax.toFixed(2)} | ||
// </col> | ||
// <col cols="5"> | ||
// </col> | ||
// <col cols="3"> | ||
// <scale height="2"> | ||
// TOTAL: | ||
// </scale> | ||
// </col> | ||
// <col cols="2" justify="right"> | ||
// <scale height="2"> | ||
// ${total.toFixed(2)} | ||
// </scale> | ||
// </col> | ||
// </row> | ||
// <br /> | ||
// <text bold> | ||
// Payments: | ||
// </text> | ||
// <br /> | ||
// <text> ${props.paymentMethod} ${total.toFixed(2)}</text> | ||
// <br /> | ||
// </fragment> | ||
// `; | ||
// return template; | ||
// }, | ||
// components: [LineItemListItem, hr], | ||
// }); | ||
|
||
export default LineItemList; | ||
// export default LineItemList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.