);
}
};
takeOrder = () => {
this.setState({ loading: true });
apiClient
.post('/api/order/?order_id=' + this.state.orderId, {
action: 'take',
amount: this.state.takeAmount,
})
.then((data) => this.handleWebln(data) & this.completeSetState(data));
};
// set delay to the one matching the order status. If null order status, delay goes to 9999999.
setDelay = (status) => {
return status >= 0 ? this.statusToDelay[status.toString()] : 99999999;
};
getCurrencyCode(val) {
const code = val ? currencyDict[val.toString()] : '';
return code;
}
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 }));
this.handleClickCloseConfirmCancelDialog();
};
handleClickOpenConfirmCancelDialog = () => {
this.setState({ openCancel: true });
};
handleClickCloseConfirmCancelDialog = () => {
this.setState({ openCancel: false });
};
CancelDialog = () => {
const { t } = this.props;
return (
);
};
handleClickOpenInactiveMakerDialog = () => {
this.setState({ openInactiveMaker: true });
};
handleClickCloseInactiveMakerDialog = () => {
this.setState({ openInactiveMaker: false });
};
InactiveMakerDialog = () => {
const { t } = this.props;
return (
);
};
tokenDialog = () => {
return getCookie('robot_token') ? (
this.setState({ openStoreToken: false })}
onClickCopy={() =>
copyToClipboard(getCookie('robot_token')) & this.props.setAppState({ copiedToken: true })
}
copyIconColor={this.props.copiedToken ? 'inherit' : 'primary'}
onClickBack={() => this.setState({ openStoreToken: false })}
onClickDone={() =>
this.setState({ openStoreToken: false }) &
(this.state.maker_status == 'Inactive'
? this.handleClickOpenInactiveMakerDialog()
: this.takeOrder())
}
/>
) : (
this.setState({ openStoreToken: false })}
/>
);
};
handleClickConfirmCollaborativeCancelButton = () => {
apiClient
.post('/api/order/?order_id=' + this.state.orderId, {
action: 'cancel',
})
.then(() => this.getOrderDetails(this.state.orderId) & this.setState({ status: 4 }));
this.handleClickCloseCollaborativeCancelDialog();
};
handleClickOpenCollaborativeCancelDialog = () => {
this.setState({ openCollaborativeCancel: true });
};
handleClickCloseCollaborativeCancelDialog = () => {
this.setState({ openCollaborativeCancel: false });
};
CollaborativeCancelDialog = () => {
const { t } = this.props;
return (
);
};
BackButton = () => {
const { t } = this.props;
// If order has expired, show back button.
if (this.state.status == 5) {
return (
);
}
return null;
};
CancelButton = () => {
const { t } = this.props;
// If maker and Waiting for Bond. Or if taker and Waiting for bond.
// Simply allow to cancel without showing the cancel dialog.
if (
this.state.is_maker & [0, 1, 2].includes(this.state.status) ||
this.state.is_taker & (this.state.status == 3)
) {
return (
);
}
// If the order does not yet have an escrow deposited. Show dialog
// to confirm forfeiting the bond
if ([3, 6, 7].includes(this.state.status)) {
return (
{this.CancelDialog()}
);
}
// If the escrow is Locked, show the collaborative cancel button.
if ([8, 9].includes(this.state.status)) {
return (
{this.CollaborativeCancelDialog()}
);
}
// If none of the above do not return a cancel button.
return null;
};
// Colors for the status badges
statusBadgeColor(status) {
if (status === 'Active') {
return 'success';
}
if (status === 'Seen recently') {
return 'warning';
}
if (status === 'Inactive') {
return 'error';
}
}
orderBox = () => {
const { t } = this.props;
return (
{t('Order Box')}
{this.state.is_participant ? (
<>
{this.state.taker_nick !== 'None' ? (
<>
>
) : (
''
)}
>
) : (
)}
{this.state.has_range & (this.state.amount == null) ? (
) : (
)}
}
secondary={
this.state.currency == 1000
? t('Swap destination')
: t('Accepted payment methods')
}
/>
{/* If there is live Price and Premium data, show it. Otherwise show the order maker settings */}
{this.state.price_now ? (
) : this.state.is_explicit ? (
) : (
)}
{/* if order is in a status that does not expire, do not show countdown */}
{[4, 12, 13, 14, 15, 16, 17, 18].includes(this.state.status) ? null : (
<>
>
)}
{/* If the user has a penalty/limit */}
{this.state.penalty ? (
<>
>
) : null}
{/* If the counterparty asked for collaborative cancel */}
{this.state.pending_cancel ? (
<>
{t('{{nickname}} is asking for a collaborative cancel', {
nickname: this.state.is_maker ? this.state.taker_nick : this.state.maker_nick,
})}
>
) : null}
{/* If the user has asked for a collaborative cancel */}
{this.state.asked_for_cancel ? (
<>
{t('You asked for a collaborative cancellation')}
>
) : null}
{/* Participants can see the "Cancel" Button, but cannot see the "Back" or "Take Order" buttons */}
{this.state.is_participant ? (
<>
{this.CancelButton()}
{this.BackButton()}
>
) : (
)}
);
};
doubleOrderPageDesktop = () => {
return (
{this.orderBox()}
);
};
a11yProps(index) {
return {
id: `simple-tab-${index}`,
'aria-controls': `simple-tabpanel-${index}`,
};
}
doubleOrderPagePhone = () => {
const { t } = this.props;
return (
this.setState({ tabValue: 0 })}
/>
this.setState({ tabValue: 1 })}
/>