From 416aab46d0addb3eb4c4f2d956c0feb58d2de612 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Mon, 2 May 2022 09:32:15 -0700 Subject: [PATCH] Store orders in app state. Fix typos. --- frontend/src/components/BookPage.js | 34 +++++++++++--------- frontend/src/components/HomePage.js | 4 ++- frontend/src/components/TradeBox.js | 2 +- frontend/src/components/icons/BuySatsIcon.js | 6 ++-- frontend/src/locales/de.json | 2 +- frontend/src/locales/en.json | 7 ++-- frontend/src/locales/es.json | 2 +- frontend/src/locales/fr.json | 2 +- frontend/src/locales/pl.json | 2 +- frontend/src/locales/ru.json | 2 +- frontend/src/locales/zh.json | 2 +- 11 files changed, 36 insertions(+), 29 deletions(-) diff --git a/frontend/src/components/BookPage.js b/frontend/src/components/BookPage.js index 40bf69f9..a7987092 100644 --- a/frontend/src/components/BookPage.js +++ b/frontend/src/components/BookPage.js @@ -23,21 +23,23 @@ class BookPage extends Component { constructor(props) { super(props); this.state = { - orders: new Array({id:0,}), - loading: true, pageSize: 6, }; - this.getOrderDetails(2, 0) + + if(this.props.orders.length == 0){ + this.getOrderDetails(2, 0) + } } getOrderDetails(type, currency) { + this.props.setAppState({bookLoading: true}); fetch('/api/book' + '?currency=' + currency + "&type=" + type) .then((response) => response.json()) - .then((data) => this.setState({ - orders: data, - not_found: data.not_found, - loading: false, - })); + .then((data) => (this.props.setAppState({ + bookNotFound: data.not_found, + bookLoading: false, + bookOrders: data, + }))); } handleRowClick=(e)=>{ @@ -83,7 +85,7 @@ class BookPage extends Component {
order.type == this.props.type || this.props.type == 2) + this.props.orders.filter(order => order.type == this.props.type || this.props.type == 2) .filter(order => order.currency == this.props.currency || this.props.currency == 0) .map((order) => ({id: order.id, @@ -101,7 +103,7 @@ class BookPage extends Component { premium: order.premium, }) )} - loading={this.state.loading} + loading={this.props.loading} columns={[ // { field: 'id', headerName: 'ID', width: 40 }, { field: 'robot', headerName: t("Robot"), width: 240, @@ -164,7 +166,7 @@ class BookPage extends Component { ) }} - pageSize={this.state.loading ? 0 : this.state.pageSize} + pageSize={this.props.loading ? 0 : this.state.pageSize} rowsPerPageOptions={[6,20,50]} onPageSizeChange={(newPageSize) => this.setState({pageSize:newPageSize})} onRowClick={(params) => this.handleRowClick(params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places. @@ -178,9 +180,9 @@ class BookPage extends Component { return (
order.type == this.props.type || this.props.type == 2) + this.props.orders.filter(order => order.type == this.props.type || this.props.type == 2) .filter(order => order.currency == this.props.currency || this.props.currency == 0) .map((order) => ({id: order.id, @@ -265,7 +267,7 @@ class BookPage extends Component { ) }} - pageSize={this.state.loading ? 0 : this.state.pageSize} + pageSize={this.props.loading ? 0 : this.state.pageSize} rowsPerPageOptions={[6,20,50]} onPageSizeChange={(newPageSize) => this.setState({pageSize:newPageSize})} onRowClick={(params) => this.handleRowClick(params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places. @@ -401,7 +403,7 @@ class BookPage extends Component { - { this.state.not_found ? "" : + { this.props.notFound ? "" : {this.props.type == 0 ? @@ -417,7 +419,7 @@ class BookPage extends Component { } - { this.state.not_found ? + { this.props.notFound ? : diff --git a/frontend/src/components/HomePage.js b/frontend/src/components/HomePage.js index 23052e3c..451dea6b 100644 --- a/frontend/src/components/HomePage.js +++ b/frontend/src/components/HomePage.js @@ -19,6 +19,8 @@ export default class HomePage extends Component { bookType:2, bookCurrency:0, bookCurrencyCode:'ANY', + bookOrders:new Array(), + bookLoading: true, } } @@ -38,7 +40,7 @@ export default class HomePage extends Component { }/> }/> - }/> + }/>
diff --git a/frontend/src/components/TradeBox.js b/frontend/src/components/TradeBox.js index 8209a9ea..0eb1327e 100644 --- a/frontend/src/components/TradeBox.js +++ b/frontend/src/components/TradeBox.js @@ -400,7 +400,7 @@ class TradeBox extends Component { -

{t("Be patient while robots check the book. This box will ring 🔊 once a robot takes your order, then you will have {{deposit_timer_hours}}h {{deposit_timer_minutes}}m hours to reply. If you do not reply, you risk losing your bond.", this.depositHoursMinutes() )}

+

{t("Be patient while robots check the book. This box will ring 🔊 once a robot takes your order, then you will have {{deposit_timer_hours}}h {{deposit_timer_minutes}}m to reply. If you do not reply, you risk losing your bond.", this.depositHoursMinutes() )}

{t("If the order expires untaken, your bond will return to you (no action needed).")}

diff --git a/frontend/src/components/icons/BuySatsIcon.js b/frontend/src/components/icons/BuySatsIcon.js index 7bdb4f71..11e2753a 100644 --- a/frontend/src/components/icons/BuySatsIcon.js +++ b/frontend/src/components/icons/BuySatsIcon.js @@ -15,7 +15,7 @@ export default function BuySatsIcon(props) { 138.476,194.816 143.92,199.672 146.813,202.254 152.256,207.109 155.712,210.195 157.527,211.816 163.973,207.854 161.154,205.34 "/> - + - + @@ -36,7 +36,7 @@ export default function BuySatsIcon(props) { - +