2018-01-02 18:04:50 +00:00
|
|
|
import React from 'react';
|
|
|
|
import './SupportFooter.scss';
|
|
|
|
import { SwapInput } from 'actions/swap';
|
|
|
|
import { NormalizedBityRates, NormalizedShapeshiftRates } from 'reducers/swap/types';
|
2018-03-01 17:53:29 +00:00
|
|
|
import { TextArea } from 'components/ui';
|
2018-03-22 03:50:25 +00:00
|
|
|
import translate from 'translations';
|
2018-01-02 18:04:50 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
origin: SwapInput;
|
|
|
|
destination: SwapInput;
|
|
|
|
destinationAddress: string | null;
|
|
|
|
paymentAddress: string | null;
|
|
|
|
reference: string | null;
|
|
|
|
provider: string;
|
|
|
|
shapeshiftRates: NormalizedShapeshiftRates;
|
|
|
|
bityRates: NormalizedBityRates;
|
|
|
|
}
|
|
|
|
|
2018-01-29 19:13:46 +00:00
|
|
|
class SupportFooter extends React.PureComponent<Props, {}> {
|
2018-01-02 18:04:50 +00:00
|
|
|
public state = {
|
|
|
|
open: false
|
|
|
|
};
|
|
|
|
public render() {
|
|
|
|
const { open } = this.state;
|
|
|
|
const {
|
|
|
|
origin,
|
|
|
|
destination,
|
|
|
|
destinationAddress,
|
|
|
|
paymentAddress,
|
|
|
|
reference,
|
|
|
|
provider,
|
|
|
|
shapeshiftRates,
|
|
|
|
bityRates
|
|
|
|
} = this.props;
|
2018-03-01 17:53:29 +00:00
|
|
|
const pair = origin && destination ? origin.label + destination.label : 'BTCETH';
|
2018-01-02 18:04:50 +00:00
|
|
|
const rates = provider === 'shapeshift' ? shapeshiftRates.byId : bityRates.byId;
|
|
|
|
const emailTo =
|
2018-02-07 04:28:28 +00:00
|
|
|
provider === 'shapeshift' ? 'support@mycrypto.com' : 'support@mycrypto.com,mew@bity.com';
|
|
|
|
const mailSubject = encodeURI('Issue regarding my Swap via MyCrypto');
|
2018-01-02 18:04:50 +00:00
|
|
|
const serviceProvider = provider.charAt(0).toUpperCase() + provider.slice(1);
|
|
|
|
let mailBody;
|
|
|
|
let fallbackBody;
|
|
|
|
if (pair && rates && rates[pair]) {
|
|
|
|
mailBody = encodeURI(`Please include the below if this issue is regarding your order.
|
|
|
|
|
|
|
|
Provider: ${serviceProvider}
|
|
|
|
|
|
|
|
REF ID#: ${reference || ''}
|
|
|
|
|
2018-03-01 17:53:29 +00:00
|
|
|
Amount to send: ${origin.amount || ''} ${origin.label}
|
2018-01-02 18:04:50 +00:00
|
|
|
|
2018-03-01 17:53:29 +00:00
|
|
|
Amount to receive: ${destination.amount || ''} ${destination.label}
|
2018-01-02 18:04:50 +00:00
|
|
|
|
|
|
|
Payment Address: ${paymentAddress || ''}
|
|
|
|
|
|
|
|
Receiving Address: ${destinationAddress || ''}
|
|
|
|
|
2018-03-01 17:53:29 +00:00
|
|
|
Rate: ${rates[pair].rate} ${origin.label}/${destination.label}
|
2018-01-02 18:04:50 +00:00
|
|
|
`);
|
|
|
|
fallbackBody = `To: ${emailTo}
|
2018-02-07 04:28:28 +00:00
|
|
|
Subject: Issue regarding my Swap via MyCrypto
|
2018-01-02 18:04:50 +00:00
|
|
|
Message:
|
|
|
|
Provider: ${serviceProvider}
|
|
|
|
REF ID#: ${reference || ''}
|
2018-03-01 17:53:29 +00:00
|
|
|
Amount to send: ${origin.amount || ''} ${origin.label}
|
|
|
|
Amount to receive: ${destination.amount || ''} ${destination.label}
|
2018-01-02 18:04:50 +00:00
|
|
|
Payment Address: ${paymentAddress || ''}
|
|
|
|
Receiving Address: ${destinationAddress || ''}
|
2018-03-01 17:53:29 +00:00
|
|
|
Rate: ${rates[pair].rate} ${origin.label}/${destination.label}`;
|
2018-01-02 18:04:50 +00:00
|
|
|
}
|
|
|
|
return (
|
|
|
|
<section className="SupportFooter">
|
|
|
|
<a
|
|
|
|
className="btn-warning btn-sm"
|
|
|
|
href={`mailto:${emailTo}?Subject=${mailSubject}&Body=${mailBody}`}
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
2018-03-22 03:50:25 +00:00
|
|
|
{translate('SWAP_SUPPORT')}
|
2018-01-02 18:04:50 +00:00
|
|
|
</a>
|
|
|
|
<div className="SupportFooter-fallback">
|
|
|
|
<p onClick={this.toggleFallback}>
|
2018-03-22 03:50:25 +00:00
|
|
|
<small>{translate('SWAP_SUPPORT_LINK_BROKEN')}</small>
|
2018-01-02 18:04:50 +00:00
|
|
|
</p>
|
|
|
|
{open ? (
|
2018-03-01 17:53:29 +00:00
|
|
|
<TextArea defaultValue={fallbackBody} className="form-control input-sm" rows={9} />
|
2018-01-02 18:04:50 +00:00
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
private toggleFallback = () => {
|
|
|
|
this.setState({
|
|
|
|
open: !this.state.open
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SupportFooter;
|