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 = [ , , ]; const actions = [ , this.postDataBank()} />, ]; return (

FROM BANK

{this.bankStore.list.map(item => { return () })}

TO BANK

0) ? this.bankStore.listAdmin[0].id : 0} onChange={this.handleBankAdmin} value={this.depositStore.bankAdmin} > {this.bankStore.listAdmin.map(item => { return () })}

Bank

{this.depositStore.bankAdmin.name == '' ? "-" : this.depositStore.bankAdmin.name}

Behalf of

{this.depositStore.bankAdmin.on_behalf == '' ? "--" : this.depositStore.bankAdmin.on_behalf}

Account Number

{this.depositStore.bankAdmin.account_number == '' ? "--" : this.depositStore.bankAdmin.account_number}

Currency

{this.depositStore.bankAdmin.account_number == '' ? "--" : "IDR"}

File this.handlePaymentProof(...args)} accept="image/*"/>
this.handleCloseBank()} >

Name

Currency

this.setState({currency: this.currency.currencyList[0]}))} onChange={this.handleChangeCurrency}> {this.currency.currencyList.map((item, index) => { return () })}

Account

On Behalf

this.handleClose()} > Make sure all of your data is correct before submitting.
) } }