- {this.state.type == null
+ {this.props.type == null
? t('Create an order for ')
- : this.state.type == 0
+ : this.props.type == 1
? t('Create a BTC buy order for ')
: t('Create a BTC sell order for ')}
{this.state.enableAmountRange & (this.state.minAmount != null)
diff --git a/frontend/src/components/OrderPage.js b/frontend/src/components/OrderPage.js
index f40a9d2f..e785cfc8 100644
--- a/frontend/src/components/OrderPage.js
+++ b/frontend/src/components/OrderPage.js
@@ -123,8 +123,7 @@ class OrderPage extends Component {
getOrderDetails = (id) => {
this.setState({ orderId: id });
- apiClient.get('/api/order/?order_id=' + id)
- .then(this.orderDetailsReceived);
+ apiClient.get('/api/order/?order_id=' + id).then(this.orderDetailsReceived);
};
orderDetailsReceived = (data) => {
@@ -185,10 +184,12 @@ class OrderPage extends Component {
};
sendWeblnInvoice = (invoice) => {
- apiClient.post('/api/order/?order_id=' + this.state.orderId, {
- action: 'update_invoice',
- invoice,
- }).then((data) => this.completeSetState(data));
+ apiClient
+ .post('/api/order/?order_id=' + this.state.orderId, {
+ action: 'update_invoice',
+ invoice,
+ })
+ .then((data) => this.completeSetState(data));
};
// Countdown Renderer callback with condition
@@ -422,10 +423,11 @@ class OrderPage extends Component {
takeOrder = () => {
this.setState({ loading: true });
- apiClient.post('/api/order/?order_id=' + this.state.orderId, {
- action: 'take',
- amount: this.state.takeAmount,
- })
+ apiClient
+ .post('/api/order/?order_id=' + this.state.orderId, {
+ action: 'take',
+ amount: this.state.takeAmount,
+ })
.then((data) => this.handleWebln(data) & this.completeSetState(data));
};
@@ -441,9 +443,11 @@ class OrderPage extends Component {
handleClickConfirmCancelButton = () => {
this.setState({ loading: true });
- apiClient.post('/api/order/?order_id=' + this.state.orderId, {
- action: 'cancel',
- }).then(() => this.getOrderDetails(this.state.orderId) & this.setState({ status: 4 }));
+ apiClient
+ .post('/api/order/?order_id=' + this.state.orderId, {
+ action: 'cancel',
+ })
+ .then(() => this.getOrderDetails(this.state.orderId) & this.setState({ status: 4 }));
this.handleClickCloseConfirmCancelDialog();
};
@@ -541,9 +545,11 @@ class OrderPage extends Component {
};
handleClickConfirmCollaborativeCancelButton = () => {
- apiClient.post('/api/order/?order_id=' + this.state.orderId, {
- action: 'cancel',
- }).then(() => this.getOrderDetails(this.state.orderId) & this.setState({ status: 4 }));
+ apiClient
+ .post('/api/order/?order_id=' + this.state.orderId, {
+ action: 'cancel',
+ })
+ .then(() => this.getOrderDetails(this.state.orderId) & this.setState({ status: 4 }));
this.handleClickCloseCollaborativeCancelDialog();
};
diff --git a/frontend/src/components/TradeBox.js b/frontend/src/components/TradeBox.js
index 91fee744..7c91be18 100644
--- a/frontend/src/components/TradeBox.js
+++ b/frontend/src/components/TradeBox.js
@@ -133,9 +133,11 @@ class TradeBox extends Component {
};
handleClickAgreeDisputeButton = () => {
- apiClient.post('/api/order/?order_id=' + this.props.data.id, {
- action: 'dispute',
- }).then((data) => this.props.completeSetState(data));
+ apiClient
+ .post('/api/order/?order_id=' + this.props.data.id, {
+ action: 'dispute',
+ })
+ .then((data) => this.props.completeSetState(data));
this.handleClickCloseConfirmDispute();
};
@@ -480,9 +482,11 @@ class TradeBox extends Component {
handleClickPauseOrder = () => {
this.props.completeSetState({ pauseLoading: true });
- apiClient.post('/api/order/?order_id=' + this.props.data.id, {
- action: 'pause',
- }).then((data) => this.props.getOrderDetails(data.id));
+ apiClient
+ .post('/api/order/?order_id=' + this.props.data.id, {
+ action: 'pause',
+ })
+ .then((data) => this.props.getOrderDetails(data.id));
};
showMakerWait = () => {
@@ -626,10 +630,12 @@ class TradeBox extends Component {
handleClickSubmitInvoiceButton = () => {
this.setState({ badInvoice: false });
- apiClient.post('/api/order/?order_id=' + this.props.data.id, {
- action: 'update_invoice',
- invoice: this.state.invoice,
- }).then(
+ apiClient
+ .post('/api/order/?order_id=' + this.props.data.id, {
+ action: 'update_invoice',
+ invoice: this.state.invoice,
+ })
+ .then(
(data) =>
this.setState({ badInvoice: data.bad_invoice }) & this.props.completeSetState(data),
);
@@ -656,11 +662,13 @@ class TradeBox extends Component {
handleClickSubmitAddressButton = () => {
this.setState({ badInvoice: false });
- apiClient.post('/api/order/?order_id=' + this.props.data.id, {
- action: 'update_address',
- address: this.state.address,
- mining_fee_rate: Math.max(1, this.state.miningFee),
- }).then(
+ apiClient
+ .post('/api/order/?order_id=' + this.props.data.id, {
+ action: 'update_address',
+ address: this.state.address,
+ mining_fee_rate: Math.max(1, this.state.miningFee),
+ })
+ .then(
(data) =>
this.setState({ badAddress: data.bad_address }) & this.props.completeSetState(data),
);
@@ -676,13 +684,15 @@ class TradeBox extends Component {
handleClickSubmitStatementButton = () => {
this.setState({ badInvoice: false });
- apiClient.post('/api/order/?order_id=' + this.props.data.id, {
- action: 'submit_statement',
- statement: this.state.statement,
- }).then(
- (data) =>
- this.setState({ badStatement: data.bad_statement }) & this.props.completeSetState(data),
- );
+ apiClient
+ .post('/api/order/?order_id=' + this.props.data.id, {
+ action: 'submit_statement',
+ statement: this.state.statement,
+ })
+ .then(
+ (data) =>
+ this.setState({ badStatement: data.bad_statement }) & this.props.completeSetState(data),
+ );
};
handleScan = (data) => {
@@ -1179,16 +1189,20 @@ class TradeBox extends Component {
}
handleClickConfirmButton = () => {
- apiClient.post('/api/order/?order_id=' + this.props.data.id, {
- action: 'confirm',
- }).then((data) => this.props.completeSetState(data));
+ apiClient
+ .post('/api/order/?order_id=' + this.props.data.id, {
+ action: 'confirm',
+ })
+ .then((data) => this.props.completeSetState(data));
};
handleRatingUserChange = (e) => {
- apiClient.post('/api/order/?order_id=' + this.props.data.id, {
- action: 'rate_user',
- rating: e.target.value,
- }).then((data) => this.props.completeSetState(data));
+ apiClient
+ .post('/api/order/?order_id=' + this.props.data.id, {
+ action: 'rate_user',
+ rating: e.target.value,
+ })
+ .then((data) => this.props.completeSetState(data));
};
handleRatingRobosatsChange = (e) => {
@@ -1197,10 +1211,12 @@ class TradeBox extends Component {
}
this.setState({ rating_platform: e.target.value });
- apiClient.post('/api/order/?order_id=' + this.props.data.id, {
- action: 'rate_platform',
- rating: e.target.value,
- }).then((data) => this.props.completeSetState(data));
+ apiClient
+ .post('/api/order/?order_id=' + this.props.data.id, {
+ action: 'rate_platform',
+ rating: e.target.value,
+ })
+ .then((data) => this.props.completeSetState(data));
};
showFiatSentButton() {
@@ -1316,7 +1332,8 @@ class TradeBox extends Component {
bond_size: this.props.data.bond_size,
bondless_taker: this.props.data.bondless_taker,
};
- apiClient.post('/api/make/', body)
+ apiClient
+ .post('/api/make/', body)
.then(
(data) =>
this.setState({ badRequest: data.bad_request }) &
diff --git a/frontend/src/components/UserGenPage.js b/frontend/src/components/UserGenPage.js
index 96dffd20..3ac5626a 100644
--- a/frontend/src/components/UserGenPage.js
+++ b/frontend/src/components/UserGenPage.js
@@ -77,51 +77,49 @@ class UserGenPage extends Component {
});
requestBody.then((body) =>
- apiClient.post('/api/user/', body)
- .then((data) => {
- console.log(data) &
- this.setState({
- nickname: data.nickname,
- bit_entropy: data.token_bits_entropy,
- avatarUrl: '/static/assets/avatars/' + data.nickname + '.png',
- shannon_entropy: data.token_shannon_entropy,
- bad_request: data.bad_request,
- found: data.found,
- loadingRobot: false,
- stealthInvoices: data.wants_stealth,
- }) &
- // Add nick and token to App state (token only if not a bad request)
- (data.bad_request
- ? this.props.setAppState({
- nickname: data.nickname,
- avatarLoaded: false,
- activeOrderId: data.active_order_id ? data.active_order_id : null,
- referralCode: data.referral_code,
- earnedRewards: data.earned_rewards,
- lastOrderId: data.last_order_id ? data.last_order_id : null,
- stealthInvoices: data.wants_stealth,
- })
- : this.props.setAppState({
- nickname: data.nickname,
- token,
- avatarLoaded: false,
- activeOrderId: data.active_order_id ? data.active_order_id : null,
- lastOrderId: data.last_order_id ? data.last_order_id : null,
- referralCode: data.referral_code,
- earnedRewards: data.earned_rewards,
- stealthInvoices: data.wants_stealth,
- }) &
- writeCookie('robot_token', token) &
- writeCookie('pub_key', data.public_key.split('\n').join('\\')) &
- writeCookie('enc_priv_key', data.encrypted_private_key.split('\n').join('\\'))) &
- // If the robot has been found (recovered) we assume the token is backed up
- (data.found ? this.props.setAppState({ copiedToken: true }) : null);
- }),
+ apiClient.post('/api/user/', body).then((data) => {
+ this.setState({
+ nickname: data.nickname,
+ bit_entropy: data.token_bits_entropy,
+ avatarUrl: '/static/assets/avatars/' + data.nickname + '.png',
+ shannon_entropy: data.token_shannon_entropy,
+ bad_request: data.bad_request,
+ found: data.found,
+ loadingRobot: false,
+ stealthInvoices: data.wants_stealth,
+ }) &
+ // Add nick and token to App state (token only if not a bad request)
+ (data.bad_request
+ ? this.props.setAppState({
+ nickname: data.nickname,
+ avatarLoaded: false,
+ activeOrderId: data.active_order_id ? data.active_order_id : null,
+ referralCode: data.referral_code,
+ earnedRewards: data.earned_rewards,
+ lastOrderId: data.last_order_id ? data.last_order_id : null,
+ stealthInvoices: data.wants_stealth,
+ })
+ : this.props.setAppState({
+ nickname: data.nickname,
+ token,
+ avatarLoaded: false,
+ activeOrderId: data.active_order_id ? data.active_order_id : null,
+ lastOrderId: data.last_order_id ? data.last_order_id : null,
+ referralCode: data.referral_code,
+ earnedRewards: data.earned_rewards,
+ stealthInvoices: data.wants_stealth,
+ }) &
+ writeCookie('robot_token', token) &
+ writeCookie('pub_key', data.public_key.split('\n').join('\\')) &
+ writeCookie('enc_priv_key', data.encrypted_private_key.split('\n').join('\\'))) &
+ // If the robot has been found (recovered) we assume the token is backed up
+ (data.found ? this.props.setAppState({ copiedToken: true }) : null);
+ }),
);
};
delGeneratedUser() {
- apiClient.delete('/api/user')
+ apiClient.delete('/api/user');
deleteCookie('sessionid');
deleteCookie('robot_token');
diff --git a/frontend/src/services/api/ApiWebClient/index.ts b/frontend/src/services/api/ApiWebClient/index.ts
index 70caabae..b8b0bd58 100644
--- a/frontend/src/services/api/ApiWebClient/index.ts
+++ b/frontend/src/services/api/ApiWebClient/index.ts
@@ -1,40 +1,40 @@
-import { ApiClient } from "../api"
+import { ApiClient } from '../api';
import { getCookie } from '../../../utils/cookies';
class ApiWebClient implements ApiClient {
- private getHeaders: () => HeadersInit = () => {
- return { 'Content-Type': 'application/json', 'X-CSRFToken': getCookie('csrftoken') || "" }
- }
+ private readonly getHeaders: () => HeadersInit = () => {
+ return { 'Content-Type': 'application/json', 'X-CSRFToken': getCookie('csrftoken') || '' };
+ };
- public post: (path: string, body: object) => Promise