Initial commit

This commit is contained in:
Rifqy Zacky Ariadhy
2019-01-02 18:39:53 +07:00
commit 1a000700e6
781 changed files with 95892 additions and 0 deletions

View File

@@ -0,0 +1,293 @@
import React from 'react';
import {observer, inject} from 'mobx-react';
import {Dialog, Divider, FlatButton, MenuItem, RaisedButton, SelectField, TextField} from "material-ui";
@inject('appstate')
@observer
export default class DepositFormComponent extends React.Component {
constructor(props) {
super(props);
this.props = props;
this.state = {
openedDialogBank : false,
};
this.defaultState = Object.assign({}, this.state);
this.http = props.appstate.http;
this.bankStore = props.appstate.bank;
this.depositStore = props.appstate.deposit;
this.currency = props.appstate.currencyStore;
}
handlePaymentProof = (event, index, value) => {
const file = event.nativeEvent.target.files[0];
const allowedFile = ['jpg', 'jpeg', 'png', 'gif'];
const [ext] = file.name.split('.').reverse();
if (!allowedFile.includes(ext.toLowerCase())) {
}
this.depositStore.file = file.name;
this.http.upload(file).then((response) => {
this.depositStore.data.payment_proof = "/api/v1" + response.path
});
};
handleOpen = () => {
this.setState({openedDialog: true});
};
handleClose = () => {
this.setState({openedDialog: false});
};
handleOpenBank = () => {
this.setState({
openedDialogBank:true
})
};
handleCloseBank = () => {
this.setState({
openedDialogBank:false
})
};
handleChangeBankName = (event) => {
this.bankStore.data.name = event.target.value;
};
handleChangeCurrency = (event, index, value) => {
this.bankStore.data.currency_id = value.id;
this.setState({currency: value});
console.log(this.bankStore.data.currency_id, value)
};
handleChangeOnBehalf = (event) => {
this.bankStore.data.on_behalf = event.target.value;
};
handleChangeAccount = (event) => {
this.bankStore.data.account_number = event.target.value;
};
postDataBank = () => {
this.bankStore.post();
this.setState({
openedDialogBank: false,
openedDialog:false
});
};
componentDidMount() {
this.bankStore.getAll();
this.bankStore.getAdminBank();
this.currency.getAll();
}
handleBank = (event, index, value) => {
this.depositStore.bank = value;
this.depositStore.data.bank_name = this.depositStore.bank.name;
this.depositStore.data.bank_account_number = this.depositStore.bank.account_number;
this.depositStore.data.bank_behalf_of = this.depositStore.bank.on_behalf;
}
handleBankAdmin = (event, index, value) => {
this.depositStore.bankAdmin = value;
this.depositStore.data.bank_to.id = this.depositStore.bankAdmin.id;
this.depositStore.data.bank_to.name = this.depositStore.bankAdmin.name;
this.depositStore.data.bank_to.account_number = this.depositStore.bankAdmin.account_number;
this.depositStore.data.bank_to.on_behalf = this.depositStore.bankAdmin.on_behalf;
}
handleAmount = (event) => {
this.depositStore.data.amount = event.target.value;
}
render() {
const actionsBank = [
<FlatButton
label="No"
primary={true}
style={{marginRight: 10}}
onClick={this.handleCloseBank}
/>,
<RaisedButton
label="Yes"
primary={true}
onClick={this.handleOpen}
/>,
];
const actions = [
<FlatButton
label="Cancel"
primary={true}
style={{marginRight: 10}}
onClick={this.handleClose}
/>,
<RaisedButton
label="Submit"
primary={true}
onClick={() => this.postDataBank()}
/>,
];
return (
<div>
<div className="row">
<div className="col s12 m6 l6">
<p style={{color: '#32325d', fontSize: '12px'}}>FROM BANK</p>
<SelectField
floatingLabelText={"Bank"}
fullWidth={true}
onChange={this.handleBank}
value={this.depositStore.bank}
hintText={this.depositStore.bank.name}
>
{this.bankStore.list.map(item => {
return (<MenuItem key={item.id} value={item} primaryText={`Bank ${item.name}`}/>)
})}
<Divider/>
<MenuItem key={0} value={0} style={{color: "blue"}} primaryText="Create New Bank.." onClick={this.handleOpenBank}/>
</SelectField>
<TextField
type="text"
fullWidth={true}
floatingLabelText={"Bank Account Number"}
disabled={true}
underlineDisabledStyle={{borderBottom: '1px dotted rgba(0, 0, 0, 0.3)'}}
value={this.depositStore.data.bank_account_number}
/>
<br/>
<TextField
type="text"
fullWidth={true}
floatingLabelText={"Behalf Of"}
disabled={true}
underlineDisabledStyle={{borderBottom: '1px dotted rgba(0, 0, 0, 0.3)'}}
value={this.depositStore.data.bank_behalf_of}
/>
</div>
<div className="col s12 m6 l6">
<p style={{color: '#32325d', fontSize: '12px'}}>TO BANK</p>
<SelectField
floatingLabelText={"Bank"}
fullWidth={true}
value={(this.bankStore.listAdmin.length > 0) ? this.bankStore.listAdmin[0].id : 0}
onChange={this.handleBankAdmin}
value={this.depositStore.bankAdmin}
>
{this.bankStore.listAdmin.map(item => {
return (<MenuItem key={item.id} value={item} primaryText={`Bank ${item.name}`}/>)
})}
</SelectField>
<div className="listCustDetail bankDetailInformation">
<div className="listCustDetailItem flex">
<p className="listCustomerDetailItemKey">Bank</p>
<code
className="listCustomerDetailItemValue">{this.depositStore.bankAdmin.name == '' ? "-" : this.depositStore.bankAdmin.name}</code>
</div>
<div className="listCustDetailItem flex">
<p className="listCustomerDetailItemKey">Behalf of</p>
<p
className="listCustomerDetailItemValue">{this.depositStore.bankAdmin.on_behalf == '' ? "--" : this.depositStore.bankAdmin.on_behalf}</p>
</div>
<div className="listCustDetailItem flex">
<p className="listCustomerDetailItemKey">Account Number</p>
<p
className="listCustomerDetailItemValue">{this.depositStore.bankAdmin.account_number == '' ? "--" : this.depositStore.bankAdmin.account_number}</p>
</div>
<div className="listCustDetailItem flex">
<p className="listCustomerDetailItemKey">Currency</p>
<p
className="listCustomerDetailItemValue">{this.depositStore.bankAdmin.account_number == '' ? "--" : "IDR"}</p>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col s12 m6 l6">
<TextField fullWidth={true} min="0" type={"number"} floatingLabelText={"Amount (IDR)"}
onChange={this.handleAmount} defaultValue={this.depositStore.data.amount}/>
</div>
</div>
<div className="row">
<div className="col s12">
<div className="file-field input-field marginBottom18">
<div className="btn">
<span>File</span>
<input type="file" onChange={(...args) => this.handlePaymentProof(...args)} accept="image/*"/>
</div>
<div className="file-path-wrapper">
<input className="file-path validate" type="text"
placeholder="Upload the evidence (jpg,jpeg,png,gif)" value={this.depositStore.file}/>
</div>
</div>
</div>
</div>
<Dialog
title="Adding Bank"
actions={actionsBank}
modal={true}
open={this.state.openedDialogBank}
onRequestClose={() => this.handleCloseBank()}
>
<div style={{padding: 20}}>
<div className="row">
<div className="col s12 m6 l6">
<p className="label-form">Name</p>
<TextField
hintText=" E.g. BCA"
onChange={this.handleChangeBankName}
fullWidth={true}
/>
</div>
<div className="col s12 m6 l6">
<p className="label-form">Currency</p>
<SelectField
fullWidth={true}
value={(this.state.currency) ? this.state.currency : (() => this.setState({currency: this.currency.currencyList[0]}))}
onChange={this.handleChangeCurrency}>
{this.currency.currencyList.map((item, index) => {
return (<MenuItem key={index} value={item} primaryText={item.name} />)
})}
</SelectField>
</div>
</div>
<div className="row">
<div className="col s12 m6 l6">
<p className="label-form">Account</p>
<TextField
hintText=" E.g. xxxxxxxxxx"
onChange={this.handleChangeAccount}
fullWidth={true}
type="number"
/>
</div>
<div className="col s12 m6 l6">
<p className="label-form">On Behalf</p>
<TextField
hintText=" E.g. Ridwan Abadi"
onChange={this.handleChangeOnBehalf}
fullWidth={true}
/>
</div>
</div>
</div>
</Dialog>
<Dialog
title="Warning"
actions={actions}
modal={true}
open={this.state.openedDialog}
onRequestClose={() => this.handleClose()}
>
Make sure all of your data is correct before submitting.
</Dialog>
</div>
)
}
}

View File

@@ -0,0 +1,103 @@
import React from 'react';
import {observer, inject} from 'mobx-react';
import NumberFormat from 'react-number-format';
@inject('appstate')
@observer
export default class DepositReviewComponent extends React.Component {
constructor(props) {
super(props);
this.props = props;
this.state = {};
this.defaultState = Object.assign({}, this.state);
this.depositStore = props.appstate.deposit;
}
componentDidMount() {
// console.log('DepositReviewComponent loaded!', this.props)
}
render() {
const {data} = this.props;
return (
<div>
<div>
<div className="center-align"><p style={{ lineHeight: "1.6rem" }}>You will made deposit request via bank transfer</p></div>
{/*<div className="center-align"><p style={{lineHeight:"1.6rem", marginTop:"0px", marginBottom:"0px"}}>Number: <span className="black-text">#3AB3Db</span></p></div>*/}
<div className="center-align"><p style={{ lineHeight: "1.6rem", marginTop: "0px" }}>Date: <span className="black-text">{moment().format('DD MMMM YYYY, HH:mm:ss')}</span></p></div>
<div className="center-align"><p style={{ lineHeight: "1.6rem", marginTop: "0px", marginBottom: "0px" }}>Total Amount</p></div>
<div className="center-align"><h4 className="black-text" style={{ lineHeight: "1.6rem", marginTop: "0px", fontSize: "26px", marginBottom: "0px" }}><NumberFormat value={this.depositStore.data.amount} displayType={'text'} thousandSeparator={true} prefix={'IDR '} /></h4></div>
<div className="row">
<div className="col s12 m6">
<h4 className="center-align" style={{ fontSize: '14px', marginBottom: "8px" }}>From</h4>
<div style={{
boxShadow: "none",
border: "1px solid #d4d4d4",
backgroundColor: "#f9f9f9",
padding: "10px 10px 10px 20px",
marginTop: 0,
marginBottom: 0
}} className="card-panel">
<p className="black-text" style={{ lineHeight: '1.0rem', fontSize: 11 }}>
Bank: {this.depositStore.bank.name}
</p>
<p className="black-text" style={{ lineHeight: '1.0rem', fontSize: 11 }}>
Behalf Of: {this.depositStore.bank.on_behalf}
</p>
<p className="black-text" style={{ lineHeight: '1.0rem', fontSize: 11 }}>
Account Number: {this.depositStore.bank.account_number}
</p>
<p className="black-text" style={{ lineHeight: '1.0rem', fontSize: 11 }}>
Currency: IDR
</p>
<p className="black-text" style={{ lineHeight: '1.0rem', fontSize: 11 }}>
Swift Code:
</p>
</div>
</div>
<div className="col s12 m6">
<h4 className="center-align" style={{ fontSize: '14px', marginBottom: "8px" }}>To</h4>
<div style={{
boxShadow: "none",
border: "1px solid #d4d4d4",
backgroundColor: "#f9f9f9",
padding: "10px 10px 10px 20px",
marginTop: 0,
marginBottom: 0
}} className="card-panel">
<p className="black-text" style={{ lineHeight: '1.0rem', fontSize: 11 }}>
Bank: {this.depositStore.bankAdmin.name}
</p>
<p className="black-text" style={{ lineHeight: '1.0rem', fontSize: 11 }}>
Behalf Of: {this.depositStore.bankAdmin.on_behalf}
</p>
<p className="black-text" style={{ lineHeight: '1.0rem', fontSize: 11 }}>
Account Number: {this.depositStore.bankAdmin.account_number}
</p>
<p className="black-text" style={{ lineHeight: '1.0rem', fontSize: 11 }}>
Currency: IDR
</p>
<p className="black-text" style={{ lineHeight: '1.0rem', fontSize: 11 }}>
Swift Code: BBIJIDJA
</p>
{/*<p className="black-text" style={{lineHeight: '1.0rem', fontSize: 11}}>*/}
{/*Note: [Your trading account number]*/}
{/*</p>*/}
</div>
</div>
</div>
</div>
</div>
)
}
}

View File

@@ -0,0 +1,226 @@
import React from 'react';
import {observer, inject} from 'mobx-react';
import {Dialog, FlatButton, RaisedButton, Step, StepLabel, Stepper} from "material-ui";
import {DIALOG} from "../../stores/global_ui";
import Form from './DepositForm';
import Review from './DepositReview';
import get from 'lodash.get';
@inject('appstate')
@observer
export default class DepositDialogComponent extends React.Component {
constructor(props) {
super(props);
this.props = props;
this.state = {
currentStep: 0,
openedDialog: false,
nextButtonText: 'Next',
backButtonText: 'Cancel',
formData: {},
steps: [
{
label: 'Deposit Form',
// action: () => this.validateName(),
component: <Form/>,
nextButtonText: 'Review',
backButtonText: 'Cancel',
},
{
label: "Review",
component: () => <Review/>,
// action: () => this.deposit.createDeposit(this.state.formData),
nextButtonText: 'Deposit',
backButtonText: 'Back',
}
]
};
this.defaultState = Object.assign({}, this.state);
this.globalUI = props.appstate.globalUI;
this.deposit = props.appstate.deposit;
this.transactionStore = props.appstate.transaction;
}
componentDidMount() {
// console.log('DepositDialogComponent loaded!')
}
get stepperContent() {
const {currentStep, steps} = this.state;
switch (typeof steps[currentStep].component) {
case "function":
return steps[currentStep].component();
default:
return steps[currentStep].component || (<div>Step #{currentStep}</div>);
}
}
handleNext() {
const {currentStep, steps} = this.state;
let newStep = currentStep;
let regex=/^[0-9]+$/;
if(this.deposit.data.payment_proof === '' || this.deposit.data.amount === '' ||
this.deposit.data.bank_account_number === '' || this.deposit.data.bank_name === '' ||
this.deposit.data.bank_behalf_of === '' || this.deposit.data.bank_to.name === ''){
this.handleOpen();
}else if(this.deposit.data.amount.match(regex)){
newStep = currentStep + 1;
}else{
this.handleOpen();
}
if (newStep >= steps.length) {
this.setState({currentStep:0});
this.deposit.createDeposit().then(res => {
this.globalUI.openSnackbar("Request Deposit Success");
this.transactionStore.getAll();
this.deposit.bankAdmin = {
name : '',
account_number : '',
on_behalf : '',
};
this.deposit.data = {
payment_proof: '',
amount: '',
bank_account_number: '',
bank_name: '',
bank_behalf_of: '',
bank_to: {
name: this.deposit.bankAdmin.name,
account_number: this.deposit.bankAdmin.account_number,
on_behalf: this.deposit.bankAdmin.on_behalf,
},
};
});
this.closeModal();
}
(steps[currentStep].action || (() => Promise.resolve(true)))()
.then(status => {
this.setState({
currentStep: newStep,
nextButtonText: steps[newStep].nextButtonText || this.defaultState.nextButtonText,
backButtonText: steps[newStep].backButtonText || this.defaultState.backButtonText,
})
})
}
handlePrev() {
const {currentStep, steps} = this.state;
let newStep = currentStep - 1;
if (newStep < 0) {
this.setState({
currentStep: 0,
nextButtonText: steps[0].nextButtonText || this.defaultState.nextButtonText,
backButtonText: steps[0].backButtonText || this.defaultState.backButtonText
});
this.closeModal();
} else {
this.setState({
currentStep: newStep,
nextButtonText: steps[newStep].nextButtonText || this.defaultState.nextButtonText,
backButtonText: steps[newStep].backButtonText || this.defaultState.backButtonText,
})
}
}
closeModal() {
this.globalUI.hideDialog(DIALOG.WALLET.DEPOSIT);
this.deposit.bankAdmin = {
name : '',
account_number : '',
on_behalf : '',
};
this.deposit.data = {
payment_proof: '',
amount: '',
bank_account_number: '',
bank_name: '',
bank_behalf_of: '',
bank_to: {
name: this.deposit.bankAdmin.name,
account_number: this.deposit.bankAdmin.account_number,
on_behalf: this.deposit.bankAdmin.on_behalf,
},
};
}
handleClose = () => {
this.setState({openedDialog: false})
};
handleOpen = () => {
this.setState({openedDialog: true})
};
render() {
const actionsWarn = [
<FlatButton
label="Okay"
primary={true}
style={{marginRight:10}}
onClick={this.handleClose}
/>,
];
let {
currentStep,
nextButtonText:defaultNextText,
backButtonText:defaultBackText
} = this.state;
let nextButtonText, backButtonText;
backButtonText = get(this.state, `steps[${currentStep}].backButtonText`, defaultBackText);
nextButtonText = get(this.state, `steps[${currentStep}].nextButtonText`, defaultNextText);
const actions = [
<FlatButton
label={backButtonText}
onClick={() => this.handlePrev()}
style={{marginRight: 12}}
/>,
<RaisedButton
label={nextButtonText}
onClick={() => this.handleNext()}
primary={true}
/>
];
return (
<div>
<Dialog
title="Deposit Form"
actions={actions}
modal={true}
onRequestClose={()=> this.closeModal()}
autoScrollBodyContent={true}
open={this.globalUI[DIALOG.WALLET.DEPOSIT]}>
<Stepper activeStep={currentStep}>
{this.state.steps.map(step => {
return (
<Step key={step.label}>
<StepLabel> <span className="hide-on-small-only">{step.label}</span></StepLabel>
</Step>
)
})}
</Stepper>
{this.stepperContent}
</Dialog>
<Dialog
title="Warning"
actions={actionsWarn}
modal={true}
contentStyle={{width:350}}
open={this.state.openedDialog}
onRequestClose={()=> this.handleClose()}
>
Please Fill the form correctly
</Dialog>
</div>
)
}
}