2022-09-09 17:18:04 +00:00
import React , { Component } from 'react' ;
import { withTranslation , Trans } from 'react-i18next' ;
import {
Alert ,
AlertTitle ,
ToggleButtonGroup ,
ToggleButton ,
IconButton ,
Box ,
Link ,
Paper ,
Rating ,
Button ,
Tooltip ,
CircularProgress ,
Grid ,
Typography ,
TextField ,
List ,
ListItem ,
ListItemText ,
Divider ,
ListItemIcon ,
Dialog ,
DialogActions ,
DialogContent ,
DialogContentText ,
DialogTitle ,
} from '@mui/material' ;
import QRCode from 'react-qr-code' ;
import Countdown , { zeroPad } from 'react-countdown' ;
import Chat from './EncryptedChat' ;
import TradeSummary from './TradeSummary' ;
import MediaQuery from 'react-responsive' ;
import { copyToClipboard } from '../utils/clipboard' ;
2022-09-16 14:16:33 +00:00
import { apiClient } from '../services/api' ;
2022-01-13 19:22:54 +00:00
2022-01-14 13:31:54 +00:00
// Icons
import PercentIcon from '@mui/icons-material/Percent' ;
import BookIcon from '@mui/icons-material/Book' ;
2022-03-11 14:33:07 +00:00
import LockIcon from '@mui/icons-material/Lock' ;
import LockOpenIcon from '@mui/icons-material/LockOpen' ;
import BalanceIcon from '@mui/icons-material/Balance' ;
2022-09-09 17:18:04 +00:00
import ContentCopy from '@mui/icons-material/ContentCopy' ;
2022-04-29 18:54:20 +00:00
import PauseCircleIcon from '@mui/icons-material/PauseCircle' ;
import PlayCircleIcon from '@mui/icons-material/PlayCircle' ;
2022-06-11 13:12:09 +00:00
import BoltIcon from '@mui/icons-material/Bolt' ;
import LinkIcon from '@mui/icons-material/Link' ;
2022-05-16 13:03:01 +00:00
import AccountBalanceWalletIcon from '@mui/icons-material/AccountBalanceWallet' ;
2022-07-16 11:15:00 +00:00
import FavoriteIcon from '@mui/icons-material/Favorite' ;
2022-07-17 18:11:10 +00:00
import RocketLaunchIcon from '@mui/icons-material/RocketLaunch' ;
import RefreshIcon from '@mui/icons-material/Refresh' ;
2022-09-09 17:18:04 +00:00
import { NewTabIcon } from './Icons' ;
2022-01-14 13:31:54 +00:00
2022-09-09 17:18:04 +00:00
import { getCookie } from '../utils/cookies' ;
import { pn } from '../utils/prettyNumbers' ;
2022-01-09 01:23:13 +00:00
2022-04-05 14:25:53 +00:00
class TradeBox extends Component {
2022-04-15 23:26:39 +00:00
invoice _escrow _duration = 3 ;
2022-01-09 14:07:05 +00:00
constructor ( props ) {
super ( props ) ;
2022-01-11 01:02:06 +00:00
this . state = {
2022-01-17 23:11:41 +00:00
openConfirmFiatReceived : false ,
openConfirmDispute : false ,
2022-06-11 13:12:09 +00:00
receiveTab : 0 ,
2022-06-13 21:37:14 +00:00
address : '' ,
miningFee : 1.05 ,
2022-01-11 01:02:06 +00:00
badInvoice : false ,
2022-06-13 21:37:14 +00:00
badAddress : false ,
2022-01-16 21:54:42 +00:00
badStatement : false ,
2022-09-09 17:18:04 +00:00
} ;
2022-01-09 01:23:13 +00:00
}
2022-01-17 23:11:41 +00:00
2022-05-08 15:43:08 +00:00
Sound = ( soundFileName ) => (
2022-03-08 20:15:27 +00:00
// Four filenames: "locked-invoice", "taker-found", "open-chat", "successful"
2022-01-23 12:30:41 +00:00
< audio autoPlay src = { ` /static/assets/sounds/ ${ soundFileName } .mp3 ` } / >
2022-09-09 17:18:04 +00:00
) ;
2022-01-23 12:30:41 +00:00
2022-03-11 14:33:07 +00:00
stepXofY = ( ) => {
// set y value
2022-09-09 17:33:29 +00:00
let x = null ;
let y = null ;
const status = this . props . data . status ;
2022-03-11 14:33:07 +00:00
2022-09-09 17:18:04 +00:00
if ( this . props . data . is _maker ) {
y = 5 ;
}
if ( this . props . data . is _taker ) {
y = 4 ;
}
2022-03-11 14:33:07 +00:00
// set x values
2022-09-09 17:18:04 +00:00
if ( this . props . data . is _maker ) {
if ( status == 0 ) {
x = 1 ;
} else if ( [ 1 , 2 , 3 ] . includes ( status ) ) {
x = 2 ;
} else if ( [ 6 , 7 , 8 ] . includes ( status ) ) {
x = 3 ;
} else if ( status == 9 ) {
x = 4 ;
} else if ( status == 10 ) {
x = 5 ;
2022-03-11 14:33:07 +00:00
}
}
2022-09-09 17:18:04 +00:00
if ( this . props . data . is _taker ) {
if ( status == 3 ) {
x = 1 ;
} else if ( [ 6 , 7 , 8 ] . includes ( status ) ) {
x = 2 ;
} else if ( status == 9 ) {
x = 3 ;
} else if ( status == 10 ) {
x = 4 ;
2022-03-11 14:33:07 +00:00
}
}
// Return "(x/y)"
2022-09-09 17:18:04 +00:00
if ( ( x != null ) & ( y != null ) ) {
return '(' + x + '/' + y + ')' ;
} else {
return '' ;
2022-03-11 14:33:07 +00:00
}
2022-09-09 17:18:04 +00:00
} ;
2022-03-11 14:33:07 +00:00
2022-01-17 23:11:41 +00:00
handleClickOpenConfirmDispute = ( ) => {
2022-09-09 17:18:04 +00:00
this . setState ( { openConfirmDispute : true } ) ;
2022-01-17 23:11:41 +00:00
} ;
2022-09-09 17:33:29 +00:00
2022-01-17 23:11:41 +00:00
handleClickCloseConfirmDispute = ( ) => {
2022-09-09 17:18:04 +00:00
this . setState ( { openConfirmDispute : false } ) ;
2022-01-17 23:11:41 +00:00
} ;
2022-09-09 17:18:04 +00:00
handleClickAgreeDisputeButton = ( ) => {
2022-09-16 14:16:33 +00:00
apiClient . post ( '/api/order/?order_id=' + this . props . data . id , {
action : 'dispute' ,
} ) . then ( ( data ) => this . props . completeSetState ( data ) ) ;
2022-01-17 23:11:41 +00:00
this . handleClickCloseConfirmDispute ( ) ;
2022-09-09 17:18:04 +00:00
} ;
2022-01-17 23:11:41 +00:00
2022-09-09 17:18:04 +00:00
ConfirmDisputeDialog = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
return (
2022-01-17 23:11:41 +00:00
< Dialog
2022-09-09 17:18:04 +00:00
open = { this . state . openConfirmDispute }
onClose = { this . handleClickCloseConfirmDispute }
aria - labelledby = 'open-dispute-dialog-title'
aria - describedby = 'open-dispute-dialog-description'
2022-01-17 23:11:41 +00:00
>
2022-09-09 17:18:04 +00:00
< DialogTitle id = 'open-dispute-dialog-title' >
{ t ( 'Do you want to open a dispute?' ) }
2022-01-17 23:11:41 +00:00
< / D i a l o g T i t l e >
< DialogContent >
2022-09-09 17:18:04 +00:00
< DialogContentText id = 'alert-dialog-description' >
{ t (
'The RoboSats staff will examine the statements and evidence provided. You need to build a complete case, as the staff cannot read the chat. It is best to provide a burner contact method with your statement. The satoshis in the trade escrow will be sent to the dispute winner, while the dispute loser will lose the bond.' ,
) }
2022-01-17 23:11:41 +00:00
< / D i a l o g C o n t e n t T e x t >
2022-09-09 17:18:04 +00:00
< br / >
< DialogContentText id = 'alert-dialog-description' >
{ t (
'Make sure to EXPORT the chat log. The staff might request your exported chat log JSON in order to solve discrepancies. It is your responsibility to store it.' ,
) }
2022-06-04 17:29:21 +00:00
< / D i a l o g C o n t e n t T e x t >
2022-01-17 23:11:41 +00:00
< / D i a l o g C o n t e n t >
< DialogActions >
2022-09-09 17:18:04 +00:00
< Button onClick = { this . handleClickCloseConfirmDispute } autoFocus >
{ t ( 'Disagree' ) }
< / B u t t o n >
< Button onClick = { this . handleClickAgreeDisputeButton } >
{ t ( 'Agree and open dispute' ) }
< / B u t t o n >
2022-01-17 23:11:41 +00:00
< / D i a l o g A c t i o n s >
< / D i a l o g >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-01-17 23:11:41 +00:00
handleClickOpenConfirmFiatReceived = ( ) => {
2022-09-09 17:18:04 +00:00
this . setState ( { openConfirmFiatReceived : true } ) ;
2022-01-17 23:11:41 +00:00
} ;
2022-09-09 17:33:29 +00:00
2022-01-17 23:11:41 +00:00
handleClickCloseConfirmFiatReceived = ( ) => {
2022-09-09 17:18:04 +00:00
this . setState ( { openConfirmFiatReceived : false } ) ;
2022-01-17 23:11:41 +00:00
} ;
2022-09-09 17:18:04 +00:00
handleClickTotallyConfirmFiatReceived = ( ) => {
2022-01-17 23:11:41 +00:00
this . handleClickConfirmButton ( ) ;
this . handleClickCloseConfirmFiatReceived ( ) ;
} ;
2022-09-09 17:18:04 +00:00
ConfirmFiatReceivedDialog = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
return (
2022-01-17 23:11:41 +00:00
< Dialog
2022-09-09 17:18:04 +00:00
open = { this . state . openConfirmFiatReceived }
onClose = { this . handleClickCloseConfirmFiatReceived }
aria - labelledby = 'fiat-received-dialog-title'
aria - describedby = 'fiat-received-dialog-description'
2022-01-17 23:11:41 +00:00
>
2022-09-09 17:18:04 +00:00
< DialogTitle id = 'open-dispute-dialog-title' >
{ t ( 'Confirm you received {{amount}} {{currencyCode}}?' , {
currencyCode : this . props . data . currencyCode ,
amount : pn (
parseFloat (
parseFloat ( this . props . data . amount ) . toFixed (
this . props . data . currency == 1000 ? 8 : 4 ,
) ,
) ,
) ,
} ) }
2022-01-17 23:11:41 +00:00
< / D i a l o g T i t l e >
< DialogContent >
2022-09-09 17:18:04 +00:00
< DialogContentText id = 'alert-dialog-description' >
{ t (
'Confirming that you received the fiat will finalize the trade. The satoshis in the escrow will be released to the buyer. Only confirm after the {{amount}} {{currencyCode}} have arrived to your account. In addition, if you have received the payment and do not confirm it, you risk losing your bond.' ,
{
currencyCode : this . props . data . currencyCode ,
amount : pn (
parseFloat (
parseFloat ( this . props . data . amount ) . toFixed (
this . props . data . currency == 1000 ? 8 : 4 ,
) ,
) ,
) ,
} ,
) }
2022-01-17 23:11:41 +00:00
< / D i a l o g C o n t e n t T e x t >
< / D i a l o g C o n t e n t >
< DialogActions >
2022-09-09 17:18:04 +00:00
< Button onClick = { this . handleClickCloseConfirmFiatReceived } autoFocus >
{ t ( 'Go back' ) }
< / B u t t o n >
< Button onClick = { this . handleClickTotallyConfirmFiatReceived } > { t ( 'Confirm' ) } < / B u t t o n >
2022-01-17 23:11:41 +00:00
< / D i a l o g A c t i o n s >
< / D i a l o g >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-01-17 23:11:41 +00:00
2022-09-09 17:18:04 +00:00
showQRInvoice = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-01-08 13:08:03 +00:00
return (
< Grid container spacing = { 1 } >
2022-05-16 13:03:01 +00:00
{ / * < G r i d i t e m x s = { 1 2 } a l i g n = " c e n t e r " >
2022-05-08 15:43:08 +00:00
< Typography variant = "body2" >
2022-04-05 14:25:53 +00:00
{ t ( "Robots show commitment to their peers" ) }
2022-01-08 13:08:03 +00:00
< / T y p o g r a p h y >
2022-05-16 13:03:01 +00:00
< /Grid> */ }
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
{ this . props . data . is _maker ? (
< Typography color = 'primary' variant = 'subtitle1' >
< b >
{ t ( 'Lock {{amountSats}} Sats to PUBLISH order' , {
amountSats : pn ( this . props . data . bond _satoshis ) ,
} ) }
< / b > { ' ' }
{ ' ' + this . stepXofY ( ) }
< / T y p o g r a p h y >
) : (
< Typography color = 'primary' variant = 'subtitle1' >
< b >
{ t ( 'Lock {{amountSats}} Sats to TAKE order' , {
amountSats : pn ( this . props . data . bond _satoshis ) ,
} ) }
< / b > { ' ' }
{ ' ' + this . stepXofY ( ) }
< / T y p o g r a p h y >
) }
2022-01-08 13:08:03 +00:00
< / G r i d >
2022-05-16 13:03:01 +00:00
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-05-16 13:03:01 +00:00
{ this . compatibleWalletsButton ( ) }
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-09-11 16:39:05 +00:00
< QRCode
bgColor = { 'rgba(255, 255, 255, 0)' }
fgColor = { this . props . theme . palette . text . primary }
value = { this . props . data . bond _invoice }
size = { 305 }
/ >
2022-09-09 17:18:04 +00:00
< Tooltip disableHoverListener enterTouchDelay = { 0 } title = { t ( 'Copied!' ) } >
< Button
size = 'small'
color = 'inherit'
onClick = { ( ) => {
copyToClipboard ( this . props . data . bond _invoice ) ;
} }
align = 'center'
>
{ ' ' }
< ContentCopy / >
{ t ( 'Copy to clipboard' ) }
< / B u t t o n >
2022-03-11 14:33:07 +00:00
< / T o o l t i p >
2022-04-15 16:22:49 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< TextField
2022-01-08 13:08:03 +00:00
hiddenLabel
2022-09-09 17:18:04 +00:00
variant = 'standard'
size = 'small'
2022-04-15 16:22:49 +00:00
defaultValue = { this . props . data . bond _invoice }
2022-05-08 15:43:08 +00:00
disabled = { true }
2022-09-09 17:18:04 +00:00
helperText = { t (
'This is a hold invoice, it will freeze in your wallet. It will be charged only if you cancel or lose a dispute.' ,
) }
color = 'secondary'
2022-01-08 13:08:03 +00:00
/ >
< / G r i d >
< / G r i d >
) ;
2022-09-09 17:18:04 +00:00
} ;
2022-01-09 20:05:19 +00:00
2022-09-09 17:18:04 +00:00
showBondIsLocked = ( ) => {
const { t } = this . props ;
2022-01-12 12:57:03 +00:00
return (
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography color = 'primary' variant = 'subtitle1' align = 'center' >
< div
style = { {
display : 'flex' ,
alignItems : 'center' ,
justifyContent : 'center' ,
flexWrap : 'wrap' ,
} }
>
< LockIcon / >
{ this . props . data . is _maker
? t ( 'Your maker bond is locked' )
: t ( 'Your taker bond is locked' ) }
< / d i v >
< / T y p o g r a p h y >
< / G r i d >
2022-01-12 12:57:03 +00:00
) ;
2022-09-09 17:18:04 +00:00
} ;
2022-01-12 12:57:03 +00:00
2022-09-09 17:18:04 +00:00
showBondIsSettled = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-02-24 20:47:46 +00:00
return (
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography color = 'error' variant = 'subtitle1' align = 'center' >
< div
style = { {
display : 'flex' ,
alignItems : 'center' ,
justifyContent : 'center' ,
flexWrap : 'wrap' ,
align : 'center' ,
} }
align = 'center'
>
< BalanceIcon / >
{ this . props . data . is _maker
? t ( 'Your maker bond was settled' )
: t ( 'Your taker bond was settled' ) }
< / d i v >
< / T y p o g r a p h y >
< / G r i d >
2022-02-24 20:47:46 +00:00
) ;
2022-09-09 17:18:04 +00:00
} ;
2022-02-24 20:47:46 +00:00
2022-09-09 17:18:04 +00:00
showBondIsReturned = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-02-24 20:47:46 +00:00
return (
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography color = 'green' variant = 'subtitle1' align = 'center' >
< div
style = { {
display : 'flex' ,
alignItems : 'center' ,
justifyContent : 'center' ,
flexWrap : 'wrap' ,
} }
>
< LockOpenIcon / >
{ this . props . data . is _maker
? t ( 'Your maker bond was unlocked' )
: t ( 'Your taker bond was unlocked' ) }
< / d i v >
< / T y p o g r a p h y >
< / G r i d >
2022-02-24 20:47:46 +00:00
) ;
2022-09-09 17:18:04 +00:00
} ;
2022-02-24 20:47:46 +00:00
2022-09-09 17:18:04 +00:00
showEscrowQRInvoice = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-01-08 17:19:30 +00:00
return (
< Grid container spacing = { 1 } >
2022-07-02 14:38:26 +00:00
{ /* Make sound for Taker found or HTLC received. */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . is _maker ? this . Sound ( 'taker-found' ) : this . Sound ( 'locked-invoice' ) }
< Grid item xs = { 12 } align = 'center' >
< Typography color = 'orange' variant = 'subtitle1' >
2022-04-05 14:25:53 +00:00
< b >
2022-09-09 17:18:04 +00:00
{ t ( 'Lock {{amountSats}} Sats as collateral' , {
amountSats : pn ( this . props . data . escrow _satoshis ) ,
} ) }
< / b >
{ ' ' + this . stepXofY ( ) }
2022-01-08 17:19:30 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'body2' >
{ t (
'You risk losing your bond if you do not lock the collateral. Total time available is {{deposit_timer_hours}}h {{deposit_timer_minutes}}m.' ,
this . depositHoursMinutes ( ) ,
) }
2022-05-16 12:22:08 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-09-11 16:39:05 +00:00
< QRCode
bgColor = { 'rgba(255, 255, 255, 0)' }
fgColor = { this . props . theme . palette . text . primary }
value = { this . props . data . escrow _invoice }
size = { 305 }
/ >
2022-09-09 17:18:04 +00:00
< Tooltip disableHoverListener enterTouchDelay = { 0 } title = { t ( 'Copied!' ) } >
< Button
size = 'small'
color = 'inherit'
onClick = { ( ) => {
copyToClipboard ( this . props . data . escrow _invoice ) ;
} }
align = 'center'
>
{ ' ' }
< ContentCopy / >
{ t ( 'Copy to clipboard' ) }
< / B u t t o n >
2022-03-11 14:33:07 +00:00
< / T o o l t i p >
2022-04-15 16:22:49 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-04-15 16:22:49 +00:00
< TextField
2022-01-08 17:19:30 +00:00
hiddenLabel
2022-09-09 17:18:04 +00:00
variant = 'filled'
size = 'small'
2022-04-15 16:22:49 +00:00
defaultValue = { this . props . data . escrow _invoice }
2022-05-08 15:43:08 +00:00
disabled = { true }
2022-09-09 17:18:04 +00:00
helperText = { t (
'This is a hold invoice, it will freeze in your wallet. It will be released to the buyer once you confirm to have received the {{currencyCode}}.' ,
{ currencyCode : this . props . data . currencyCode } ,
) }
color = 'secondary'
2022-01-08 17:19:30 +00:00
/ >
< / G r i d >
2022-01-12 12:57:03 +00:00
{ this . showBondIsLocked ( ) }
2022-01-08 17:19:30 +00:00
< / G r i d >
) ;
2022-09-09 17:18:04 +00:00
} ;
2022-01-08 17:19:30 +00:00
2022-09-09 17:18:04 +00:00
showTakerFound = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-01-09 01:23:13 +00:00
return (
< Grid container spacing = { 1 } >
2022-07-02 14:38:26 +00:00
{ /* Make bell sound when taker is found. SUPRESSED: It's annoying, not the right moment! Play only after taker locks bon */ }
2022-09-09 17:18:04 +00:00
{ /* {this.Sound("taker-found")} */ }
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'subtitle1' >
< b > { t ( 'A taker has been found!' ) } < / b > { ' ' + t h i s . s t e p X o f Y ( ) }
2022-01-09 01:23:13 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Divider / >
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'body2' >
{ t (
'Please wait for the taker to lock a bond. If the taker does not lock a bond in time, the order will be made public again.' ,
) }
2022-01-09 01:23:13 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-01-12 12:57:03 +00:00
{ this . showBondIsLocked ( ) }
2022-01-09 01:23:13 +00:00
< / G r i d >
) ;
2022-09-09 17:18:04 +00:00
} ;
2022-01-09 01:23:13 +00:00
2022-09-09 17:18:04 +00:00
depositHoursMinutes = ( ) => {
2022-09-09 17:33:29 +00:00
const hours = parseInt ( this . props . data . escrow _duration / 3600 ) ;
const minutes = parseInt ( ( this . props . data . escrow _duration - hours * 3600 ) / 60 ) ;
const dict = { deposit _timer _hours : hours , deposit _timer _minutes : minutes } ;
2022-09-09 17:18:04 +00:00
return dict ;
} ;
2022-04-29 18:54:20 +00:00
2022-09-09 17:18:04 +00:00
handleClickPauseOrder = ( ) => {
this . props . completeSetState ( { pauseLoading : true } ) ;
2022-09-16 14:16:33 +00:00
apiClient . post ( '/api/order/?order_id=' + this . props . data . id , {
action : 'pause' ,
} ) . then ( ( data ) => this . props . getOrderDetails ( data . id ) ) ;
2022-09-09 17:18:04 +00:00
} ;
2022-02-22 10:34:48 +00:00
2022-09-09 17:18:04 +00:00
showMakerWait = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-01-08 15:34:09 +00:00
return (
< Grid container spacing = { 1 } >
2022-01-23 12:30:41 +00:00
{ /* Make confirmation sound for HTLC received. */ }
2022-09-09 17:18:04 +00:00
{ this . Sound ( 'locked-invoice' ) }
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'subtitle1' >
< b > { t ( 'Your order is public' ) } < / b > { ' ' + t h i s . s t e p X o f Y ( ) }
2022-01-08 15:34:09 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< List dense = { true } >
< Divider / >
2022-01-08 15:34:09 +00:00
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' align = 'left' >
{ 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 ( ) ,
) }
2022-05-08 15:43:08 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
2022-09-09 17:18:04 +00:00
2022-05-08 15:43:08 +00:00
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' align = 'left' >
{ t (
'If the order expires untaken, your bond will return to you (no action needed).' ,
) }
2022-01-08 15:34:09 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
2022-04-29 18:54:20 +00:00
2022-09-09 17:18:04 +00:00
< Divider / >
2022-04-15 16:22:49 +00:00
2022-04-29 18:54:20 +00:00
< Grid container >
< Grid item xs = { 10 } >
< ListItem >
< ListItemIcon >
2022-09-09 17:18:04 +00:00
< BookIcon / >
2022-04-29 18:54:20 +00:00
< / L i s t I t e m I c o n >
2022-09-09 17:18:04 +00:00
< ListItemText
primary = { this . props . data . num _similar _orders }
secondary = { t ( 'Public orders for {{currencyCode}}' , {
currencyCode : this . props . data . currencyCode ,
} ) }
/ >
2022-04-29 18:54:20 +00:00
< / L i s t I t e m >
< / G r i d >
2022-09-09 17:18:04 +00:00
2022-04-29 18:54:20 +00:00
< Grid item xs = { 2 } >
2022-09-09 17:18:04 +00:00
< div style = { { position : 'relative' , top : '7px' , right : '14px' } } >
{ this . props . pauseLoading ? (
< CircularProgress sx = { { width : '30px' , height : '30px' } } / >
) : (
< Tooltip
placement = 'top'
enterTouchDelay = { 500 }
enterDelay = { 700 }
enterNextDelay = { 2000 }
title = { t ( 'Pause the public order' ) }
>
< Button color = 'primary' onClick = { this . handleClickPauseOrder } >
< PauseCircleIcon sx = { { width : '36px' , height : '36px' } } / >
< / B u t t o n >
< / T o o l t i p >
) }
< / d i v >
2022-04-29 18:54:20 +00:00
< / G r i d >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Divider / >
< ListItem >
2022-01-14 13:31:54 +00:00
< ListItemIcon >
2022-09-09 17:18:04 +00:00
< PercentIcon / >
2022-01-14 13:31:54 +00:00
< / L i s t I t e m I c o n >
2022-09-09 17:18:04 +00:00
< ListItemText
primary = {
t ( 'Premium rank' ) + ' ' + parseInt ( this . props . data . premium _percentile * 100 ) + '%'
}
secondary = { t ( 'Among public {{currencyCode}} orders (higher is cheaper)' , {
currencyCode : this . props . data . currencyCode ,
} ) }
/ >
< / L i s t I t e m >
< Divider / >
2022-01-08 15:34:09 +00:00
< / L i s t >
< / G r i d >
2022-01-12 12:57:03 +00:00
{ this . showBondIsLocked ( ) }
2022-01-08 15:34:09 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-01-08 13:08:03 +00:00
2022-09-09 17:18:04 +00:00
showPausedOrder = ( ) => {
2022-04-29 18:54:20 +00:00
const { t } = this . props ;
return (
2022-09-09 17:18:04 +00:00
< Grid container align = 'center' spacing = { 1 } >
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'subtitle1' >
< b > { t ( 'Your order is paused' ) } < / b > { ' ' + t h i s . s t e p X o f Y ( ) }
2022-04-29 18:54:20 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-05-08 15:43:08 +00:00
< List dense = { true } >
2022-09-09 17:18:04 +00:00
< Divider / >
< ListItem >
< Typography variant = 'body2' align = 'left' >
{ t (
'Your public order has been paused. At the moment it cannot be seen or taken by other robots. You can choose to unpause it at any time.' ,
) }
2022-04-29 18:54:20 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
{ this . props . pauseLoading ? (
< CircularProgress / >
) : (
< Button color = 'primary' onClick = { this . handleClickPauseOrder } >
< PlayCircleIcon sx = { { width : '36px' , height : '36px' } } / >
{ t ( 'Unpause Order' ) }
< / B u t t o n >
) }
2022-04-29 18:54:20 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-04-29 18:54:20 +00:00
< / L i s t >
< / G r i d >
{ this . showBondIsLocked ( ) }
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-04-29 18:54:20 +00:00
2022-09-09 17:18:04 +00:00
handleInputInvoiceChanged = ( e ) => {
2022-01-09 14:07:05 +00:00
this . setState ( {
2022-09-09 17:18:04 +00:00
invoice : e . target . value ,
badInvoice : false ,
2022-01-09 14:07:05 +00:00
} ) ;
2022-09-09 17:18:04 +00:00
} ;
handleClickSubmitInvoiceButton = ( ) => {
this . setState ( { badInvoice : false } ) ;
2022-01-09 12:14:11 +00:00
2022-09-16 14:16:33 +00:00
apiClient . post ( '/api/order/?order_id=' + this . props . data . id , {
action : 'update_invoice' ,
invoice : this . state . invoice ,
} ) . then (
2022-09-09 17:18:04 +00:00
( data ) =>
this . setState ( { badInvoice : data . bad _invoice } ) & this . props . completeSetState ( data ) ,
) ;
} ;
2022-01-09 12:14:11 +00:00
2022-09-09 17:18:04 +00:00
handleInputAddressChanged = ( e ) => {
2022-06-13 21:37:14 +00:00
this . setState ( {
2022-09-09 17:18:04 +00:00
address : e . target . value ,
badAddress : false ,
2022-06-13 21:37:14 +00:00
} ) ;
2022-09-09 17:18:04 +00:00
} ;
2022-06-13 21:37:14 +00:00
2022-09-09 17:18:04 +00:00
handleMiningFeeChanged = ( e ) => {
2022-09-09 17:33:29 +00:00
let fee = e . target . value ;
2022-09-09 17:18:04 +00:00
if ( fee > 50 ) {
fee = 50 ;
2022-06-13 21:37:14 +00:00
}
this . setState ( {
2022-09-09 17:18:04 +00:00
miningFee : fee ,
2022-06-13 21:37:14 +00:00
} ) ;
2022-09-09 17:18:04 +00:00
} ;
2022-06-13 21:37:14 +00:00
2022-09-09 17:18:04 +00:00
handleClickSubmitAddressButton = ( ) => {
this . setState ( { badInvoice : false } ) ;
2022-06-13 21:37:14 +00:00
2022-09-16 14:16:33 +00:00
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 (
2022-09-09 17:18:04 +00:00
( data ) =>
this . setState ( { badAddress : data . bad _address } ) & this . props . completeSetState ( data ) ,
) ;
} ;
2022-06-13 21:37:14 +00:00
2022-09-09 17:18:04 +00:00
handleInputDisputeChanged = ( e ) => {
2022-01-16 21:54:42 +00:00
this . setState ( {
2022-09-09 17:18:04 +00:00
statement : e . target . value ,
badStatement : false ,
2022-01-16 21:54:42 +00:00
} ) ;
2022-09-09 17:18:04 +00:00
} ;
2022-01-16 21:54:42 +00:00
2022-09-09 17:18:04 +00:00
handleClickSubmitStatementButton = ( ) => {
this . setState ( { badInvoice : false } ) ;
2022-01-16 21:54:42 +00:00
2022-09-16 14:16:33 +00:00
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 ) ,
) ;
2022-09-09 17:18:04 +00:00
} ;
2022-01-28 00:17:20 +00:00
2022-09-09 17:18:04 +00:00
handleScan = ( data ) => {
2022-01-28 00:17:20 +00:00
if ( data ) {
this . setState ( {
2022-09-09 17:18:04 +00:00
invoice : data ,
} ) ;
2022-01-28 00:17:20 +00:00
}
2022-09-09 17:18:04 +00:00
} ;
2022-09-09 17:33:29 +00:00
2022-09-09 17:18:04 +00:00
handleError = ( err ) => {
console . error ( err ) ;
} ;
2022-01-28 00:17:20 +00:00
2022-09-09 17:18:04 +00:00
compatibleWalletsButton = ( ) => {
2022-05-16 13:03:01 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
return (
< Button
color = 'primary'
component = { Link }
href = { 'https://learn.robosats.com/docs/wallets/' }
target = '_blank'
align = 'center'
>
< AccountBalanceWalletIcon / >
{ t ( 'See Compatible Wallets' ) }
< NewTabIcon sx = { { width : 16 , height : 16 } } / >
2022-05-16 13:03:01 +00:00
< / B u t t o n >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-01-16 21:54:42 +00:00
2022-09-09 17:18:04 +00:00
showInputInvoice ( ) {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-01-09 14:07:05 +00:00
return (
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-07-02 14:38:26 +00:00
{ /* Make sound for Taker found or HTLC received. */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . is _maker ? this . Sound ( 'taker-found' ) : this . Sound ( 'locked-invoice' ) }
< Typography color = 'primary' variant = 'subtitle1' >
< b >
{ ' ' }
{ t ( 'Submit payout info for {{amountSats}} Sats' , {
amountSats : pn ( this . props . data . invoice _amount ) ,
} ) }
< / b > { ' ' }
{ ' ' + this . stepXofY ( ) }
2022-01-09 14:07:05 +00:00
< / T y p o g r a p h y >
2022-09-09 17:18:04 +00:00
< / G r i d >
2022-06-11 13:12:09 +00:00
< List dense = { true } >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-06-11 13:12:09 +00:00
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' >
{ t (
'Before letting you send {{amountFiat}} {{currencyCode}}, we want to make sure you are able to receive the BTC.' ,
{
amountFiat : pn (
parseFloat (
parseFloat ( this . props . data . amount ) . toFixed (
this . props . data . currency == 1000 ? 8 : 4 ,
) ,
) ,
) ,
currencyCode : this . props . data . currencyCode ,
} ,
) }
2022-06-11 13:12:09 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
2022-06-17 11:36:27 +00:00
< / L i s t >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< ToggleButtonGroup size = 'small' value = { this . state . receiveTab } exclusive >
< ToggleButton
value = { 0 }
disableRipple = { true }
onClick = { ( ) => this . setState ( { receiveTab : 0 } ) }
>
< div
style = { {
display : 'flex' ,
alignItems : 'center' ,
justifyContent : 'center' ,
flexWrap : 'wrap' ,
} }
>
< BoltIcon / > { t ( 'Lightning' ) }
< / d i v >
< / T o g g l e B u t t o n >
< ToggleButton
value = { 1 }
disabled = { ! this . props . data . swap _allowed }
onClick = { ( ) =>
this . setState ( {
receiveTab : 1 ,
miningFee : parseFloat ( this . props . data . suggested _mining _fee _rate ) ,
} )
}
>
< div
style = { {
display : 'flex' ,
alignItems : 'center' ,
justifyContent : 'center' ,
flexWrap : 'wrap' ,
} }
>
< LinkIcon / > { t ( 'Onchain' ) }
< / d i v >
< / T o g g l e B u t t o n >
2022-06-17 11:36:27 +00:00
< / T o g g l e B u t t o n G r o u p >
2022-05-16 13:03:01 +00:00
< / G r i d >
2022-06-11 13:12:09 +00:00
2022-09-09 17:18:04 +00:00
{ /* LIGHTNING PAYOUT TAB */ }
< div style = { { display : this . state . receiveTab == 0 ? '' : 'none' } } >
< div style = { { height : 15 } } / >
< Grid container spacing = { 1 } >
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'body2' >
{ t ( 'Submit a valid invoice for {{amountSats}} Satoshis.' , {
amountSats : pn ( this . props . data . invoice _amount ) ,
} ) }
< / T y p o g r a p h y >
< / G r i d >
2022-05-16 13:03:01 +00:00
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
{ this . compatibleWalletsButton ( ) }
< / G r i d >
2022-06-13 21:37:14 +00:00
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< TextField
error = { this . state . badInvoice }
helperText = { this . state . badInvoice ? t ( this . state . badInvoice ) : '' }
label = { t ( 'Payout Lightning Invoice' ) }
required
value = { this . state . invoice }
inputProps = { {
style : { textAlign : 'center' } ,
maxHeight : 200 ,
} }
multiline
minRows = { 4 }
maxRows = { 8 }
onChange = { this . handleInputInvoiceChanged }
/ >
< / G r i d >
< Grid item xs = { 12 } align = 'center' >
< Button
onClick = { this . handleClickSubmitInvoiceButton }
variant = 'contained'
color = 'primary'
>
{ t ( 'Submit' ) }
< / B u t t o n >
< / G r i d >
< / G r i d >
< / d i v >
2022-06-13 21:37:14 +00:00
2022-09-09 17:18:04 +00:00
{ /* ONCHAIN PAYOUT TAB */ }
< div style = { { display : this . state . receiveTab == 1 ? '' : 'none' } } >
< List dense = { true } >
< ListItem >
< Typography variant = 'body2' >
< b > { t ( 'EXPERIMENTAL: ' ) } < / b >
{ t ( 'RoboSats will do a swap and send the Sats to your onchain address.' ) }
< / T y p o g r a p h y >
< / L i s t I t e m >
2022-06-13 21:37:14 +00:00
2022-09-09 17:18:04 +00:00
< Divider / >
< ListItem >
< ListItemText
primary = {
pn (
parseInt (
( this . props . data . invoice _amount * this . props . data . swap _fee _rate ) / 100 ,
) ,
) +
' Sats (' +
this . props . data . swap _fee _rate +
'%)'
}
secondary = { t ( 'Swap fee' ) }
/ >
< / L i s t I t e m >
< Divider / >
< ListItem >
< ListItemText
primary = {
pn ( parseInt ( Math . max ( 1 , this . state . miningFee ) * 141 ) ) +
' Sats (' +
Math . max ( 1 , this . state . miningFee ) +
' Sats/vByte)'
}
secondary = { t ( 'Mining fee' ) }
/ >
< / L i s t I t e m >
< Divider / >
< ListItem >
< ListItemText
primary = {
< b >
{ pn (
parseInt (
this . props . data . invoice _amount -
Math . max ( 1 , this . state . miningFee ) * 141 -
( this . props . data . invoice _amount * this . props . data . swap _fee _rate ) / 100 ,
) ,
) + ' Sats' }
< / b >
}
secondary = { t ( 'Final amount you will receive' ) }
/ >
< / L i s t I t e m >
< / L i s t >
< TextField
error = { this . state . badAddress }
helperText = { this . state . badAddress ? t ( this . state . badAddress ) : '' }
label = { t ( 'Bitcoin Address' ) }
required
value = { this . state . invoice }
sx = { { width : 170 } }
inputProps = { {
style : { textAlign : 'center' } ,
} }
onChange = { this . handleInputAddressChanged }
/ >
< TextField
error = { this . state . miningFee < 1 || this . state . miningFee > 50 }
helperText = { this . state . miningFee < 1 || this . state . miningFee > 50 ? 'Invalid' : '' }
label = { t ( 'Mining Fee' ) }
required
sx = { { width : 110 } }
value = { this . state . miningFee }
type = 'number'
inputProps = { {
max : 50 ,
min : 1 ,
style : { textAlign : 'center' } ,
} }
onChange = { this . handleMiningFeeChanged }
/ >
< div style = { { height : 10 } } / >
< Grid item xs = { 12 } align = 'center' >
< Button
onClick = { this . handleClickSubmitAddressButton }
variant = 'contained'
color = 'primary'
>
{ t ( 'Submit' ) }
< / B u t t o n >
< / G r i d >
< / d i v >
2022-06-13 21:37:14 +00:00
< List >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-06-11 13:12:09 +00:00
< / L i s t >
2022-01-16 21:54:42 +00:00
{ this . showBondIsLocked ( ) }
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
2022-01-16 21:54:42 +00:00
}
// Asks the user for a dispute statement.
2022-09-09 17:18:04 +00:00
showInDisputeStatement = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
if ( this . props . data . statement _submitted ) {
2022-01-22 23:05:03 +00:00
return (
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography color = 'primary' variant = 'subtitle1' >
< b > { t ( 'We have received your statement' ) } < / b >
2022-01-22 23:05:03 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-05-08 16:46:27 +00:00
< List dense = { true } >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-05-08 16:46:27 +00:00
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' >
{ t (
'We are waiting for your trade counterpart statement. If you are hesitant about the state of the dispute or want to add more information, contact robosats@protonmail.com.' ,
) }
2022-05-08 16:46:27 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' >
{ t (
'Please, save the information needed to identify your order and your payments: order ID; payment hashes of the bonds or escrow (check on your lightning wallet); exact amount of satoshis; and robot nickname. You will have to identify yourself as the user involved in this trade via email (or other contact methods).' ,
) }
2022-05-08 16:46:27 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-05-08 16:46:27 +00:00
< / L i s t >
2022-01-22 23:05:03 +00:00
< / G r i d >
2022-02-24 20:47:46 +00:00
{ this . showBondIsSettled ( ) }
2022-01-22 23:05:03 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
} else {
2022-01-22 23:05:03 +00:00
return (
// TODO Option to upload files
2022-04-15 16:22:49 +00:00
2022-01-22 23:05:03 +00:00
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography color = 'primary' variant = 'subtitle1' >
< b > { t ( 'A dispute has been opened' ) } < / b >
2022-01-22 23:05:03 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-05-10 18:44:12 +00:00
< List dense = { true } >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-05-10 18:44:12 +00:00
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' >
{ t (
'Please, submit your statement. Be clear and specific about what happened and provide the necessary evidence. You MUST provide a contact method: burner email, XMPP or telegram username to follow up with the staff. Disputes are solved at the discretion of real robots (aka humans), so be as helpful as possible to ensure a fair outcome. Max 5000 chars.' ,
) }
2022-05-10 18:44:12 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
2022-04-15 16:22:49 +00:00
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< TextField
2022-01-22 23:05:03 +00:00
error = { this . state . badStatement }
2022-09-09 17:18:04 +00:00
helperText = { this . state . badStatement ? this . state . badStatement : '' }
label = { t ( 'Submit dispute statement' ) }
2022-01-22 23:05:03 +00:00
required
inputProps = { {
2022-09-09 17:18:04 +00:00
style : { textAlign : 'center' } ,
2022-01-22 23:05:03 +00:00
} }
multiline
rows = { 4 }
onChange = { this . handleInputDisputeChanged }
2022-09-09 17:18:04 +00:00
/ >
< / G r i d >
< Grid item xs = { 12 } align = 'center' >
< Button
onClick = { this . handleClickSubmitStatementButton }
variant = 'contained'
color = 'primary'
>
Submit
< / B u t t o n >
< / G r i d >
< / L i s t >
{ this . showBondIsSettled ( ) }
< / G r i d >
) ;
}
} ;
2022-01-09 14:07:05 +00:00
2022-09-09 17:18:04 +00:00
showWaitForDisputeResolution = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-01-25 14:46:02 +00:00
return (
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography color = 'primary' variant = 'subtitle1' >
< b > { t ( 'We have the statements' ) } < / b >
2022-01-25 14:46:02 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-05-10 18:44:12 +00:00
< List dense = { true } >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-05-10 18:44:12 +00:00
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' >
{ t (
'Both statements have been received, wait for the staff to resolve the dispute. If you are hesitant about the state of the dispute or want to add more information, contact robosats@protonmail.com. If you did not provide a contact method, or are unsure whether you wrote it right, write us immediately.' ,
) }
2022-05-10 18:44:12 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' >
{ t (
'Please, save the information needed to identify your order and your payments: order ID; payment hashes of the bonds or escrow (check on your lightning wallet); exact amount of satoshis; and robot nickname. You will have to identify yourself as the user involved in this trade via email (or other contact methods).' ,
) }
2022-05-10 18:44:12 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-05-10 18:44:12 +00:00
< / L i s t >
2022-01-25 14:46:02 +00:00
< / G r i d >
2022-02-24 20:47:46 +00:00
{ this . showBondIsSettled ( ) }
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-02-24 20:47:46 +00:00
2022-09-09 17:18:04 +00:00
showDisputeWinner = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-02-24 20:47:46 +00:00
return (
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography color = 'primary' variant = 'subtitle1' >
< b > { t ( 'You have won the dispute' ) } < / b >
2022-02-24 20:47:46 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'left' >
< Typography variant = 'body2' >
{ t (
'You can claim the dispute resolution amount (escrow and fidelity bond) from your profile rewards. If there is anything the staff can help with, do not hesitate to contact to robosats@protonmail.com (or via your provided burner contact method).' ,
) }
2022-02-24 20:47:46 +00:00
< / T y p o g r a p h y >
< / G r i d >
{ this . showBondIsSettled ( ) }
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-02-24 20:47:46 +00:00
2022-09-09 17:18:04 +00:00
showDisputeLoser = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-02-24 20:47:46 +00:00
return (
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography color = 'error' variant = 'subtitle1' >
< b > { t ( 'You have lost the dispute' ) } < / b >
2022-02-24 20:47:46 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'left' >
< Typography variant = 'body2' >
{ t (
'Unfortunately you have lost the dispute. If you think this is a mistake you can ask to re-open the case via email to robosats@protonmail.com. However, chances of it being investigated again are low.' ,
) }
2022-02-24 20:47:46 +00:00
< / T y p o g r a p h y >
< / G r i d >
{ this . showBondIsSettled ( ) }
2022-01-25 14:46:02 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-01-25 14:46:02 +00:00
2022-09-09 17:18:04 +00:00
showWaitingForEscrow ( ) {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
return (
2022-01-09 15:28:12 +00:00
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'subtitle1' >
< b > { t ( 'Your info looks good!' ) } < / b > { ' ' + t h i s . s t e p X o f Y ( ) }
2022-01-09 15:28:12 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-05-08 16:46:27 +00:00
< List dense = { true } >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-05-08 16:46:27 +00:00
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' align = 'left' >
{ t ( 'We are waiting for the seller to lock the trade amount.' ) }
2022-05-08 16:46:27 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' align = 'left' >
{ t (
'Just hang on for a moment. If the seller does not deposit, you will get your bond back automatically. In addition, you will receive a compensation (check the rewards in your profile).' ,
) }
2022-05-08 16:46:27 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-05-08 16:46:27 +00:00
< / L i s t >
2022-01-09 15:28:12 +00:00
< / G r i d >
2022-01-12 12:57:03 +00:00
{ this . showBondIsLocked ( ) }
2022-01-09 15:28:12 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
2022-01-09 15:28:12 +00:00
}
2022-09-09 17:18:04 +00:00
showWaitingForBuyerInvoice ( ) {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
return (
2022-01-09 15:28:12 +00:00
< Grid container spacing = { 1 } >
2022-01-23 12:30:41 +00:00
{ /* Make confirmation sound for HTLC received. */ }
2022-09-09 17:18:04 +00:00
{ this . Sound ( 'locked-invoice' ) }
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'subtitle1' >
< b > { t ( 'The trade collateral is locked!' ) } < / b > { ' ' + t h i s . s t e p X o f Y ( ) }
2022-01-09 15:28:12 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-05-08 16:46:27 +00:00
< List dense = { true } >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-05-08 16:46:27 +00:00
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' align = 'left' >
{ t (
'We are waiting for the buyer to post a lightning invoice. Once he does, you will be able to directly communicate the fiat payment details.' ,
) }
2022-05-08 16:46:27 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
< ListItem >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' align = 'left' >
{ t (
'Just hang on for a moment. If the buyer does not cooperate, you will get back the trade collateral and your bond automatically. In addition, you will receive a compensation (check the rewards in your profile).' ,
) }
2022-05-08 16:46:27 +00:00
< / T y p o g r a p h y >
< / L i s t I t e m >
2022-09-09 17:18:04 +00:00
< Divider / >
2022-05-08 16:46:27 +00:00
< / L i s t >
2022-01-09 15:28:12 +00:00
< / G r i d >
2022-01-12 12:57:03 +00:00
{ this . showBondIsLocked ( ) }
2022-01-09 15:28:12 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
2022-01-09 14:07:05 +00:00
}
2022-01-09 12:14:11 +00:00
2022-09-09 17:18:04 +00:00
handleClickConfirmButton = ( ) => {
2022-09-16 14:16:33 +00:00
apiClient . post ( '/api/order/?order_id=' + this . props . data . id , {
action : 'confirm' ,
} ) . then ( ( data ) => this . props . completeSetState ( data ) ) ;
2022-09-09 17:18:04 +00:00
} ;
2022-01-17 23:11:41 +00:00
2022-09-09 17:18:04 +00:00
handleRatingUserChange = ( e ) => {
2022-09-16 14:16:33 +00:00
apiClient . post ( '/api/order/?order_id=' + this . props . data . id , {
action : 'rate_user' ,
rating : e . target . value ,
} ) . then ( ( data ) => this . props . completeSetState ( data ) ) ;
2022-02-04 18:07:09 +00:00
} ;
2022-09-09 17:18:04 +00:00
handleRatingRobosatsChange = ( e ) => {
if ( this . state . rating _platform != null ) {
return null ;
}
this . setState ( { rating _platform : e . target . value } ) ;
2022-02-04 18:07:09 +00:00
2022-09-16 14:16:33 +00:00
apiClient . post ( '/api/order/?order_id=' + this . props . data . id , {
action : 'rate_platform' ,
rating : e . target . value ,
} ) . then ( ( data ) => this . props . completeSetState ( data ) ) ;
2022-01-11 20:49:53 +00:00
} ;
2022-01-09 12:14:11 +00:00
2022-09-09 17:18:04 +00:00
showFiatSentButton ( ) {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
return (
2022-01-09 15:28:12 +00:00
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Button
defaultValue = 'confirm'
variant = 'contained'
color = 'secondary'
onClick = { this . handleClickConfirmButton }
>
{ t ( 'Confirm {{amount}} {{currencyCode}} sent' , {
currencyCode : this . props . data . currencyCode ,
amount : pn (
parseFloat (
parseFloat ( this . props . data . amount ) . toFixed (
this . props . data . currency == 1000 ? 8 : 4 ,
) ,
) ,
) ,
} ) }
< / B u t t o n >
2022-01-09 20:05:19 +00:00
< / G r i d >
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
2022-01-09 20:05:19 +00:00
}
2022-09-09 17:18:04 +00:00
showFiatReceivedButton ( ) {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
return (
< Grid item xs = { 12 } align = 'center' >
< Button
defaultValue = 'confirm'
variant = 'contained'
color = 'secondary'
onClick = { this . handleClickOpenConfirmFiatReceived }
>
{ t ( 'Confirm {{amount}} {{currencyCode}} received' , {
currencyCode : this . props . data . currencyCode ,
amount : pn (
parseFloat (
parseFloat ( this . props . data . amount ) . toFixed (
this . props . data . currency == 1000 ? 8 : 4 ,
) ,
) ,
) ,
} ) }
< / B u t t o n >
< / G r i d >
) ;
2022-01-09 20:05:19 +00:00
}
2022-09-09 17:18:04 +00:00
disputeCountdownRenderer = ( { hours , minutes } ) => {
return (
< span >
{ hours } h { zeroPad ( minutes ) } m { ' ' }
< / s p a n >
) ;
2022-07-11 16:26:29 +00:00
} ;
2022-09-09 17:18:04 +00:00
showOpenDisputeButton ( ) {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:33:29 +00:00
const now = Date . now ( ) ;
const expires _at = new Date ( this . props . data . expires _at ) ;
2022-07-11 16:26:29 +00:00
// open dispute button enables 12h before expiry
expires _at . setHours ( expires _at . getHours ( ) - 12 ) ;
2022-09-09 17:18:04 +00:00
return (
< Tooltip
placement = 'top'
2022-07-28 21:14:37 +00:00
componentsProps = { {
2022-09-09 17:18:04 +00:00
tooltip : { sx : { position : 'relative' , top : 42 } } ,
2022-07-28 21:14:37 +00:00
} }
2022-09-09 17:18:04 +00:00
disableHoverListener = { now > expires _at }
disableTouchListener = { now > expires _at }
enterTouchDelay = { 0 }
title = {
< Trans i18nKey = 'open_dispute' >
2022-09-15 15:42:33 +00:00
To open a dispute you need to wait
2022-09-09 17:18:04 +00:00
< Countdown date = { expires _at } renderer = { this . disputeCountdownRenderer } / >
< / T r a n s >
}
>
< Grid item xs = { 12 } align = 'center' >
< Button
disabled = { now < expires _at }
color = 'inherit'
onClick = { this . handleClickOpenConfirmDispute }
>
{ t ( 'Open Dispute' ) }
< / B u t t o n >
2022-01-09 20:05:19 +00:00
< / G r i d >
2022-07-11 16:26:29 +00:00
< / T o o l t i p >
2022-09-09 17:18:04 +00:00
) ;
2022-01-09 20:05:19 +00:00
}
2022-09-09 17:18:04 +00:00
handleRenewOrderButtonPressed = ( ) => {
this . setState ( { renewLoading : true } ) ;
2022-09-16 14:16:33 +00:00
const body = {
type : this . props . data . type ,
currency : this . props . data . currency ,
amount : this . props . data . has _range ? null : this . props . data . amount ,
has _range : this . props . data . has _range ,
min _amount : this . props . data . min _amount ,
max _amount : this . props . data . max _amount ,
payment _method : this . props . data . payment _method ,
is _explicit : this . props . data . is _explicit ,
premium : this . props . data . is _explicit ? null : this . props . data . premium ,
satoshis : this . props . data . is _explicit ? this . props . data . satoshis : null ,
public _duration : this . props . data . public _duration ,
escrow _duration : this . props . data . escrow _duration ,
bond _size : this . props . data . bond _size ,
bondless _taker : this . props . data . bondless _taker ,
2022-04-29 18:54:20 +00:00
} ;
2022-09-16 14:16:33 +00:00
apiClient . post ( '/api/make/' , body )
2022-09-09 17:18:04 +00:00
. then (
( data ) =>
this . setState ( { badRequest : data . bad _request } ) &
( data . id
? this . props . push ( '/order/' + data . id ) & this . props . getOrderDetails ( data . id )
: '' ) ,
) ;
} ;
2022-04-29 18:54:20 +00:00
2022-09-09 17:18:04 +00:00
showOrderExpired = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:33:29 +00:00
const show _renew = this . props . data . is _maker ;
2022-04-29 18:54:20 +00:00
2022-09-09 17:18:04 +00:00
return (
2022-01-18 15:45:04 +00:00
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'subtitle1' >
< b > { t ( 'The order has expired' ) } < / b >
2022-01-18 15:45:04 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-04-29 18:54:20 +00:00
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'body2' > { t ( this . props . data . expiry _message ) } < / T y p o g r a p h y >
2022-04-29 18:54:20 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
{ show _renew ? (
< Grid item xs = { 12 } align = 'center' >
{ this . state . renewLoading ? (
< CircularProgress / >
) : (
< Button
variant = 'contained'
color = 'primary'
onClick = { this . handleRenewOrderButtonPressed }
>
{ t ( 'Renew Order' ) }
< / B u t t o n >
) }
2022-04-29 18:54:20 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) : null }
2022-01-18 15:45:04 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-01-18 15:45:04 +00:00
2022-09-09 17:18:04 +00:00
showChat = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:33:29 +00:00
// In Chatroom - No fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton)
2022-09-09 17:18:04 +00:00
if ( this . props . data . is _buyer & ( this . props . data . status == 9 ) ) {
var showSendButton = true ;
var showReveiceButton = false ;
var showDisputeButton = true ;
}
if ( this . props . data . is _seller & ( this . props . data . status == 9 ) ) {
var showSendButton = false ;
var showReveiceButton = false ;
var showDisputeButton = true ;
}
2022-04-15 16:22:49 +00:00
2022-09-09 17:33:29 +00:00
// In Chatroom - Fiat sent - showChat(showSendButton, showReveiceButton, showDisputeButton)
2022-09-09 17:18:04 +00:00
if ( this . props . data . is _buyer & ( this . props . data . status == 10 ) ) {
var showSendButton = false ;
var showReveiceButton = false ;
var showDisputeButton = true ;
}
if ( this . props . data . is _seller & ( this . props . data . status == 10 ) ) {
var showSendButton = false ;
var showReveiceButton = true ;
var showDisputeButton = true ;
}
2022-04-15 16:22:49 +00:00
2022-09-09 17:18:04 +00:00
return (
2022-01-09 20:05:19 +00:00
< Grid container spacing = { 1 } >
2022-01-23 12:30:41 +00:00
{ /* Make confirmation sound for Chat Open. */ }
2022-09-09 17:18:04 +00:00
{ this . Sound ( 'locked-invoice' ) }
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'subtitle1' >
< b >
{ ' ' }
{ this . props . data . is _seller ? t ( 'Chat with the buyer' ) : t ( 'Chat with the seller' ) }
< / b > { ' ' }
{ ' ' + this . stepXofY ( ) }
2022-01-09 20:05:19 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
{ this . props . data . is _seller ? (
< Typography variant = 'body2' align = 'center' >
{ this . props . data . status == 9
? t (
'Say hi! Be helpful and concise. Let them know how to send you {{amount}} {{currencyCode}}.' ,
{
currencyCode : this . props . data . currencyCode ,
amount : pn (
parseFloat (
parseFloat ( this . props . data . amount ) . toFixed (
this . props . data . currency == 1000 ? 8 : 4 ,
) ,
) ,
) ,
} ,
)
: t ( "The buyer has sent the fiat. Click 'Confirm Received' once you receive it." ) }
< / T y p o g r a p h y >
) : (
< Typography variant = 'body2' align = 'center' >
{ this . props . data . status == 9
? t (
"Say hi! Ask for payment details and click 'Confirm Sent' as soon as the payment is sent." ,
)
: t ( 'Wait for the seller to confirm he has received the payment.' ) }
< / T y p o g r a p h y >
) }
2022-01-09 20:05:19 +00:00
< / G r i d >
2022-01-13 19:22:54 +00:00
2022-09-09 17:18:04 +00:00
< Chat orderId = { this . props . data . id } ur _nick = { this . props . data . ur _nick } / >
< Grid item xs = { 12 } align = 'center' >
{ showDisputeButton ? this . showOpenDisputeButton ( ) : '' }
{ showSendButton ? this . showFiatSentButton ( ) : '' }
{ showReveiceButton ? this . showFiatReceivedButton ( ) : '' }
2022-01-09 15:28:12 +00:00
< / G r i d >
2022-01-12 12:57:03 +00:00
{ this . showBondIsLocked ( ) }
2022-01-09 15:28:12 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-01-09 15:28:12 +00:00
2022-09-09 17:18:04 +00:00
showRateSelect ( ) {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:33:29 +00:00
const show _renew = this . props . data . is _maker ;
2022-05-03 20:21:04 +00:00
2022-09-09 17:18:04 +00:00
return (
2022-01-11 20:49:53 +00:00
< Grid container spacing = { 1 } >
2022-01-23 12:30:41 +00:00
{ /* Make confirmation sound for Chat Open. */ }
2022-09-09 17:18:04 +00:00
{ this . Sound ( 'successful' ) }
< Grid item xs = { 12 } align = 'center' >
< Typography component = 'h6' variant = 'h6' >
< div
style = { {
display : 'flex' ,
alignItems : 'center' ,
flexWrap : 'wrap' ,
justifyContent : 'center' ,
} }
>
< BoltIcon sx = { { width : 25 , height : 37 } } color = 'warning' / >
{ t ( 'Trade finished!' ) }
< BoltIcon sx = { { width : 25 , height : 37 } } color = 'warning' / >
2022-07-16 11:15:00 +00:00
< / d i v >
2022-01-11 20:49:53 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'body2' align = 'center' >
< Trans i18nKey = 'rate_robosats' >
What do you think of < b > RoboSats < / b > ?
< / T r a n s >
2022-02-04 18:07:09 +00:00
< / T y p o g r a p h y >
2022-01-11 20:49:53 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Rating
name = 'size-large'
defaultValue = { 0 }
size = 'large'
onChange = { this . handleRatingRobosatsChange }
/ >
2022-02-04 18:07:09 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
{ this . state . rating _platform == 5 ? (
< Grid item xs = { 12 } align = 'center' >
< div
style = { {
display : 'flex' ,
alignItems : 'center' ,
flexWrap : 'wrap' ,
justifyContent : 'center' ,
} }
>
< Typography variant = 'body2' align = 'center' >
< b > { t ( 'Thank you! RoboSats loves you too' ) } < / b > { ' ' }
< / T y p o g r a p h y >
< FavoriteIcon color = 'error' / >
< / d i v >
< Typography variant = 'body2' align = 'center' >
{ t (
'RoboSats gets better with more liquidity and users. Tell a bitcoiner friend about Robosats!' ,
) }
< / T y p o g r a p h y >
< / G r i d >
) : null }
{ ( this . state . rating _platform != 5 ) & ( this . state . rating _platform != null ) ? (
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'body2' align = 'center' >
< b > { t ( 'Thank you for using Robosats!' ) } < / b >
< / T y p o g r a p h y >
< Typography variant = 'body2' align = 'center' >
< Trans i18nKey = 'let_us_know_hot_to_improve' >
Let us know how the platform could improve (
< Link target = '_blank' href = 'https://t.me/robosats' >
Telegram
< / L i n k > { ' ' }
/ { ' ' }
< Link target = '_blank' href = 'https://github.com/Reckless-Satoshi/robosats/issues' >
Github
< / L i n k >
)
< / T r a n s >
< / T y p o g r a p h y >
< / G r i d >
) : null }
2022-06-16 15:31:30 +00:00
{ /* SHOW TXID IF USER RECEIVES ONCHAIN */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . txid ? (
< Grid item xs = { 12 } align = 'left' >
< Alert severity = 'success' >
< AlertTitle >
{ t ( 'Your TXID' ) }
< Tooltip disableHoverListener enterTouchDelay = { 0 } title = { t ( 'Copied!' ) } >
< IconButton
color = 'inherit'
onClick = { ( ) => {
copyToClipboard ( this . props . data . txid ) ;
} }
>
< ContentCopy sx = { { width : 16 , height : 16 } } / >
2022-06-16 20:01:10 +00:00
< / I c o n B u t t o n >
< / T o o l t i p >
< / A l e r t T i t l e >
2022-09-09 17:18:04 +00:00
< Typography
variant = 'body2'
align = 'center'
sx = { { wordWrap : 'break-word' , width : 220 } }
>
< Link
target = '_blank'
href = {
'http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhhj6mlo2r6ad.onion/' +
( this . props . data . network == 'testnet' ? 'testnet/' : '' ) +
'tx/' +
this . props . data . txid
}
>
{ this . props . data . txid }
< / L i n k >
2022-06-16 20:01:10 +00:00
< / T y p o g r a p h y >
< / A l e r t >
2022-06-16 15:31:30 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) : null }
2022-06-16 15:31:30 +00:00
2022-07-17 18:11:10 +00:00
< Grid item container spacing = { 3 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { show _renew ? 6 : 12 } align = 'center' >
< Button
color = 'primary'
variant = 'outlined'
onClick = { ( ) => {
this . props . push ( '/' ) ;
} }
>
< RocketLaunchIcon / >
{ t ( 'Start Again' ) }
< / B u t t o n >
2022-07-16 11:15:00 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
{ show _renew ? (
< Grid item xs = { 6 } align = 'center' >
{ this . state . renewLoading ? (
< CircularProgress / >
) : (
< Button
color = 'primary'
variant = 'outlined'
onClick = { this . handleRenewOrderButtonPressed }
>
< RefreshIcon / >
{ t ( 'Renew Order' ) }
< / B u t t o n >
) }
2022-07-16 11:15:00 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) : null }
2022-01-11 20:49:53 +00:00
< / G r i d >
2022-05-03 20:21:04 +00:00
2022-09-09 17:18:04 +00:00
< TradeSummary
isMaker = { this . props . data . is _maker }
makerNick = { this . props . data . maker _nick }
takerNick = { this . props . data . taker _nick }
currencyCode = { this . props . data . currencyCode }
makerSummary = { this . props . data . maker _summary }
takerSummary = { this . props . data . taker _summary }
platformSummary = { this . props . data . platform _summary }
orderId = { this . props . data . orderId }
/ >
< / G r i d >
) ;
2022-01-11 20:49:53 +00:00
}
2022-01-09 12:14:11 +00:00
2022-09-09 17:18:04 +00:00
showSendingPayment ( ) {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
return (
2022-01-23 21:56:26 +00:00
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography component = 'h6' variant = 'h6' >
{ t ( 'Attempting Lightning Payment' ) }
2022-01-23 21:56:26 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'body2' align = 'center' >
{ t (
'RoboSats is trying to pay your lightning invoice. Remember that lightning nodes must be online in order to receive payments.' ,
) }
2022-01-23 21:56:26 +00:00
< / T y p o g r a p h y >
2022-09-09 17:18:04 +00:00
< br / >
< Grid item xs = { 12 } align = 'center' >
< CircularProgress / >
< / G r i d >
2022-01-23 21:56:26 +00:00
< / G r i d >
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
2022-01-23 21:56:26 +00:00
}
2022-04-15 16:22:49 +00:00
// Countdown Renderer callback with condition
2022-02-04 18:07:09 +00:00
countdownRenderer = ( { minutes , seconds , completed } ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-02-04 18:07:09 +00:00
if ( completed ) {
// Render a completed state
2022-09-09 17:18:04 +00:00
return (
< div align = 'center' >
< span > { t ( 'Retrying!' ) } < / s p a n >
< br / >
< CircularProgress / >
< / d i v >
) ;
2022-02-04 18:07:09 +00:00
} else {
return (
2022-09-09 17:18:04 +00:00
< span >
{ zeroPad ( minutes ) } m { zeroPad ( seconds ) } s { ' ' }
< / s p a n >
2022-02-04 18:07:09 +00:00
) ;
}
2022-07-11 16:26:29 +00:00
} ;
2022-09-09 17:18:04 +00:00
failureReason = ( ) => {
2022-05-19 14:00:55 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
return (
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'body2' align = 'center' >
< b > { t ( 'Failure reason:' ) } < / b >
2022-05-19 14:00:55 +00:00
< / T y p o g r a p h y >
2022-09-09 17:18:04 +00:00
< Typography variant = 'body2' align = 'center' >
2022-05-19 14:00:55 +00:00
{ t ( this . props . data . failure _reason ) }
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
} ;
2022-02-04 18:07:09 +00:00
2022-09-09 17:18:04 +00:00
showRoutingFailed = ( ) => {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-09-09 17:18:04 +00:00
if ( this . props . data . invoice _expired ) {
return (
2022-01-24 22:53:55 +00:00
< Grid container spacing = { 1 } >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography component = 'h6' variant = 'h6' >
{ t ( 'Lightning Routing Failed' ) }
2022-01-24 22:53:55 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-05-19 14:43:04 +00:00
2022-09-09 17:18:04 +00:00
{ this . props . data . failure _reason ? this . failureReason ( ) : null }
2022-05-19 14:43:04 +00:00
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'body2' align = 'center' >
{ t (
'Your invoice has expired or more than 3 payment attempts have been made. Submit a new invoice.' ,
) }
2022-01-24 22:53:55 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-05-16 20:57:44 +00:00
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-05-16 20:57:44 +00:00
{ this . compatibleWalletsButton ( ) }
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography color = 'primary' variant = 'subtitle1' >
< b >
{ ' ' }
{ t ( 'Submit an invoice for {{amountSats}} Sats' , {
amountSats : pn ( this . props . data . invoice _amount ) ,
} ) }
< / b >
2022-01-24 22:53:55 +00:00
< / T y p o g r a p h y >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-04-15 16:22:49 +00:00
< TextField
2022-09-09 17:18:04 +00:00
error = { this . state . badInvoice }
helperText = { this . state . badInvoice ? t ( this . state . badInvoice ) : '' }
label = { t ( 'Payout Lightning Invoice' ) }
required
inputProps = { {
style : { textAlign : 'center' } ,
} }
multiline
minRows = { 4 }
maxRows = { 8 }
onChange = { this . handleInputInvoiceChanged }
2022-01-24 22:53:55 +00:00
/ >
< / G r i d >
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Button
onClick = { this . handleClickSubmitInvoiceButton }
variant = 'contained'
color = 'primary'
>
Submit
< / B u t t o n >
2022-01-24 22:53:55 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
{ this . showBondIsReturned ( ) }
2022-01-23 21:56:26 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
} else {
return (
< Grid container spacing = { 1 } >
< Grid item xs = { 12 } align = 'center' >
< Typography component = 'h6' variant = 'h6' >
{ t ( 'Lightning Routing Failed' ) }
< / T y p o g r a p h y >
< / G r i d >
2022-05-19 14:00:55 +00:00
2022-09-09 17:18:04 +00:00
{ this . props . data . failure _reason ? this . failureReason ( ) : null }
2022-05-19 14:43:04 +00:00
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
< Typography variant = 'body2' align = 'center' >
{ t (
'RoboSats will try to pay your invoice 3 times with a one minute pause in between. If it keeps failing, you will be able to submit a new invoice. Check whether you have enough inbound liquidity. Remember that lightning nodes must be online in order to receive payments.' ,
) }
< / T y p o g r a p h y >
< List >
< Divider / >
< ListItemText secondary = { t ( 'Next attempt in' ) } >
< Countdown
date = { new Date ( this . props . data . next _retry _time ) }
renderer = { this . countdownRenderer }
/ >
< / L i s t I t e m T e x t >
< / L i s t >
< / G r i d >
{ this . showBondIsReturned ( ) }
2022-01-23 21:56:26 +00:00
< / G r i d >
2022-09-09 17:18:04 +00:00
) ;
}
} ;
2022-01-23 21:56:26 +00:00
2022-01-08 13:08:03 +00:00
render ( ) {
2022-04-05 14:25:53 +00:00
const { t } = this . props ;
2022-01-08 13:08:03 +00:00
return (
2022-09-09 17:18:04 +00:00
< Grid container spacing = { 1 } style = { { width : this . props . width } } >
2022-05-05 21:28:54 +00:00
{ this . ConfirmDisputeDialog ( ) }
{ this . ConfirmFiatReceivedDialog ( ) }
2022-09-09 17:18:04 +00:00
< Grid item xs = { 12 } align = 'center' >
2022-01-27 22:51:57 +00:00
< MediaQuery minWidth = { 920 } >
2022-09-09 17:18:04 +00:00
< Typography component = 'h5' variant = 'h5' >
{ t ( 'Contract Box' ) }
2022-01-27 22:51:57 +00:00
< / T y p o g r a p h y >
< / M e d i a Q u e r y >
2022-09-09 17:18:04 +00:00
< Paper elevation = { 12 } style = { { padding : 8 } } >
2022-01-09 12:14:11 +00:00
{ /* Maker and taker Bond request */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . is _maker & ( this . props . data . status == 0 ) ? this . showQRInvoice ( ) : '' }
{ this . props . data . is _taker & ( this . props . data . status == 3 ) ? this . showQRInvoice ( ) : '' }
2022-01-09 12:14:11 +00:00
{ /* Waiting for taker and taker bond request */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . is _maker & ( this . props . data . status == 2 ) ? this . showPausedOrder ( ) : '' }
{ this . props . data . is _maker & ( this . props . data . status == 1 ) ? this . showMakerWait ( ) : '' }
{ this . props . data . is _maker & ( this . props . data . status == 3 ) ? this . showTakerFound ( ) : '' }
2022-01-09 12:14:11 +00:00
{ /* Send Invoice (buyer) and deposit collateral (seller) */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . is _seller &
( this . props . data . status == 6 || this . props . data . status == 7 )
? this . showEscrowQRInvoice ( )
: '' }
{ this . props . data . is _buyer & ( this . props . data . status == 6 || this . props . data . status == 8 )
? this . showInputInvoice ( )
: '' }
{ this . props . data . is _buyer & ( this . props . data . status == 7 )
? this . showWaitingForEscrow ( )
: '' }
{ this . props . data . is _seller & ( this . props . data . status == 8 )
? this . showWaitingForBuyerInvoice ( )
: '' }
2022-01-09 12:14:11 +00:00
2022-01-19 22:44:31 +00:00
{ /* In Chatroom */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . status == 9 || this . props . data . status == 10 ? this . showChat ( ) : '' }
2022-01-09 12:14:11 +00:00
{ /* Trade Finished */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . is _seller & [ 13 , 14 , 15 ] . includes ( this . props . data . status )
? this . showRateSelect ( )
: '' }
{ this . props . data . is _buyer & ( this . props . data . status == 14 ) ? this . showRateSelect ( ) : '' }
2022-01-11 20:49:53 +00:00
{ /* Trade Finished - Payment Routing Failed */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . is _buyer & ( this . props . data . status == 13 )
? this . showSendingPayment ( )
: '' }
2022-01-23 21:56:26 +00:00
{ /* Trade Finished - Payment Routing Failed */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . is _buyer & ( this . props . data . status == 15 )
? this . showRoutingFailed ( )
: '' }
2022-01-11 20:49:53 +00:00
2022-01-16 21:54:42 +00:00
{ /* Trade Finished - TODO Needs more planning */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . status == 11 ? this . showInDisputeStatement ( ) : '' }
{ this . props . data . status == 16 ? this . showWaitForDisputeResolution ( ) : '' }
{ ( this . props . data . status == 17 ) & this . props . data . is _taker ||
( this . props . data . status == 18 ) & this . props . data . is _maker
? this . showDisputeWinner ( )
: '' }
{ ( this . props . data . status == 18 ) & this . props . data . is _taker ||
( this . props . data . status == 17 ) & this . props . data . is _maker
? this . showDisputeLoser ( )
: '' }
2022-02-24 20:47:46 +00:00
2022-01-18 15:45:04 +00:00
{ /* Order has expired */ }
2022-09-09 17:18:04 +00:00
{ this . props . data . status == 5 ? this . showOrderExpired ( ) : '' }
{ /* TODO */ }
{ /* */ }
{ /* */ }
2022-01-08 13:08:03 +00:00
< / P a p e r >
< / G r i d >
< / G r i d >
) ;
}
2022-04-05 14:25:53 +00:00
}
2022-04-15 16:22:49 +00:00
export default withTranslation ( ) ( TradeBox ) ;