Create a BTC {this.state.type==0 ? "buy":"sell"} order for {this.state.amount} {this.state.currencyCode}
diff --git a/frontend/src/components/OrderPage.js b/frontend/src/components/OrderPage.js
index 50c526fa..86ed50ec 100644
--- a/frontend/src/components/OrderPage.js
+++ b/frontend/src/components/OrderPage.js
@@ -2,6 +2,34 @@ import React, { Component } from "react";
import { Paper, Button , Grid, Typography, List, ListItem, ListItemText, ListItemAvatar, Avatar, Divider} from "@material-ui/core"
import { Link } from 'react-router-dom'
+function msToTime(duration) {
+ var seconds = Math.floor((duration / 1000) % 60),
+ minutes = Math.floor((duration / (1000 * 60)) % 60),
+ hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
+
+ minutes = (minutes < 10) ? "0" + minutes : minutes;
+ seconds = (seconds < 10) ? "0" + seconds : seconds;
+
+ return hours + "h " + minutes + "m " + seconds + "s";
+}
+
+function getCookie(name) {
+ let cookieValue = null;
+ if (document.cookie && document.cookie !== '') {
+ const cookies = document.cookie.split(';');
+ for (let i = 0; i < cookies.length; i++) {
+ const cookie = cookies[i].trim();
+ // Does this cookie string begin with the name we want?
+ if (cookie.substring(0, name.length + 1) === (name + '=')) {
+ cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
+ break;
+ }
+ }
+ }
+ return cookieValue;
+}
+const csrftoken = getCookie('csrftoken');
+
// pretty numbers
function pn(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
@@ -26,7 +54,7 @@ export default class OrderPage extends Component {
statusText: data.status_message,
type: data.type,
currency: data.currency,
- currencyCode: (data.currency== 1 ) ? "USD": ((data.currency == 2 ) ? "EUR":"ETH"),
+ currencyCode: this.getCurrencyCode(data.currency),
amount: data.amount,
paymentMethod: data.payment_method,
isExplicit: data.is_explicit,
@@ -37,14 +65,39 @@ export default class OrderPage extends Component {
makerNick: data.maker_nick,
takerId: data.taker,
takerNick: data.taker_nick,
+ isBuyer:data.buyer,
+ isSeller:data.seller,
+ expiresAt:data.expires_at,
+ badRequest:data.bad_request,
});
});
}
+ // Gets currency code (3 letters) from numeric (e.g., 1 -> USD)
+ // Improve this function so currencies are read from json
+ getCurrencyCode(val){
+ return (val == 1 ) ? "USD": ((val == 2 ) ? "EUR":"ETH")
+ }
+
// Fix to use proper react props
handleClickBackButton=()=>{
window.history.back();
}
+
+ handleClickTakeOrderButton=()=>{
+ console.log(this.state)
+ const requestOptions = {
+ method: 'POST',
+ headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken'),},
+ body: JSON.stringify({
+ 'action':'take',
+ }),
+ };
+ fetch('/api/order/' + '?order_id=' + this.orderId, requestOptions)
+ .then((response) => response.json())
+ .then((data) => (console.log(data) & this.getOrderDetails(data.id)));
+ }
+
render (){
return (
@@ -53,17 +106,43 @@ export default class OrderPage extends Component {
BTC {this.state.type ? " Sell " : " Buy "} Order
-
-
+
+
-
+
+
+ {this.state.isParticipant ?
+ <>
+ {this.state.takerNick!='None' ?
+ <>
+
+
+
+
+
+
+
+ >:
+ ""
+ }
+
+
+
+
+ >
+ :""
+ }
+
@@ -80,32 +159,26 @@ export default class OrderPage extends Component {
}
- {this.state.isParticipant ?
- <>
-
-
-
-
- { this.state.takerNick!='None' ?
- <>
-
-
- >: ""}
- >
- :""
- }
+
+
+
+
+
+
+
+
- {this.state.isParticipant ? "" : }
+ {this.state.isParticipant ? "" : }
- {this.state.isParticipant ? "" : }
+
-
+
);
diff --git a/frontend/src/components/TradePipelineBox.js b/frontend/src/components/TradePipelineBox.js
new file mode 100644
index 00000000..e69de29b
diff --git a/frontend/src/components/UserGenPage.js b/frontend/src/components/UserGenPage.js
index bdab24d0..ef7d9c98 100644
--- a/frontend/src/components/UserGenPage.js
+++ b/frontend/src/components/UserGenPage.js
@@ -58,7 +58,7 @@ export default class UserGenPage extends Component {
delGeneratedUser() {
const requestOptions = {
method: 'DELETE',
- headers: {'Content-Type':'application/json', 'X-CSRFToken': csrftoken},
+ headers: {'Content-Type':'application/json', 'X-CSRFToken': getCookie('csrftoken')},
};
fetch("/api/usergen", requestOptions)
.then((response) => response.json())
@@ -74,7 +74,7 @@ export default class UserGenPage extends Component {
this.setState({
token: this.genBase62Token(32),
})
- this.getGeneratedUser();
+ this.reload_for_csrf_to_work();
}
handleChangeToken=(e)=>{
diff --git a/frontend/static/assets/misc/unknown_avatar.png b/frontend/static/assets/misc/unknown_avatar.png
new file mode 100644
index 00000000..9e19b6a9
Binary files /dev/null and b/frontend/static/assets/misc/unknown_avatar.png differ
diff --git a/setup.md b/setup.md
index f3b0af5d..c1cbf307 100644
--- a/setup.md
+++ b/setup.md
@@ -4,7 +4,10 @@
`sudo apt install python3 python3 pip`
### Install virtual environments
-`pip install virtualenvwrapper`
+```
+pip install virtualenvwrapper
+pip install python-decouple
+```
### Add to .bashrc
@@ -28,6 +31,9 @@ source /usr/local/bin/virtualenvwrapper.sh
### Install Django and Restframework
`pip3 install django djangorestframework`
+## Install Django admin relational links
+`pip install django-admin-relation-links`
+
*Django 4.0 at the time of writting*
### Launch the local development node