From 95329db9a289626917e0ab8207543ba3b3f30106 Mon Sep 17 00:00:00 2001 From: Ivan Ray Altomera Date: Tue, 16 Jul 2019 15:41:25 +0800 Subject: [PATCH 1/2] fix: table click not responding --- src/container/SalesContainer/index.js | 23 ++++++++--------------- src/services/tailorder.js | 10 ++++++++++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/container/SalesContainer/index.js b/src/container/SalesContainer/index.js index 0479ed0..41530f7 100644 --- a/src/container/SalesContainer/index.js +++ b/src/container/SalesContainer/index.js @@ -36,7 +36,9 @@ import { tailOrderLine, changeOrderTable, getOrder, + orderItemToReceiptItem, } from "../../services/tailorder"; + import { currentLanguage } from "../../translations/CurrentLanguage"; const Sound = require("react-native-sound"); @@ -667,25 +669,16 @@ export default class SalesContainer extends React.Component { onTableClick = index => { const { orders, setCurrentTable } = this.props.stateStore; - - setCurrentTable(orders[index].id); - const lines = JSON.parse(orders[index].lines); - - // Default Receipt const { defaultReceipt } = this.props.receiptStore; + const { id, items } = orders[index]; - // Clear receipts + setCurrentTable(id); defaultReceipt.clear(); - // Add all of the items to the receipt - for (let i = 0; i < lines.length; i++) { - defaultReceipt.add({ - item: lines[i].itemCode, - item_name: lines[i].itemName, - price: lines[i].rate, - qty: lines[i].qty, - date: Date.now(), - }); + for (let i = 0; i < items.length; i++) { + defaultReceipt.add( + orderItemToReceiptItem(items[i]) + ); } }; diff --git a/src/services/tailorder.js b/src/services/tailorder.js index 1085ee6..0845208 100644 --- a/src/services/tailorder.js +++ b/src/services/tailorder.js @@ -62,6 +62,16 @@ exports.tailOrderLine = function(line) { }; }; +exports.orderItemToReceiptItem = function(item) { + return { + item: item.item_code, + item_name: item.item_name, + price: item.rate, + qty: item.qty, + date: item.creation + }; +}; + exports.getOrder = function(type, items) { return { type, items }; }; From 0ce715bc60593f3fdc742f076b02ba38f9ccf696 Mon Sep 17 00:00:00 2001 From: Ivan Ray Altomera Date: Tue, 16 Jul 2019 15:42:15 +0800 Subject: [PATCH 2/2] fix: eslint --- src/container/SalesContainer/index.js | 4 +--- src/services/tailorder.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/container/SalesContainer/index.js b/src/container/SalesContainer/index.js index 41530f7..086876f 100644 --- a/src/container/SalesContainer/index.js +++ b/src/container/SalesContainer/index.js @@ -676,9 +676,7 @@ export default class SalesContainer extends React.Component { defaultReceipt.clear(); for (let i = 0; i < items.length; i++) { - defaultReceipt.add( - orderItemToReceiptItem(items[i]) - ); + defaultReceipt.add(orderItemToReceiptItem(items[i])); } }; diff --git a/src/services/tailorder.js b/src/services/tailorder.js index 0845208..70beb47 100644 --- a/src/services/tailorder.js +++ b/src/services/tailorder.js @@ -68,7 +68,7 @@ exports.orderItemToReceiptItem = function(item) { item_name: item.item_name, price: item.rate, qty: item.qty, - date: item.creation + date: item.creation, }; };