Merge branch 'master' of gitlab.com:asacreative/redemption-point/new-frontend-customer-redemption-point

This commit is contained in:
enggar_ganteng 2019-01-06 15:43:50 +07:00
commit 6572d4609e
12 changed files with 122 additions and 195 deletions

11
package-lock.json generated
View File

@ -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"
}

View File

@ -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();

View File

@ -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, Dominos menyajikan pizza paling lezat dengan harga terbaik untuk jutaan pelanggan. Dominos 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 {
})}
</Row>
<ModalVouchersComponent
title={this.state.data.name+' Vouchers'}
data={this.state.data}
isVisible={this.state.isOpened}
onOk={() => this.setState({isOpened: false})}
onCancel={() => this.setState({isOpened: false})}
/>
{/*<ModalVouchersComponent*/}
{/*title={this.state.data.name+' Vouchers'}*/}
{/*data={this.state.data}*/}
{/*isVisible={this.state.isOpened}*/}
{/*onOk={() => this.setState({isOpened: false})}*/}
{/*onCancel={() => this.setState({isOpened: false})}*/}
{/*/>*/}
</div>
</div>
</div>

View File

@ -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 {
<input
className={'usernameForm'}
placeholder="Username"
onChange={(e) => this.setState({username: e.target.value})}
/>
<input
className={'passwordForm'}
placeholder="Password"
onChange={(e) => this.setState({password: e.target.value})}
type="password"
/>
</div>
<button onClick={() => this.props.history.push(LINKS.DASHBOARD)} className={'buttonLogin'}>
<button onClick={() => this.login()} className={'buttonLogin'}>
Sign In
</button>
</div>

View File

@ -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 (
<Card className={'itemCard'}>
<img className={'imageCard'} src={this.http.appendImagePath(data.images.logo)} />
<img className={'imageCard'} src={image} />
<p className={'titleCard'}>{data.name}</p>
</Card>
)

View File

@ -25,7 +25,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 (
<Modal
@ -53,7 +59,7 @@ export default class ModalVouchersComponent extends React.Component {
// background: data.background_color || '#aaa',
flex: 0.3
}}>
<img className={'imageModal'} src={this.http.appendImagePath(data.images.logo)} />
<img className={'imageModal'} src={image} />
<p className={'titleModal'}>{data.name} }</p>
</div>
<div style={{

View File

@ -52,152 +52,6 @@ export default class VouchersComponent extends React.Component {
}
render() {
const data = [
{
name: 'KFC',
image: '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))',
option: [
{
value: 'Rp. 50.000',
cost: '50 Points'
},
{
value: 'Rp. 100.000',
cost: '100 Points'
},
{
value: 'Super Besar 1',
cost: '34 Points'
},
{
value: 'Super Besar 2',
cost: '49 Points'
},
]
},
{
name: 'Grab',
image: '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))',
option: [
{
value: 'Rp. 10.000',
cost: '10 Points'
},
{
value: 'Rp. 20.000',
cost: '20 Points'
},
{
value: 'Rp. 50.000',
cost: '50 Points'
},
{
value: 'Rp. 100.000',
cost: '100 Points'
},
]
},
{
name: 'OYO Hotel',
image: '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))',
option: [
{
value: 'Rp. 75.000',
cost: '25 Points'
},
]
},
{
name: 'Carrefour',
image: '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))',
option: [
{
value: 'Rp. 100.000',
cost: '100 Points'
},
{
value: 'Rp. 200.000',
cost: '200 Points'
},
]
},
{
name: "Domino's Pizza",
image: '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, Dominos menyajikan pizza paling lezat dengan harga terbaik untuk jutaan pelanggan. Dominos 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))',
option: [
{
value: 'Rp. 100.000',
cost: '90 Points'
},
{
value: 'Rp. 200.000',
cost: '180 Points'
},
]
},
{
name: 'Timezone',
image: '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))',
option: [
{
value: 'Value Voucher Rp 200.000 (Saldo Rp 150.000 & Free Games Rp 50.000)',
cost: '135 Points'
},
{
value: 'Value Voucher Rp 500.000 (Saldo Rp 300.000 & Free Games Rp 200.000)',
cost: '285 Points'
},
]
},
{
name: 'Bakmi GM',
image: '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))',
option: [
{
value: 'Rp. 50.000',
cost: '47 Points'
},
{
value: 'Rp. 100.000',
cost: '94 Points'
},
]
},
{
name: 'CFC',
image: '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))',
option: [
{
value: 'Rp. 50.000',
cost: '44 Points'
},
]
},
];
return (
<div className="voucher">

View File

@ -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();

View File

@ -152,7 +152,7 @@ export default class Routes extends React.Component {
<Switch>
<Route exact path={LINKS.ROOT} render={props => (<Redirect
to={{
pathname: true ? LINKS.DASHBOARD : LINKS.LOGIN
pathname: this.authStore.isLoggedIn ? LINKS.DASHBOARD : LINKS.LOGIN
}}/>)}/>
<Route exact path={LINKS.REGISTER} component={RegisterComponent}/>
<Route exact path={LINKS.LOGIN} component={LoginComponent}/>

View File

@ -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;

View File

@ -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;
})
// 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);
}

View File

@ -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";
}
}