From 21c56ad40feb17a6b7d4d335e217344d19c16cd1 Mon Sep 17 00:00:00 2001 From: enggar_ganteng Date: Sun, 6 Jan 2019 18:10:57 +0700 Subject: [PATCH] ini lah vouchers sesungguhnya --- src/common/pages/Vouchers/Checkout/index.js | 19 ++++++---- src/common/pages/Vouchers/Modal/index.js | 39 +++++++++++++++------ src/common/pages/Vouchers/Payment/index.js | 33 ++++++++++++----- src/common/pages/Vouchers/index.js | 1 + src/common/stores/vouchers.js | 20 ++++++++--- 5 files changed, 83 insertions(+), 29 deletions(-) diff --git a/src/common/pages/Vouchers/Checkout/index.js b/src/common/pages/Vouchers/Checkout/index.js index 2b58dda..96ebeaa 100644 --- a/src/common/pages/Vouchers/Checkout/index.js +++ b/src/common/pages/Vouchers/Checkout/index.js @@ -28,10 +28,14 @@ export default class CheckoutVouchers extends React.Component { this.http = props.appstate.http; this.authStore = props.appstate.auth; this.globalUI = props.appstate.globalUI; + this.vouchersStore = props.appstate.vouchers; } componentDidMount() { - + console.log("skuid",this.vouchersStore.skuId); + console.log("skuName",this.vouchersStore.skuName); + console.log("skuPrice",this.vouchersStore.skuPrice); + console.log("data",this.vouchersStore.dataItems); } render() { @@ -68,19 +72,20 @@ export default class CheckoutVouchers extends React.Component {
-
+
- + + {/* */}
-
+

Jenis Layanan :

-

KFC Rp.50.000,00

+

{this.vouchersStore.dataItems.name} {this.vouchersStore.skuName}

@@ -88,7 +93,7 @@ export default class CheckoutVouchers extends React.Component {

Point :

-

50 Points

+

{this.vouchersStore.skuPrice} Points

@@ -108,7 +113,7 @@ export default class CheckoutVouchers extends React.Component {

Total Pembayaran Point

-

50 Points

+

{this.vouchersStore.skuPrice} Points

diff --git a/src/common/pages/Vouchers/Modal/index.js b/src/common/pages/Vouchers/Modal/index.js index c7f0230..e29108e 100644 --- a/src/common/pages/Vouchers/Modal/index.js +++ b/src/common/pages/Vouchers/Modal/index.js @@ -15,11 +15,14 @@ export default class ModalVouchersComponent extends React.Component { super(props); this.props = props; this.state = { - selectedOption: '0', - hidden:'inline' + selectedOption: '', + hidden:'inline', + skuName:'', + skuPrice:'0' }; this.defaultState = Object.assign({}, this.state); this.http = props.appstate.http; + this.vouchersStore = props.appstate.vouchers; } componentDidMount() {} @@ -60,7 +63,7 @@ export default class ModalVouchersComponent extends React.Component { flex: 0.3 }}> -

{data.name} }

+

{data.name}

{ - this.setState({selectedOption: e}) + onChange={(value) => { + this.setState({selectedOption: value}) this.setState({hidden: 'none'}) - console.log(this.state.hidden,'onChange') + // console.log('onChange',value); + const points = data.sku.filter(item => item.id == value); + console.log(points[0].price,'points',points[0].name); + this.setState({ + skuName :points[0].name, + skuPrice : points[0].price + }) } } onDropdownVisibleChange={(value) => { this.setState({hidden: 'inline'}) - console.log(this.state.hidden,'onDropdownVisibleChange') }} > {data.sku.map((item, index) => { - return + return + // return })}

Points

-

+

( - + )} />
diff --git a/src/common/pages/Vouchers/Payment/index.js b/src/common/pages/Vouchers/Payment/index.js index 8388a56..a382fcd 100644 --- a/src/common/pages/Vouchers/Payment/index.js +++ b/src/common/pages/Vouchers/Payment/index.js @@ -29,6 +29,7 @@ export default class PaymentVouchers extends React.Component { this.http = props.appstate.http; this.authStore = props.appstate.auth; this.globalUI = props.appstate.globalUI; + this.vouchersStore = props.appstate.vouchers; } componentDidMount() { @@ -45,6 +46,10 @@ export default class PaymentVouchers extends React.Component { }); }; + const price = this.vouchersStore.skuPrice; + const qty = 1; + const total = price * qty; + return (
@@ -67,7 +72,7 @@ export default class PaymentVouchers extends React.Component {

- 50 Points + {price} Points

Detail Tagihan @@ -76,21 +81,21 @@ export default class PaymentVouchers extends React.Component { } key="1">
-

KFC - Rp. 50,000

-

50 Points

+

{this.vouchersStore.dataItems.name} - {this.vouchersStore.skuName}

+

{price} Points

-

1 x Rp. 50 Points

-

50 Points

+

{qty} x {price} Points

+

{total} Points

Tagihan

-

50 Points

+

{total} Points

@@ -120,8 +125,20 @@ export default class PaymentVouchers extends React.Component {

diff --git a/src/common/pages/Vouchers/index.js b/src/common/pages/Vouchers/index.js index f44c3b7..e242667 100644 --- a/src/common/pages/Vouchers/index.js +++ b/src/common/pages/Vouchers/index.js @@ -36,6 +36,7 @@ export default class VouchersComponent extends React.Component { // ], sku: [ { + id:'', name: '', price: '' }, diff --git a/src/common/stores/vouchers.js b/src/common/stores/vouchers.js index ba63d59..7b8bf2a 100644 --- a/src/common/stores/vouchers.js +++ b/src/common/stores/vouchers.js @@ -7,6 +7,15 @@ export default class Vouchers { @observable istLoading = false; @observable isSearching = false; @observable filtered = []; + @observable skuId = {} ; + @observable skuName = {} ; + @observable skuPrice = {} ; + @observable dataItems = { + name :'', + images : { + logo: '' + } + } ; constructor(context) { this.http = context.http; @@ -19,7 +28,6 @@ export default class Vouchers { this.isLoading = true; return this.http.get("items") .then(res => { - console.log(res.data,'res list') this.list = res.data; this.isLoading = false; }) @@ -44,12 +52,16 @@ export default class Vouchers { } @action - post(data){ + buyVoucher(data){ + console.log('data',data) this.isLoading = true; - return this.http.post("stores", data) - .then(res => { + return this.http.post("shop/buy_voucher", { + item_sku_id : data + } + ).then(res => { this.isLoading = false; this.getList(); + console.log('res',res) return res; }) .catch(err => {