Skip to content

Commit

Permalink
Updated Apk
Browse files Browse the repository at this point in the history
  • Loading branch information
jiloysss committed Nov 26, 2019
1 parent 9a3d888 commit 1f865f6
Show file tree
Hide file tree
Showing 25 changed files with 1,133 additions and 1,031 deletions.
33 changes: 17 additions & 16 deletions src/container/LoadingContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ export default class LoadingContainer extends React.Component {

componentDidMount() {
this.props.attendantStore.getData().then(async res => {
await this.props.receiptStore.currentReceipt(this.props.printerStore.companySettings[0].tax);
setTimeout(() => {
let routeName = "";
if (res.result || res.rowsLength > 0) {
routeName = "Pin";
} else {
routeName = "Login";
}

const resetAction = NavigationActions.reset({
index: 0,
key: null,
actions: [NavigationActions.navigate({ routeName })],
});
this.props.navigation.dispatch(resetAction);
}, 3000);
await this.props.receiptStore.currentReceipt(
this.props.printerStore.companySettings[0].tax,
);
setTimeout(() => {
let routeName = "";
if (res.result || res.rowsLength > 0) {
routeName = "Pin";
} else {
routeName = "Login";
}

const resetAction = NavigationActions.reset({
index: 0,
key: null,
actions: [NavigationActions.navigate({ routeName })],
});
this.props.navigation.dispatch(resetAction);
}, 3000);
});
}

Expand Down
45 changes: 29 additions & 16 deletions src/container/PaymentContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ export default class PaymentContainer extends React.Component {
}

componentWillMount() {

this.props.stateStore.resetScannedNfc();
this.props.stateStore.set_customers_pin("");
this.props.stateStore.set_customers_pin("");
this.props.stateStore.is_not_customers_pin();
this.props.stateStore.resetPaymentTypes();
this.props.stateStore.setMopAmount("0");
this.props.stateStore.setMopAmount("0");
const { stateStore } = this.props;
this.props.stateStore.setBalance(
(
Expand Down Expand Up @@ -138,19 +137,30 @@ export default class PaymentContainer extends React.Component {

onValueChange = text => {
let payment_state_values = this.props.stateStore.payment_state[0].toJSON();
let value = payment_state_values.selected === "Wallet" ? this.props.stateStore.customers_pin_value : this.props.stateStore.payment_value;
const { setPaymentValue, set_customers_pin } = this.props.stateStore;
let value =
payment_state_values.selected === "Wallet"
? this.props.stateStore.customers_pin_value
: this.props.stateStore.payment_value;
const { setPaymentValue, set_customers_pin } = this.props.stateStore;
if (text === "Del") {
const finalValue = value.slice(0, -1);
payment_state_values.selected === "Wallet" ? set_customers_pin(finalValue) : setPaymentValue(finalValue);
payment_state_values.selected === "Wallet"
? set_customers_pin(finalValue)
: setPaymentValue(finalValue);
} else {
if (text.length > 1) {
payment_state_values.selected === "Wallet" ? set_customers_pin(text) : setPaymentValue(text);
payment_state_values.selected === "Wallet"
? set_customers_pin(text)
: setPaymentValue(text);
} else {
if (this.props.stateStore.payment_value === "0") {
payment_state_values.selected === "Wallet" ? set_customers_pin(text) : setPaymentValue(text);
payment_state_values.selected === "Wallet"
? set_customers_pin(text)
: setPaymentValue(text);
} else {
payment_state_values.selected === "Wallet" ? set_customers_pin(value + text) : setPaymentValue(value + text);
payment_state_values.selected === "Wallet"
? set_customers_pin(value + text)
: setPaymentValue(value + text);
}
}
}
Expand Down Expand Up @@ -350,12 +360,16 @@ export default class PaymentContainer extends React.Component {
);
};
proceedToWalletTransaction = () => {
const { scanned_nfc, customers_pin_value,deviceId } = this.props.stateStore;
check_customers_pin(scanned_nfc, customers_pin_value, this.props, deviceId);
};clearCustomersPin = () => {
const { set_customers_pin } = this.props.stateStore;
set_customers_pin("");

const {
scanned_nfc,
customers_pin_value,
deviceId,
} = this.props.stateStore;
check_customers_pin(scanned_nfc, customers_pin_value, this.props, deviceId);
};
clearCustomersPin = () => {
const { set_customers_pin } = this.props.stateStore;
set_customers_pin("");
};
render() {
strings.setLanguage(currentLanguage().companyLanguage);
Expand Down Expand Up @@ -404,7 +418,6 @@ export default class PaymentContainer extends React.Component {
addMultipleMop={this.addMultipleMop}
removeMop={this.removeMop}
proceedToWalletTransaction={this.proceedToWalletTransaction}

/>
);
}
Expand Down
80 changes: 51 additions & 29 deletions src/container/PaymentContainer/nfc_manager_initialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,25 @@ export async function check_internet_connection(tag, props, deviceId) {
export async function on_check_tag_event(tag, props, deviceId) {
let scanned_nfc = JSON.parse(props.stateStore.scanned_nfc);
if (!("customer" in scanned_nfc)) {
check_customer_tag(tag, props, deviceId);
} else if (!("attendant" in scanned_nfc) && props.stateStore.customers_pin_value) {
check_attendant_tag(tag, props, deviceId);
} else if (!("attendant" in scanned_nfc) && !props.stateStore.customers_pin_value){
showToastDanger("Please enter customers pin first");
check_customer_tag(tag, props, deviceId);
} else if (
!("attendant" in scanned_nfc) &&
props.stateStore.customers_pin_value
) {
check_attendant_tag(tag, props, deviceId);
} else if (
!("attendant" in scanned_nfc) &&
!props.stateStore.customers_pin_value
) {
showToastDanger("Please enter customers pin first");
}
}
export async function check_customers_pin(scanned_nfc, customers_pin, props, deviceId) {
export async function check_customers_pin(
scanned_nfc,
customers_pin,
props,
deviceId,
) {
if (scanned_nfc) {
if (validUrl.isWebUri(returnUrl().url)) {
FrappeFetch.createClient(returnUrl())
Expand All @@ -88,7 +99,7 @@ export async function check_customers_pin(scanned_nfc, customers_pin, props, dev
"tailpos_sync.wallet_sync.check_customers_pin",
{
wallet_card_number: scanned_nfc,
customers_pin: customers_pin,
customers_pin: customers_pin,
},
);
})
Expand All @@ -99,12 +110,13 @@ export async function check_customers_pin(scanned_nfc, customers_pin, props, dev
showToastDanger(responseJson.message.message);
} else {
showToast(responseJson.message.message);
props.stateStore.is_customers_pin();
props.stateStore.is_customers_pin();
}

})
.catch(() =>
showToastDanger("Please check your credentials in Sync settings and Error Logs in ERPNext"),
showToastDanger(
"Please check your credentials in Sync settings and Error Logs in ERPNext",
),
);
} else {
showToastDanger("Invalid URL. Please set valid URL in Sync Settings");
Expand Down Expand Up @@ -132,28 +144,35 @@ export async function check_attendant_tag(tag, props, deviceId) {
} else {
props.stateStore.updateScannedNfc("attendant", tag.id);

proceed_to_validate_sync(props,deviceId);
proceed_to_validate_sync(props, deviceId);
}
})
.catch(() =>
showToastDanger("Please check your credentials in Sync settings and Error Logs in ERPNext"),
showToastDanger(
"Please check your credentials in Sync settings and Error Logs in ERPNext",
),
);
} else {
showToastDanger("Invalid URL. Please set valid URL in Sync Settings");
}
}
}
export async function proceed_to_validate_sync(props, deviceId) {
Alert.alert(
"Confirm Wallet Transaction",
"Are you sure you want to proceed wallet transaction?",
[
{ text: "No", style: "cancel" },
{ text: "Yes",onPress: () => { on_sync_tag_event(props.stateStore.scanned_nfc, props, deviceId); } },
]
);
}
export async function check_customer_tag(tag, props,deviceId) {
Alert.alert(
"Confirm Wallet Transaction",
"Are you sure you want to proceed wallet transaction?",
[
{ text: "No", style: "cancel" },
{
text: "Yes",
onPress: () => {
on_sync_tag_event(props.stateStore.scanned_nfc, props, deviceId);
},
},
],
);
}
export async function check_customer_tag(tag, props, deviceId) {
if (tag) {
const { defaultReceipt } = stores.receiptStore;
if (validUrl.isWebUri(returnUrl().url)) {
Expand All @@ -172,17 +191,18 @@ export async function check_customer_tag(tag, props,deviceId) {
.catch(() => {})
.then(response => response.json())
.then(responseJson => {
if (responseJson.message.failed){
showToastDanger(responseJson.message.message);
if (responseJson.message.failed) {
showToastDanger(responseJson.message.message);
} else {
props.stateStore.updateScannedNfc("customer", tag.id);
showToast(responseJson.message.message);

props.stateStore.updateScannedNfc("customer", tag.id);
showToast(responseJson.message.message);
}
})

.catch(() =>
showToastDanger("Please check your credentials in Sync settings and Error Logs in ERPNext"),
showToastDanger(
"Please check your credentials in Sync settings and Error Logs in ERPNext",
),
);
} else {
showToastDanger("Invalid URL. Please set valid URL in Sync Settings");
Expand All @@ -209,7 +229,9 @@ export async function on_sync_tag_event(scanned_nfc, props, deviceId) {
validate_return_from_server(responseJson.message, props);
})
.catch(() =>
showToastDanger("Please check your credentials in Sync settings and Error Logs in ERPNext"),
showToastDanger(
"Please check your credentials in Sync settings and Error Logs in ERPNext",
),
);
} else {
showToastDanger("Invalid URL. Please set valid URL in Sync Settings");
Expand Down
Loading

0 comments on commit 1f865f6

Please sign in to comment.