+
+ {/*
-
- Hey there, {user.name.split(" ")[0]}
-
- You are logged into a full-stack{" "}
- MERN app 👏
-
-
-
-
- + Create PoS
-
+ Logout
+
+
+
-
- Cashier
-
+
*/}
+
+
+
+
+ {this.state.user_data.name.substring(0, 1)}
+
+
+
{this.state.user_data.name}
+
+ expand_more
+
+
+
+
+
+
+ dashboard
+ Master Dashboard
+
+
+ shopping_cart
+ Global Transaction History
+
+
+
+
+
+ settings_power
+ Logout
+
+
+
+
+
+
+
+
+
+
+
+
Master
+ Dashboard
+
+
+
+
+
- Customer
+
+ add
+
+ add new PoS
-
+
+
+
+
+
+ {
+ this.state.user_pos_systems.map((pos, i) =>
+
+
+
ID: ...{pos._id.substring(17)}
+
+
+ {pos.name}
+
+
+
+ )
+ }
);
}
+
}
Dashboard.propTypes = {
logoutUser: PropTypes.func.isRequired,
- auth: PropTypes.object.isRequired
};
const mapStateToProps = state => ({
@@ -95,4 +333,4 @@ const mapStateToProps = state => ({
export default connect(
mapStateToProps,
{ logoutUser }
-)(Dashboard);
+)(injectSheet(styles)(Dashboard));
diff --git a/src/components/layout/Cashier.js b/src/components/layout/Cashier.js
index 1c5b7af..9d68eca 100644
--- a/src/components/layout/Cashier.js
+++ b/src/components/layout/Cashier.js
@@ -1,136 +1,638 @@
-//const command = require("shebang!../bin/command");
import React from 'react';
-import { Helmet } from 'react-helmet';
+//import { Helmet } from 'react-helmet';
import axios from 'axios';
-import openSocket from 'socket.io-client';
+import socketClient from 'socket.io-client';
+import QRAddress21 from '../QRAddress21';
+import bitcoinbay from '../../images/bitcoinbay.jpeg';
-const BITBOXSDK = require("@chris.troutner/bitbox-js");
+import injectSheet from 'react-jss';
+const HDKey = require('ethereumjs-wallet/hdkey');
+const BITBOXSDK = require("@chris.troutner/bitbox-js");
// initialize BITBOX
-const BITBOX = new BITBOXSDK({ restURL: "https://trest.bitcoin.com/v2/" });
+const BITBOX = new BITBOXSDK({ restURL: "https://rest.bitcoin.com/v2/" });
+const TESTBOX = new BITBOXSDK({ restURL: "https://trest.bitcoin.com/v2/" });
+const socket = socketClient('http://192.168.1.15:3000');
+const defaultWebURL = 'https://www.meetup.com/The-Bitcoin-Bay';
+
+const styles = {
+ vertical_wrapper: {
+ height: "100vh"
+ },
+
+ crypto_header: {
+ marginLeft: "-125px",
+ marginBottom: "7px",
+ fontFamily: "Roboto, sans-serif"
+ },
+
+ fiat_header: {
+ marginLeft: "-142px",
+ marginBottom: "7px",
+ fontFamily: "Roboto, sans-serif"
+ },
+
+ crypto_currency_button: {
+ background: "#FFFFFF",
+ color: "#000000",
+ width: "70px",
+ height: "45px",
+ margin: "4px",
+ boxShadow: "0px 2px 2px rgba(0, 0, 0, 0.24), 0px 0px 2px rgba(0, 0, 0, 0.12)",
+ border: "2px solid #999999",
+ outline: "none",
+ fontFamily: "Roboto, sans-serif",
+ fontWeight: "bold"
+ },
+
+ fiat_currency_button: {
+ background: "#FFFFFF",
+ color: "#000000",
+ width: "70px",
+ height: "45px",
+ margin: "4px",
+ borderRadius: "40px",
+ boxShadow: "0px 2px 2px rgba(0, 0, 0, 0.24), 0px 0px 2px rgba(0, 0, 0, 0.12)",
+ border: "2px solid #999999",
+ outline: "none",
+ fontFamily: "Roboto, sans-serif",
+ fontWeight: "bold"
+ },
-const socket = openSocket('http://localhost:3000');
+ input_header: {
+ marginLeft: "-134px",
+ marginBottom: "7px",
+ fontFamily: "Roboto, sans-serif",
+ },
-const api_key = '897a2b25ccd5730323919dee1201a832e5d2bb9835e6ded08dd4897f7669e8f7'
-const XPubKey = "tpubDCoP9xnjhwkwC8pT7DVSPFDgbYb2uq2UAdY2DQmk2YtBpiEY8XGtT26P6NgYyc38fiuTF9x3MAtKmuUR2HPd7qKQmAYD5NTpfVy5SzZntWN";
+ amount_input: {
+ fontFamily: "Poppins, sans-serif",
+ fontSize: "32px !important",
+ fontWeight: "bold",
+ },
-export default class Cashier extends React.Component {
+ confirm_payment_button: {
+ background: "#289B00",
+ borderRadius: "30px",
+ fontFamily: "Roboto, sans-serif",
+ fontWeight: "bold",
+ fontSize: "14px",
+ padding: "15px 30px",
+// height: "50px",
+ lineHeight: "16px",
+ marginLeft: "0"
+ }
+};
+
+class Cashier extends React.Component {
constructor() {
super();
+ this.toggleBip21 = this.toggleBip21.bind(this);
this.handleClick = this.handleClick.bind(this);
+ this.newOrder = this.newOrder.bind(this);
+ this.cancelOrder = this.cancelOrder.bind(this);
this.updatePrices = this.updatePrices.bind(this);
this.calculateCryptoAmount = this.calculateCryptoAmount.bind(this);
this.sendSocketIO = this.sendSocketIO.bind(this);
- this.toggleCryptoType = this.toggleCryptoType.bind(this);
+ this.toggleCurrency = this.toggleCurrency.bind(this);
+ this.updateAmount = this.updateAmount.bind(this);
+
this.state = {
+ bip21: false,
jsonData: null,
cryptoType: 'BCH',
fiatType: 'CAD',
+ blockHeight: null,
fiatAmount: 0,
cryptoAmount: 0,
- cryptoPrice: 0
+ cryptoPrice: 0,
+ url: defaultWebURL,
+ utxo: null,
+ pos_id: null,
+ pos_name: null,
+ pos_xpub_id: null,
+ pos_xpub_array: [],
+ pos_xpub_address: null,
+ pos_xpub_index: 0,
+ index_counter: {
+ BCH: 0,
+ BTC: 0,
+ ETH: 0,
+ TSN: 0
+ },
+ pos_address: null,
+ paymentListening: 0,
+ color : "blue",
+ pos_currencies: []
}
}
- sendSocketIO(msg) {
- console.log(msg);
- socket.emit('event', msg);
+ onChange = () => {
+ this.setState({ color: 'green' });
}
componentDidMount() {
- this.updatePrices();
- setInterval(() => {
- this.updatePrices();
+ this.setState({ pos_id: this.props.location.search.substring(3) }, async () => {
+ const pos_data = {
+ pos_id: this.state.pos_id
+ };
+
+ socket.emit('add-user', pos_data);
+
+ await this.updatePrices();
+
+ axios.post("/api/get-all-pos-xpubs", pos_data).then((res) => {
+ this.setState({ pos_xpub_array: res.data.xpubs }, () => {
+ let db_currencies = [];
+ for (let i = 0; i < this.state.pos_xpub_array.length; i++) {
+ db_currencies.push(this.state.pos_xpub_array[i].type);
+ }
+
+ this.setState({ pos_currencies: db_currencies });
+
+ this.setPaymentAddress();
+ });
+ });
+ });
+
+ setInterval(async () => {
+ await this.updatePrices();
}, 600000);
}
calculateCryptoAmount() {
- let cryptoAmount = this.state.fiatAmount / this.state.cryptoPrice;
- if (this.state.cryptoPrice * cryptoAmount === this.state.fiatAmount) {
- this.setState({ cryptoAmount: cryptoAmount });
+ let cryptoAmount = this.state.fiatAmount/this.state.cryptoPrice;
+ //console.log("calculate: ", cryptoAmount)
+ if (cryptoAmount > 0) {
+ if (this.state.cryptoType === "ETH") {
+ this.setState({ cryptoAmount: cryptoAmount.toFixed(18) }, () => {
+ this.generateEthereumnAddress();
+ });
+ } else if (this.state.cryptoType === "TSN") {
+ this.setState({ cryptoAmount: 0.0001}, () => {
+ this.generateTestnetAddress();
+ });
+ }else {
+ this.setState({ cryptoAmount: cryptoAmount.toFixed(8) }, () => {
+ this.generateBitcoinAddress();
+ });
+ }
+ } else {
+ this.setState({ cryptoAmount: 0, url: defaultWebURL });
}
}
- handleClick(event) {
- let payAmount = parseFloat(event.target.value);
- console.log(payAmount);
- if (typeof payAmount !== "number" || payAmount === 0) {
+ cancelOrder() {
+ clearInterval(this.state.paymentListening);
+ this.setState({ paymentListening: 0 });
+ }
+
+ generateBitcoinAddress() {
+ let options = {
+ amount: this.state.cryptoAmount,
+ label: '#BitcoinBay',
+ };
+ let Bip21URL;
+ //console.log(this.state.pos_xpub_address, "\n", this.state.pos_xpub_index)
+ try {
+ let XPubAddress = BITBOX.Address.fromXPub(this.state.pos_xpub_address, `0/${this.state.pos_xpub_index + this.state.index_counter[this.state.cryptoType]}`);
+ if (this.state.cryptoType === "BTC") {
+ XPubAddress = BITBOX.Address.toLegacyAddress(XPubAddress);
+ }
+ if (this.state.bip21 === true) {
+ Bip21URL = BITBOX.BitcoinCash.encodeBIP21(XPubAddress, options);
+ this.setState({ url: Bip21URL, pos_address: XPubAddress });
+ } else {
+ this.setState({ url: XPubAddress, pos_address: XPubAddress });
+ }
+ } catch {
+ return;
+ }
+ }
+
+ generateEthereumnAddress() {
+ try {
+ let fromXPub = HDKey.fromExtendedKey(this.state.pos_xpub_address);
+ //console.log(XPubAddress);
+ let paymentAddress = fromXPub.deriveChild(`${this.state.pos_xpub_index + this.state.index_counter[this.state.cryptoType]}`).getWallet().getAddressString();
+ this.setState({ url: paymentAddress, pos_address: paymentAddress });
+ } catch {
+ return;
+ }
+ }
+
+ generateTestnetAddress() {
+ let options = {
+ amount: 0.0001,
+ label: '#BitcoinBay',
+ };
+
+ let XPubAddress = TESTBOX.Address.fromXPub(this.state.pos_xpub_address, `0/${this.state.pos_xpub_index + this.state.index_counter[this.state.cryptoType]}`);
+
+ let Bip21URL = TESTBOX.BitcoinCash.encodeBIP21(XPubAddress, options);
+ this.setState({ url: Bip21URL, pos_address: XPubAddress });
+ }
+
+ handleClick(e) {
+ try {
+ let payAmount = parseFloat(e.target.value);
+ if (typeof payAmount !== "number" || payAmount === 0 || isNaN(payAmount)) {
+ this.setState({ fiatAmount: 0 }, async() => {
+ await this.calculateCryptoAmount();
+ });
+ } else {
+ this.setState({ fiatAmount: payAmount }, async() => {
+ await this.calculateCryptoAmount();
+ });
+ }
+ } catch (err) {
this.setState({ fiatAmount: 0 }, async() => {
await this.calculateCryptoAmount();
});
}
- this.setState({ fiatAmount: payAmount }, async() => {
- await this.calculateCryptoAmount();
+ }
+
+ newOrder() {
+ clearInterval(this.state.paymentListening);
+ this.setState({ cryptoType: 'BCH', fiatType: 'CAD', fiatAmount: 0, cryptoAmount: 0, url: defaultWebURL, paymentListening: 0, pos_address: null }, () => {
+ socket.emit('event', ['BCH', 'CAD', 0, 0, 0, this.state.url, false]);
});
}
- sendSocketIO(msg) {
- console.log(msg);
- socket.emit('event', msg);
+ setPaymentAddress() {
+ let xpub_array = this.state.pos_xpub_array;
+ for (let i = 0; i < this.state.pos_xpub_array.length; i++) {
+ if (this.state.pos_xpub_array[i].type === this.state.cryptoType) {
+ this.setState({ pos_xpub_address: xpub_array[i].address, pos_xpub_index: xpub_array[i].address_index});
+ }
+ }
}
- toggleCryptoType(e) {
- console.log(e.target.value);
- const jsonData = this.state.jsonData;
+ toggleAddressIndex(e) {
+ const { index_counter } = { ...this.state };
+// console.log("index counter: ", index_counter);
+// console.log("event.target: ", e.target.value);
+ let currentCrypto = index_counter;
+ let value = parseInt(e.target.value);
+ if (isNaN(value)) {
+ value = 0;
+ }
- if (e.target.value === 'BTC' && e.target.value === 'CAD') {
- this.setState({ cryptoType: 'BTC', cryptoPrice: jsonData.BTC.CAD}, async() => {
- await this.calculateCryptoAmount();
- });
+ currentCrypto[this.state.cryptoType] = value;
+// console.log("Toggle: ", currentCrypto);
+
+ try {
+ this.setState({ index_counter: currentCrypto }, () => {
+ this.calculateCryptoAmount();
+ });
+ } catch (err) {
+ console.log(err);
+ return;
}
+ }
- if (e.target.value === 'BCH' && e.target.value === 'CAD') {
- this.setState({ cryptoType: 'BCH', cryptoPrice: jsonData.BCH.CAD}, async() => {
- await this.calculateCryptoAmount();
- });
+ toggleBip21() {
+ if (this.state.bip21 === true) {
+ this.setState({ bip21: false });
+ } else {
+ this.setState({ bip21: true });
}
- if (e.target.value === 'BCH' && e.target.value === 'CAD') {
- this.setState({ cryptoType: 'ETH', cryptoPrice: jsonData.ETH.CAD}, async() => {
- await this.calculateCryptoAmount();
+ }
+
+ toggleCurrency(e) {
+ const jsonData = this.state.jsonData;
+
+ e.persist();
+
+ if (e.target.value === "BTC" || e.target.value === "BCH" || e.target.value === "ETH") {
+ this.setState({ cryptoType: e.target.value, cryptoPrice: jsonData[e.target.value][this.state.fiatType]}, () => {
+ this.setPaymentAddress();
+
+ let crypto_currency_buttons = document.getElementById("crypto_currency_buttons");
+ for (let i = 1; i < crypto_currency_buttons.children.length; i++) {
+ crypto_currency_buttons.children[i].style.background = "#FFFFFF";
+ crypto_currency_buttons.children[i].style.color = "#000000";
+ }
+ e.target.style.background = "#00A3FF";
+ e.target.style.color = "#FFFFFF";
+
+ let fiat_currency_buttons = document.getElementById("fiat_currency_buttons");
+ for (let i = 1; i < fiat_currency_buttons.children.length; i++) {
+ fiat_currency_buttons.children[i].disabled = false;
+ }
+
+ this.calculateCryptoAmount();
+ });
+ } else if (e.target.value === "TSN") {
+ this.setState({ cryptoType: e.target.value, cryptoPrice: 1}, () => {
+ this.setPaymentAddress();
+
+ let crypto_currency_buttons = document.getElementById("crypto_currency_buttons");
+ for (let i = 1; i < crypto_currency_buttons.children.length; i++) {
+ crypto_currency_buttons.children[i].style.background = "#FFFFFF";
+ crypto_currency_buttons.children[i].style.color = "#000000";
+ }
+ e.target.style.background = "#00A3FF";
+ e.target.style.color = "#FFFFFF";
+
+ let fiat_currency_buttons = document.getElementById("fiat_currency_buttons");
+ for (let i = 1; i < fiat_currency_buttons.children.length; i++) {
+ fiat_currency_buttons.children[i].disabled = false;
+ }
+
+ this.calculateCryptoAmount();
+ })
+ } else if (e.target.value === "USD" || e.target.value === "CAD" || e.target.value === "EUR") {
+ if (this.state.cryptoType !== "TSN") {
+ this.setState({ fiatType: e.target.value, cryptoPrice: jsonData[this.state.cryptoType][e.target.value]}, () => {
+ let fiat_currency_buttons = document.getElementById("fiat_currency_buttons");
+ for (let i = 1; i < fiat_currency_buttons.children.length; i++) {
+ fiat_currency_buttons.children[i].style.background = "#FFFFFF";
+ fiat_currency_buttons.children[i].style.color = "#000000";
+ }
+ e.target.style.background = "#00A3FF";
+ e.target.style.color = "#FFFFFF";
+
+ if (this.state.fiatType === "CAD" || this.state.fiatType === "USD") {
+ this.setState({ payment_amount_input_value: "$" });
+ } else if (this.state.fiatType === "EUR") {
+ this.setState({ payment_amount_input_value: "€" });
+ }
+
+ this.calculateCryptoAmount();
});
+ } else {
+ return;
+ }
+ }
+ }
+
+ updateAmount(event) {
+ let amount_string;
+
+ if (event.target.value.length === 1 && event.target.value.match("^[0-9]")) {
+ amount_string = event.target.value;
+ } else {
+ amount_string = event.target.value.substring(1);
}
+
+ this.setState({ payment_amount: amount_string }, (event) => {
+ let currency_character;
+ if (this.state.fiatType === "CAD" || this.state.fiatType === "USD") {
+ currency_character = "$";
+ } else if (this.state.fiatType === "EUR") {
+ currency_character = "€"
+ }
+
+ this.setState({ payment_amount_input_value: currency_character + this.state.payment_amount });
+ });
}
- updatePrices() {
- axios.get(`https://min-api.cryptocompare.com/data/pricemulti?fsyms=BCH,BTC,ETH&tsyms=USD,EUR,CAD&api_key={${api_key}}`)
- .then((res) => {
- this.setState({ jsonData: res.data });
+ // updateXPubIndex is currently not in usage
+ updateXPubIndex() {
+ let indexTotal = this.state.pos_xpub_index + this.state.index_counter[this.state.cryptoType];
+
+ const pos_data = {
+ id: this.state.pos_xpub_id,
+ address_index: indexTotal
+ };
+
+ axios.post("/api/update-xpub-index", pos_data)
+ .then((res) => {
+ // console.log(res);
+ }).catch((err) => {
+ // console.log(err);
+ });
+ }
+
+ async sendSocketIO(msg) {
+ console.log("Socket: ", msg);
+ socket.emit('event', msg);
+ await this.updateBlockHeight();
+ let listen = setInterval(() => {
+ axios
+ .get(`/api/balance${this.state.cryptoType}/${this.state.pos_address}`)
+ .then((res) => {
+ console.log(res.data.utxo.length);
+ if (res.data.utxo.length !== 0) {
+ for (let i = 0; i < res.data.utxo.length; i++) {
+ // if (res.data.utxo[i].confirmations === 0) {
+ if (this.state.cryptoType === 'BCH' || this.state.cryptoType === 'TSN') {
+ this.setState({ utxo: res.data.utxo[0].txid}, () => {
+ console.log(this.state.utxo);
+
+ const transaction_data = {
+ pos_id: this.state.pos_id,
+ block_number: res.data.utxo[0].blockNumber,
+ hash: res.data.utxo[0].txid,
+ amount: res.data.utxo[0].amount,
+ crypto_currency: this.state.cryptoType,
+ fiat_currency: this.state.fiatType,
+ market_price: this.state.cryptoPrice
+ };
+
+ console.log(transaction_data);
+
+ axios.post("/api/add-transaction", transaction_data).then((res) => {
+ this.props.history.push("/transactions");
+ })
+ }) ;
+ } else {
+ this.setState({ utxo: res.data.utxo[0].hash}, () => {
+ console.log(this.state.utxo);
+
+ const transaction_data = {
+ pos_id: this.state.pos_id,
+ hash: res.data.utxo[0].hash,
+ amount: res.data.utxo[0].value,
+ crypto_currency: this.state.cryptoType,
+ fiat_currency: this.state.fiatType,
+ market_price: this.state.cryptoPrice
+ };
+
+ axios.post("/api/add-transaction", transaction_data).then((res) => {
+ this.props.history.push({pathname: "/transactions", search: '?p=' + this.state.pos_id});
+ })
+ }) ;
+ }
+
+ clearInterval(listen);
+ // } else {
+ // console.log(`Transaction Confirmations: ${res.data.utxo[i].confirmations}`)
+ // }
+ }
+ } else {
+ return;
+ }
+ })
+ .catch((err) => {
+ console.log(err);
+ return;
+ })}
+ , 10000);
+ this.setState({ paymentListening: listen });
+ }
+
+ async updateBlockHeight() {
+ axios
+ .get('/api/blockHeight')
+ .then(res => {
+ this.setState({ blockHeight: res.data });
+ });
+ }
+
+ async updatePrices() {
+ await axios
+ .get('/api/datafeed')
+ .then(res => {
+ this.setState({ jsonData: res.data.status }, () => {
+// console.log(this.state.jsonData);
+ if (this.state.cryptoType === "TSN") {
+ this.setState({ cryptoPrice: 0.0001});
+ } else if (this.state.cryptoType === "BTC" || this.state.cryptoType === "BCH" || this.state.cryptoType === "ETH") {
+ this.setState({ cryptoPrice: res.data.status[this.state.cryptoType][this.state.fiatType]});
+ this.calculateCryptoAmount();
+ }
+ });
+ })
+ .catch(err => {
+ console.log(err);
+ return;
});
+ await this.updateBlockHeight();
}
render() {
+ const { classes } = this.props;
return(
-
-
- Cashier Page
-
-
-
-
Choose payment Option
-
-
-
-
-
-
-
-
-
-
-
{this.handleClick(e)}} defaultValue={1} />
-
-
-
$ {this.state.cryptoPrice} {this.state.fiatType} / {this.state.cryptoType}
-
{this.state.cryptoAmount} {this.state.cryptoType}
-
$ {this.state.fiatAmount} {this.state.fiatType}
-
-
+
+
+ { this.state.paymentListening === 0
+ ? (
+
+
+
+
+
+
+
Amount {this.state.fiatType !== '' ? "(" + this.state.fiatType + ")" : ""}
+
{ this.handleClick(e) }} />
+
+
+
+
+
+ )
+ :
+ { this.state.url === defaultWebURL
+ ? (
+
+
+
+ )
+ : (
+
+
+
+ )
+ }
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
);
}
}
+
+export default injectSheet(styles)(Cashier);
diff --git a/src/components/layout/Customer.js b/src/components/layout/Customer.js
index 2b52150..8649172 100644
--- a/src/components/layout/Customer.js
+++ b/src/components/layout/Customer.js
@@ -1,52 +1,55 @@
import React from 'react';
import { Helmet } from 'react-helmet';
-import openSocket from 'socket.io-client';
-import './styles/customer.css'
-import QRAddress21 from './../QRAddress21';
-import { Dropdown } from 'semantic-ui-react'
-import { Link } from 'react-router-dom';
-import PaymentSucess from './PaymentSucess';
-// var QRCode = require('qrcode.react');
+import socketClient from 'socket.io-client';
+import QRAddress21 from '../QRAddress21';
+import bitcoinbay from '../../images/bitcoinbay.jpeg';
-//import * as BITBOXCli from "bitbox-sdk";
+const socket = socketClient('http://192.168.1.15:3000');
+// const socket = socketClient('http://localhost:5000');
-// initialize BITBOX
-//const BITBOX = new BITBOXCli.default({ restURL: "https://trest.bitcoin.com/v2/" });
-
-const socket = openSocket('http://localhost:3000');
const defaultWebURL = 'https://www.meetup.com/The-Bitcoin-Bay';
-
-const options = [
- { key: 1, text: 'CAD', value: 1 },
- { key: 2, text: 'BCH', value: 2 },
-
-]
-
const styleLink = document.createElement("link");
styleLink.rel = "stylesheet";
styleLink.href = "https://cdn.jsdelivr.net/npm/semantic-ui/dist/semantic.min.css";
document.head.appendChild(styleLink);
export default class Customer extends React.Component {
-
-
constructor() {
super();
+ this.handleClick = this.handleClick.bind(this);
this.state = {
- // value: '45.98',
- // url: defaultWebURL,
cryptoType: 'BCH',
fiatType: 'CAD',
cryptoAmount: 0,
fiatAmount:0,
- cryptoPrice: 40.30,
+ cryptoPrice: 0,
url: defaultWebURL,
-
- }
+ isToggleuPaid: true,
+ isPayment: false,
+ pos_id: null
+ }
+ }
+
+ handleClick() {
+ this.setState(function(prevState) {
+ return {isToggleuPaid: !prevState.isToggleuPaid};
+ });
}
+
componentDidMount() {
+ this.setState({ pos_id: this.props.location.query }, () => {
+ const pos_data = {
+ pos_id: this.state.pos_id
+ };
+
+ console.log(pos_data);
+
+ socket.emit('add-user', pos_data);
+ });
+
socket.on('event', msg => this.update(msg));
}
+
update(data) {
console.log(data);
this.setState({
@@ -56,79 +59,39 @@ export default class Customer extends React.Component {
fiatAmount: data[3],
cryptoPrice: data[4],
url: data[5],
+ isPayment: data[6]
}, () => console.log(this.state));
}
+
render() {
return (
-
- Customer Page
-
-
-
-
-
-
-
- {/*
- Login into cashier page is {" "}
- successful. Made by Bitcoin Bay
-
*/}
- {/*
*/}
-
Please Send Your 0.3143hBCH To This Address
-
-
- Customer POS Page
-
-
-
- { this.state.url === ''
- ?
- : (
-
-
-
- )
- }
-
- $ {this.state.cryptoPrice} {this.state.fiatType} / {this.state.cryptoType}
-
- {this.state.cryptoAmount} {this.state.cryptoType}
- $ {this.state.fiatAmount} {this.state.fiatType}
-
-
-
-
-
+
+
+
+ Customer POS Page
+
+
+ { this.state.isPayment === false
+ ?
+
Bitcoin Bay Point of Sales
+

+
+ : (
+
+
+ Please Send Your {this.state.cryptoAmount} {this.state.cryptoType} To The Following Address
+
+
+ $ {this.state.fiatAmount} {this.state.fiatType}
+ @ $ {this.state.cryptoPrice} {this.state.fiatType} / {this.state.cryptoType}
+
+ )
+ }
+
+