From 7f076130609de79922f20e091d6b9dbb4de6b77f Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Thu, 31 Mar 2022 07:38:53 -0700 Subject: [PATCH] Add permanent memory for book type and currency --- frontend/src/components/BookPage.js | 30 ++++++++++++++--------------- frontend/src/components/HomePage.js | 4 +++- frontend/static/frontend/main.js | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/BookPage.js b/frontend/src/components/BookPage.js index badc0a32..61f8efd8 100644 --- a/frontend/src/components/BookPage.js +++ b/frontend/src/components/BookPage.js @@ -1,5 +1,5 @@ -import React, { Component } from "react"; -import { Badge, Tooltip, Paper, Button , CircularProgress, ListItemButton, Typography, Grid, Select, MenuItem, FormControl, FormHelperText, List, ListItem, ListItemText, Avatar, RouterLink, ListItemAvatar, IconButton} from "@mui/material"; +import React, { Component , useState } from "react"; +import { Badge, Tooltip, Paper, Button, ListItemButton, Typography, Grid, Select, MenuItem, FormControl, FormHelperText, ListItemText, ListItemAvatar, IconButton} from "@mui/material"; import { Link } from 'react-router-dom' import { DataGrid } from '@mui/x-data-grid'; import MediaQuery from 'react-responsive' @@ -12,15 +12,15 @@ export default class BookPage extends Component { super(props); this.state = { orders: new Array({id:0,}), - currency: 0, - type: 2, + currency: this.props.currency ? this.props.currency : 0, + type: this.props.type ? this.props.type : 2, currencies_dict: {"0":"ANY"}, loading: true, pageSize: 6, }; this.getCurrencyDict() - this.getOrderDetails(this.state.type, this.state.currency) - this.state.currencyCode = this.getCurrencyCode(this.state.currency) + this.getOrderDetails(this.props.type, this.props.currency) + this.state.currencyCode = this.getCurrencyCode(this.props.currency) } getOrderDetails(type, currency) { @@ -39,18 +39,18 @@ export default class BookPage extends Component { handleTypeChange=(e)=>{ this.setState({ - type: e.target.value, loading: true, }); - this.getOrderDetails(e.target.value,this.state.currency); + this.props.setAppState({type: e.target.value}) + this.getOrderDetails(e.target.value,this.props.currency); } handleCurrencyChange=(e)=>{ this.setState({ - currency: e.target.value, currencyCode: this.getCurrencyCode(e.target.value), loading: true, }) - this.getOrderDetails(this.state.type, e.target.value); + this.props.setAppState({currency: e.target.value}) + this.getOrderDetails(this.props.type, e.target.value); } getCurrencyDict() { @@ -271,7 +271,7 @@ export default class BookPage extends Component { autoWidth={true} label="Select Order Type" required="true" - value={this.state.type} + value={this.props.type} inputProps={{ style: {textAlign:"center"} }} @@ -286,14 +286,14 @@ export default class BookPage extends Component { - and {this.state.type == 0 ? ' receive' : (this.state.type == 1 ? ' pay with' : ' use' )} + and {this.props.type == 0 ? ' receive' : (this.props.type == 1 ? ' pay with' : ' use' )}