Skip to content

Commit

Permalink
Merge pull request #1967 from kaloudis/pos-order-unit-vs-total-displa…
Browse files Browse the repository at this point in the history
…y-value

POS: Order: clearly display per unit + total values
  • Loading branch information
kaloudis authored Feb 2, 2024
2 parents 256f0b2 + 9c8257c commit 5c6b75f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
5 changes: 2 additions & 3 deletions components/KeyValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default class KeyValue extends React.Component<KeyValueProps, {}> {
const styles = StyleSheet.create({
key: {
paddingRight: 35,
maxWidth: '50%'
maxWidth: '70%'
},
value: {
flex: 1,
Expand All @@ -135,7 +135,6 @@ const styles = StyleSheet.create({
justifyContent: 'flex-end'
},
rtlValue: {
paddingRight: 10,
maxWidth: '50%'
paddingRight: 10
}
});
26 changes: 17 additions & 9 deletions views/Order.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,35 +331,43 @@ export default class OrderView extends React.Component<OrderProps, OrderState> {
keyboardShouldPersistTaps="handled"
>
{lineItems.map((item: any, index: number) => {
const keyValue =
item.quantity > 1
? `${item.name} (x${item.quantity})`
: item.name;

const fiatPriced = item.base_price_money.amount > 0;

const unitPrice = fiatPriced
? item.base_price_money.amount
: item.base_price_money.sats;

let displayValue;
let unitDisplayValue, totalDisplayValue;
if (fiatPriced) {
displayValue = UnitsStore.getFormattedAmount(
unitDisplayValue = UnitsStore.getFormattedAmount(
unitPrice,
'fiat'
);
totalDisplayValue = UnitsStore.getFormattedAmount(
unitPrice * item.quantity,
'fiat'
);
} else {
displayValue = UnitsStore.getFormattedAmount(
unitDisplayValue = UnitsStore.getFormattedAmount(
unitPrice,
'sats'
);
totalDisplayValue = UnitsStore.getFormattedAmount(
unitPrice * item.quantity,
'sats'
);
}

const keyValue =
item.quantity > 1
? `${item.name} (x${item.quantity} @ ${unitDisplayValue})`
: item.name;

return (
<KeyValue
key={index}
keyValue={keyValue}
value={displayValue}
value={totalDisplayValue}
/>
);
})}
Expand Down

0 comments on commit 5c6b75f

Please sign in to comment.