diff --git a/package-lock.json b/package-lock.json index e16f5c2..338ebef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6433,11 +6433,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -6454,7 +6456,8 @@ }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", @@ -6561,7 +6564,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -6583,6 +6587,7 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } diff --git a/src/common/pages/App/index.js b/src/common/pages/App/index.js index 16e4369..5170c46 100644 --- a/src/common/pages/App/index.js +++ b/src/common/pages/App/index.js @@ -157,7 +157,11 @@ export default class App extends React.Component { componentDidMount() { // this.checkIsLogin(); // this.settingStore.getAll(); - // this.authStore.getProfile(); + this.authStore.getProfile(); + + setTimeout(() => { + console.log(this.authStore.userProfile, 'this.authStore.userProfile this.authStore.userProfile'); + }, 2500) // this.user.getUserGeolocation(); // this.appStore.getAppType(); // this.profileStore.getProfile(); diff --git a/src/common/pages/Dashboard/index.js b/src/common/pages/Dashboard/index.js index 62531c7..e108610 100644 --- a/src/common/pages/Dashboard/index.js +++ b/src/common/pages/Dashboard/index.js @@ -103,7 +103,9 @@ export default class DashboardComponent extends React.Component { const data = [ { name: 'KFC', - image: 'https://ecs7.tokopedia.net/img/recharge/operator/kfc-box_150px_74px.png', + images: { + logo: 'https://ecs7.tokopedia.net/img/recharge/operator/kfc-box_150px_74px.png' + }, description: 'KFC merupakan restoran cepat saji yang menyediakan ayam goreng serta berbagai menu pilihan lainnya seperti burger, sup, dan salad. Dengan rasa yang renyah dan gurih, siapa pun dijamin ketagihan dengan ayam goreng yang satu ini.', additional_information: 'Voucher ini berlaku hingga 29 hari setelah pembelian.', background_color: 'linear-gradient(rgb(214, 18, 53), rgb(100, 23, 24))', @@ -128,7 +130,9 @@ export default class DashboardComponent extends React.Component { }, { name: 'Grab', - image: 'https://ecs7.tokopedia.net/img/recharge/operator/grab_150px_74px.png', + images: { + logo: 'https://ecs7.tokopedia.net/img/recharge/operator/grab_150px_74px.png' + }, description: 'Grab adalah platform transportasi terkemuka di Asia Tenggara. Kami percaya setiap orang harus bisa pergi ke mana saja dan percaya bahwa mereka dapat memesan perjalanan yang aman.', additional_information: 'Voucher ini berlaku hingga 28 Februari 2019. Voucher ini hanya bisa digunakan untuk layanan GrabCar, GrabBike, dan GrabExpress. ', background_color: 'linear-gradient(rgb(0, 174, 66), rgb(0, 93, 36))', @@ -153,7 +157,9 @@ export default class DashboardComponent extends React.Component { }, { name: 'OYO Hotel', - image: 'https://ecs7.tokopedia.net/img/recharge/operator/oyo_150px_74px.png', + images: { + logo: 'https://ecs7.tokopedia.net/img/recharge/operator/oyo_150px_74px.png' + }, description: 'OYO Hotel adalah jaringan hotel terbesar di Asia Selatan dan terdapat di 11 negara dengan lebih dari 12,000 hotel tersebar di seluruh dunia.', additional_information: 'Voucher ini berlaku hingga 31 Januari 2019.', background_color: 'linear-gradient(rgb(253, 234, 225), rgb(255, 138, 98))', @@ -166,7 +172,9 @@ export default class DashboardComponent extends React.Component { }, { name: 'Carrefour', - image: 'https://ecs7.tokopedia.net/img/recharge/operator/carrefour_150px_74px.png', + images: { + logo: 'https://ecs7.tokopedia.net/img/recharge/operator/carrefour_150px_74px.png' + }, description: 'Carrefour membantu semua orang agar dapat menikmati kualitas hidup yang lebih baik setiap harinya. Menyediakan berbagai kebutuhan harian sekaligus bulanan, sebagai tujuan utama berbelanja keluarga dengan memberikan pelayanan dan produk berkualitas dimanapun dan kapanpun.', additional_information: 'Voucher ini berlaku hingga 29 hari setelah pembelian.', background_color: 'linear-gradient(rgb(236, 249, 250), rgb(73, 176, 228))', @@ -183,7 +191,9 @@ export default class DashboardComponent extends React.Component { }, { name: "Domino's Pizza", - image: 'https://ecs7.tokopedia.net/img/recharge/operator/dominos_150px_74px.png', + images: { + logo: 'https://ecs7.tokopedia.net/img/recharge/operator/dominos_150px_74px.png' + }, description: "Domino's Pizza adalah pemimpin Pizza delivery di dunia. Dengan 130 toko yang tersebar di Jabodetabek, Bali, Bandung, Serang, dan Sukabumi, Domino’s menyajikan pizza paling lezat dengan harga terbaik untuk jutaan pelanggan. Domino’s juga mengantarkan pizza hangat dengan jaminan 30 menit sampai.", additional_information: "Voucher ini berlaku hingga 29 hari setelah pembelian", background_color: 'linear-gradient(rgb(11, 110, 174), rgb(2, 61, 96))', @@ -200,7 +210,9 @@ export default class DashboardComponent extends React.Component { }, { name: 'Timezone', - image: 'https://ecs7.tokopedia.net/img/recharge/operator/new-timezone_150px_74px.png', + images: { + logo: 'https://ecs7.tokopedia.net/img/recharge/operator/new-timezone_150px_74px.png', + }, description: 'Timezone merupakan tempat permainan semua keluarga di Indonesia. Beragam permainan menarik yang disediakan untuk memberikan pengalaman yang menyenangkan bagi setiap pengunjung. Selain permainan – permainan yang cukup menarik dan sensasi berbeda, pengunjung yang hadir ke Timezone juga berkesempatan mendapatkan hadiah-hadiah menarik dari mesin-mesin yang dimainkan ataupun souvenir, boneka dari tiket yang ditukarkan', additional_information: 'Voucher ini berlaku hingga 29 hari setelah pembelian.', background_color: 'linear-gradient(rgb(255, 118, 90), rgb(255, 40, 12))', @@ -217,7 +229,9 @@ export default class DashboardComponent extends React.Component { }, { name: 'Bakmi GM', - image: 'https://ecs7.tokopedia.net/img/recharge/operator/bakmigm_150px_74px.png', + images: { + logo: 'https://ecs7.tokopedia.net/img/recharge/operator/bakmigm_150px_74px.png' + }, description: 'BAKMI GM dirancang khusus untuk memberikan rasa yang lezat, yang dibuat dari bahan baku pilihan dan disajikan dengan harga yang ekonomis. Tersedia lebih dari 50 menu yang dapat dipilih oleh pelanggan, dengan menu Bakmi Special GM dan Pangsit Goreng yang menjadi favorit pelanggan.', additional_information: 'Voucher ini berlaku hingga 11 Januari 2019.', background_color: 'linear-gradient(rgb(254, 239, 73), rgb(241, 186, 54))', @@ -234,7 +248,9 @@ export default class DashboardComponent extends React.Component { }, { name: 'CFC', - image: 'https://ecs7.tokopedia.net/img/recharge/operator/cfc_150px_74px.png', + images: { + logo: 'https://ecs7.tokopedia.net/img/recharge/operator/cfc_150px_74px.png' + }, description: 'CFC merupakan salah satu brand fast food yang tersebar di berbagai daerah di Indonesia. CFC menyediakan berbagai menu makanan dan minuman yang praktis dan bervariasi sesuai dengan selera keluarga Indonesia. Mulai dari berbagai menu berbahan dasar ayam seperti : Crispy Fried Chicken, Chicken Strips, Chicken Pop, Chicken Burger, Ayam Geprek, hingga Nasi Goreng, Spaghetti, Ice blended, Calblend Float, dan masih banyak lagi.', additional_information: 'Voucher ini berlaku hingga 29 hari setelah pembelian. Maksimal penggunaan 3 e-Voucher dalam 1 kali transaksi', background_color: 'linear-gradient(rgb(255, 255, 255), rgb(192, 192, 192))', @@ -315,13 +331,13 @@ export default class DashboardComponent extends React.Component { })} - this.setState({isOpened: false})} - onCancel={() => this.setState({isOpened: false})} - /> + {/* this.setState({isOpened: false})}*/} + {/*onCancel={() => this.setState({isOpened: false})}*/} + {/*/>*/} diff --git a/src/common/pages/Login/index.js b/src/common/pages/Login/index.js index dfe17ee..00391d0 100644 --- a/src/common/pages/Login/index.js +++ b/src/common/pages/Login/index.js @@ -12,16 +12,31 @@ export default class LoginComponent extends React.Component { super(props); this.props = props; this.state = { - email: "", + username: "", password: "", }; this.defaultState = Object.assign({}, this.state); + this.authStore = props.appstate.auth; } componentDidMount() { } + login = () => { + const username = this.state.username; + const password = this.state.password; + const data = { + username: username, + password: password, + } + this.authStore.login(data).then(res => { + this.props.history.push(LINKS.DASHBOARD); + }).catch(err => { + alert(err.message); + }); + }; + render() { return ( @@ -35,15 +50,17 @@ export default class LoginComponent extends React.Component { this.setState({username: e.target.value})} /> this.setState({password: e.target.value})} type="password" /> - diff --git a/src/common/pages/Vouchers/ItemCard/index.js b/src/common/pages/Vouchers/ItemCard/index.js index d9c26c3..0fd52e6 100644 --- a/src/common/pages/Vouchers/ItemCard/index.js +++ b/src/common/pages/Vouchers/ItemCard/index.js @@ -28,10 +28,16 @@ export class ItemCard extends React.Component { render() { const {data = {}} = this.props; + let image = '' + if(data.images.logo.includes('http')){ + image = data.images.logo; + }else{ + image = this.http.appendImagePath(data.images.logo); + } return ( - +

{data.name}

) diff --git a/src/common/pages/Vouchers/Modal/index.js b/src/common/pages/Vouchers/Modal/index.js index 793e13c..027720a 100644 --- a/src/common/pages/Vouchers/Modal/index.js +++ b/src/common/pages/Vouchers/Modal/index.js @@ -24,7 +24,13 @@ export default class ModalVouchersComponent extends React.Component { componentDidMount() {} render() { - const {data, isVisible = false, onOk = () => {}, onCancel = () => {}, title='Modal'} = this.props; + const {data = {}, isVisible = false, onOk = () => {}, onCancel = () => {}, title='Modal'} = this.props; + let image = '' + if(data.images.logo.includes('http')){ + image = data.images.logo; + }else{ + image = this.http.appendImagePath(data.images.logo); + } return ( - +

{data.name} }

diff --git a/src/common/pages/Wallet/index.js b/src/common/pages/Wallet/index.js index 5471c88..510ccaa 100644 --- a/src/common/pages/Wallet/index.js +++ b/src/common/pages/Wallet/index.js @@ -49,9 +49,13 @@ export default class WalletComponent extends React.Component { }; this.defaultState = Object.assign({}, this.state); this.http = props.appstate.http; + this.purchasedItemStore = props.appstate.purchased_items; } componentDidMount() { + this.purchasedItemStore.getAll().then(res => { + console.log(res, 'ini purchased items') + }) // this.globalUI.openLoading(); // this.transactionStore.getAll().then(res => { // this.globalUI.closeLoading(); diff --git a/src/common/routes.js b/src/common/routes.js index 1a35055..22350b7 100644 --- a/src/common/routes.js +++ b/src/common/routes.js @@ -152,7 +152,7 @@ export default class Routes extends React.Component { ()}/> diff --git a/src/common/stores/appstate.js b/src/common/stores/appstate.js index 37f1db2..08cc0a5 100644 --- a/src/common/stores/appstate.js +++ b/src/common/stores/appstate.js @@ -57,6 +57,7 @@ import Surf from './surf'; import Odoo from './odoo'; import Vouchers from './vouchers'; +import {PurchasedItemStore} from "./purchased_item"; export default class AppState { http = new Http(this.token); @@ -115,7 +116,7 @@ export default class AppState { notification = new Notification(this); tags = new Tags(this); surf_turf = new Surf(this); - + purchased_items = new PurchasedItemStore(this); constructor(initialState) { this.token = initialState.token; diff --git a/src/common/stores/authenticaton.js b/src/common/stores/authenticaton.js index 94fa013..de6f12c 100644 --- a/src/common/stores/authenticaton.js +++ b/src/common/stores/authenticaton.js @@ -71,29 +71,31 @@ export class Authentication { @action logout() { - return this.http.post("authentication/logout", {token : localStorage.getItem('tokens')}) - .then(res => { - this.context.setToken(""); - this.context.setUserData({}); - - localStorage.removeItem('id_token'); - localStorage.removeItem('user.name'); - localStorage.removeItem('user.profile_image'); - localStorage.setItem('isLoggingIn', false); - let cookies = document.cookie.split(";"); - for (let i = 0; i < cookies.length; i++) { - this.eraseCookie(cookies[i].split("=")[0]); - } - - if (window && window.Tawk_API && window.Tawk_API.isChatHidden()) { - window.Tawk_API.hideWidget() - } - - return res; - }) - .catch(err => { - throw err; - }) + this.context.setToken(""); + this.context.setUserData({}); + // return this.http.post("authentication/logout", {token : localStorage.getItem('tokens')}) + // .then(res => { + // this.context.setToken(""); + // this.context.setUserData({}); + // + // localStorage.removeItem('id_token'); + // localStorage.removeItem('user.name'); + // localStorage.removeItem('user.profile_image'); + // localStorage.setItem('isLoggingIn', false); + // let cookies = document.cookie.split(";"); + // for (let i = 0; i < cookies.length; i++) { + // this.eraseCookie(cookies[i].split("=")[0]); + // } + // + // if (window && window.Tawk_API && window.Tawk_API.isChatHidden()) { + // window.Tawk_API.hideWidget() + // } + // + // return res; + // }) + // .catch(err => { + // throw err; + // }) } @@ -248,6 +250,7 @@ export class Authentication { @computed get isLoggedIn() { + // alert(!!(this.context.token)); return !!(this.context.token); } diff --git a/src/common/stores/purchased_item.js b/src/common/stores/purchased_item.js new file mode 100644 index 0000000..8d9840f --- /dev/null +++ b/src/common/stores/purchased_item.js @@ -0,0 +1,11 @@ +import { BaseStore } from "./base_store"; +import {observable, action} from "mobx/lib/mobx"; + +export class PurchasedItemStore extends BaseStore { + + constructor(context) { + super(context); + this.url = "purchased_items"; + } + +}