update: Wallet page
This commit is contained in:
		| @@ -20,11 +20,9 @@ import { | |||||||
| } from 'material-ui'; | } from 'material-ui'; | ||||||
| import {Table as TableAntd} from 'antd'; | import {Table as TableAntd} from 'antd'; | ||||||
| import {startCase} from 'lodash'; | import {startCase} from 'lodash'; | ||||||
| import {LINKS} from "../../routes"; |  | ||||||
| import {Link} from 'react-router-dom'; | import {Link} from 'react-router-dom'; | ||||||
| import SearchIcon from 'material-ui/svg-icons/action/search'; | import SearchIcon from 'material-ui/svg-icons/action/search'; | ||||||
| import UnarchiveIcon from 'material-ui/svg-icons/content/unarchive'; | import UnarchiveIcon from 'material-ui/svg-icons/content/unarchive'; | ||||||
| import ArchiveIcon from 'material-ui/svg-icons/content/archive'; |  | ||||||
| import DC from 'decimal.js-light'; | import DC from 'decimal.js-light'; | ||||||
| import NumberFormat from 'react-number-format'; | import NumberFormat from 'react-number-format'; | ||||||
| import MoreIcon from 'material-ui/svg-icons/navigation/more-vert'; | import MoreIcon from 'material-ui/svg-icons/navigation/more-vert'; | ||||||
| @@ -32,7 +30,7 @@ import LoadingDialog from "../LoadingDialog"; | |||||||
| import Loader from 'react-loader-advanced'; | import Loader from 'react-loader-advanced'; | ||||||
| import './style.scss'; | import './style.scss'; | ||||||
| import {DIALOG} from "../../stores/global_ui"; | import {DIALOG} from "../../stores/global_ui"; | ||||||
| import EmptyComponent from '../EmptyComponent'; | import faker from 'faker'; | ||||||
|  |  | ||||||
| @inject('appstate') | @inject('appstate') | ||||||
| @observer | @observer | ||||||
| @@ -49,11 +47,6 @@ export default class WalletComponent extends React.Component { | |||||||
|     }; |     }; | ||||||
|     this.defaultState = Object.assign({}, this.state); |     this.defaultState = Object.assign({}, this.state); | ||||||
|     this.http = props.appstate.http; |     this.http = props.appstate.http; | ||||||
|     this.authStore = props.appstate.auth; |  | ||||||
|     this.globalUI = props.appstate.globalUI; |  | ||||||
|     this.transactionStore = props.appstate.transaction; |  | ||||||
|     this.bankStore = props.appstate.bank; |  | ||||||
|     this.userData = props.appstate.userData; |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   componentDidMount() { |   componentDidMount() { | ||||||
| @@ -67,48 +60,42 @@ export default class WalletComponent extends React.Component { | |||||||
|     // this.authStore.getWallet(); |     // this.authStore.getWallet(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   handleUpdateInput = (searchText) => { |  | ||||||
|     this.setState({ |  | ||||||
|       searchText: searchText, |  | ||||||
|     }); |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   handleNewRequest = () => { |  | ||||||
|     this.setState({ |  | ||||||
|       searchText: '', |  | ||||||
|     }); |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   tabsHandleChange = (value) => { |  | ||||||
|     this.setState({ |  | ||||||
|       slideIndex: value, |  | ||||||
|     }); |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   search = (event)=>{ |  | ||||||
|     if(event.target.value.length == 0){ |  | ||||||
|       this.transactionStore.isSearching = false; |  | ||||||
|     } |  | ||||||
|     else{ |  | ||||||
|       this.transactionStore.isSearching = true; |  | ||||||
|       this.transactionStore.search(event.target.value); |  | ||||||
|     } |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   handleChangeSorter = (pagination, filters, sorter) => { |  | ||||||
|     // console.log('Various parameters', pagination, filters, sorter); |  | ||||||
|     this.setState({ |  | ||||||
|       filteredInfo: filters, |  | ||||||
|       sortedInfo: sorter, |  | ||||||
|     }); |  | ||||||
|   }; |  | ||||||
|  |  | ||||||
|   handleChange = (event, index, value) => this.setState({value}); |  | ||||||
|  |  | ||||||
|   render() { |   render() { | ||||||
|     const voucher = <NumberFormat value={(500000).toFixed(2)} displayType={'text'} thousandSeparator={true} prefix={'Rp '}/>; |     const voucher = <NumberFormat value={(500000).toFixed(2)} displayType={'text'} thousandSeparator={true} prefix={'Rp '}/>; | ||||||
|     const points = <NumberFormat value={15000} displayType={'text'} thousandSeparator={true}/>; |     const points = <NumberFormat value={15000} displayType={'text'} thousandSeparator={true}/>; | ||||||
|  |  | ||||||
|  |     const data = [ | ||||||
|  |       { | ||||||
|  |         id: faker.random.uuid(), | ||||||
|  |         created_at: faker.date.past(), | ||||||
|  |         type: 'Points', | ||||||
|  |         amount: faker.commerce.price() | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         id: faker.random.uuid(), | ||||||
|  |         created_at: faker.date.past(), | ||||||
|  |         type: 'Points', | ||||||
|  |         amount: faker.commerce.price() | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         id: faker.random.uuid(), | ||||||
|  |         created_at: faker.date.past(), | ||||||
|  |         type: 'Voucher', | ||||||
|  |         amount: faker.commerce.price() | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         id: faker.random.uuid(), | ||||||
|  |         created_at: faker.date.past(), | ||||||
|  |         type: 'Voucher', | ||||||
|  |         amount: faker.commerce.price() | ||||||
|  |       }, | ||||||
|  |       { | ||||||
|  |         id: faker.random.uuid(), | ||||||
|  |         created_at: faker.date.past(), | ||||||
|  |         type: 'Points', | ||||||
|  |         amount: faker.commerce.price() | ||||||
|  |       }, | ||||||
|  |     ]; | ||||||
|  |  | ||||||
|     const columns = [{ |     const columns = [{ | ||||||
|       title: 'Id', |       title: 'Id', | ||||||
| @@ -133,25 +120,26 @@ export default class WalletComponent extends React.Component { | |||||||
|         dataIndex: 'type', |         dataIndex: 'type', | ||||||
|         key: 'type', |         key: 'type', | ||||||
|         className: 'recentOrder-noOrder', |         className: 'recentOrder-noOrder', | ||||||
|         render: (text) => <span>{text.name}</span> |         render: (text) => <span>{text}</span> | ||||||
|       }, |  | ||||||
|  |  | ||||||
|       { |  | ||||||
|         title: 'Status', |  | ||||||
|         dataIndex: 'status', |  | ||||||
|         key: 'status', |  | ||||||
|         className: 'recentOrder-status', |  | ||||||
|         render: (text) => <div><span>{text === 'created' ? 'Waiting Approval' : startCase(text)}</span></div> |  | ||||||
|       }, |       }, | ||||||
|  |       // { | ||||||
|  |       //   title: 'Status', | ||||||
|  |       //   dataIndex: 'status', | ||||||
|  |       //   key: 'status', | ||||||
|  |       //   className: 'recentOrder-status', | ||||||
|  |       //   render: (text) => <div><span>{text === 'created' ? 'Waiting Approval' : startCase(text)}</span></div> | ||||||
|  |       // }, | ||||||
|       { |       { | ||||||
|         title: 'Amount', |         title: 'Amount', | ||||||
|         dataIndex: 'amount', |         dataIndex: 'amount', | ||||||
|         key: 'amount', |         key: 'amount', | ||||||
|         className: 'recentOrder-customer bolder green', |         className: 'recentOrder-customer bolder green', | ||||||
|         render: (text) => { |         render: (text) => { | ||||||
|           return <NumberFormat |           return <span> | ||||||
|  |             <NumberFormat | ||||||
|               value={new DC(text).toNumber()} displayType={'text'} |               value={new DC(text).toNumber()} displayType={'text'} | ||||||
|             thousandSeparator={true} prefix={'Rp. '}/> |               thousandSeparator={true}/> | ||||||
|  |           </span> | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -165,8 +153,6 @@ export default class WalletComponent extends React.Component { | |||||||
|               <h3 className="headerMenu">Wallet</h3> |               <h3 className="headerMenu">Wallet</h3> | ||||||
|             </div> |             </div> | ||||||
|           </div> |           </div> | ||||||
|           { |  | ||||||
|             (this.transactionStore.saldo.length === 2) ? |  | ||||||
|           <div> |           <div> | ||||||
|             <div className="col s6 m6"> |             <div className="col s6 m6"> | ||||||
|               <Card className="cardLite row"> |               <Card className="cardLite row"> | ||||||
| @@ -179,16 +165,6 @@ export default class WalletComponent extends React.Component { | |||||||
|               </Card> |               </Card> | ||||||
|             </div> |             </div> | ||||||
|           </div> |           </div> | ||||||
|               : |  | ||||||
|               <div className="col s12 m12"> |  | ||||||
|                 <Card className="cardLite row"> |  | ||||||
|                   <CardTitle title={voucher} subtitle="Your Voucher"/> |  | ||||||
|                 </Card> |  | ||||||
|                 <Card className="cardLite row"> |  | ||||||
|                   <CardTitle title={points} subtitle="Your Points"/> |  | ||||||
|                 </Card> |  | ||||||
|               </div> |  | ||||||
|           } |  | ||||||
|  |  | ||||||
|           <div className="col s12"> |           <div className="col s12"> | ||||||
|             <Card className="cardLite" style={{paddingBottom: 5}}> |             <Card className="cardLite" style={{paddingBottom: 5}}> | ||||||
| @@ -240,14 +216,14 @@ export default class WalletComponent extends React.Component { | |||||||
|               </Toolbar> |               </Toolbar> | ||||||
|               <Divider/> |               <Divider/> | ||||||
|               <div> |               <div> | ||||||
|                 <Loader show={this.globalUI.loadingVisibility} message={<LoadingDialog/>} |                 <Loader show={false} message={<LoadingDialog/>} | ||||||
|                         messageStyle={{textAlign: 'center'}} |                         messageStyle={{textAlign: 'center'}} | ||||||
|                         backgroundStyle={{backgroundColor: 'rgba(255,255,255,0.5)'}}> |                         backgroundStyle={{backgroundColor: 'rgba(255,255,255,0.5)'}}> | ||||||
|                   <TableAntd |                   <TableAntd | ||||||
|                     pagination={true} |                     pagination={true} | ||||||
|                     className='table-padded' |                     className='table-padded tableWallet' | ||||||
|                     dataSource={this.transactionStore.isSearching ? this.transactionStore.transactionListFiltered : this.transactionStore.list} |                     dataSource={data} | ||||||
|                     onChange={this.handleChangeSorter} |                     // onChange={this.handleChangeSorter} | ||||||
|                     columns={columns} |                     columns={columns} | ||||||
|                     // onRow={(record) => {` |                     // onRow={(record) => {` | ||||||
|                     //   return { |                     //   return { | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| .wallet { | .wallet { | ||||||
|   margin-top: 35px; |   margin-top: 35px; | ||||||
|  |  | ||||||
|  |   .tableWallet{ | ||||||
|  |     padding: 15px; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   .container { |   .container { | ||||||
|     padding: 25px; |     padding: 25px; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user