lbry-desktop/ui/modal/modalAffirmPurchase/view.jsx

65 lines
1.6 KiB
React
Raw Normal View History

2018-09-26 13:48:07 -04:00
// @flow
import React from 'react';
import FilePrice from 'component/filePrice';
import { Modal } from 'modal/modal';
import Card from 'component/common/card';
import I18nMessage from 'component/i18nMessage';
import Button from 'component/button';
2017-09-07 17:18:33 -04:00
2018-09-26 13:48:07 -04:00
type Props = {
closeModal: () => void,
loadVideo: string => void,
uri: string,
cancelPurchase: () => void,
2019-04-24 10:02:08 -04:00
metadata: StreamMetadata,
2018-09-26 13:48:07 -04:00
};
class ModalAffirmPurchase extends React.PureComponent<Props> {
2018-05-31 00:32:31 -04:00
constructor() {
super();
2019-01-07 21:46:33 -05:00
(this: any).onAffirmPurchase = this.onAffirmPurchase.bind(this);
2018-05-31 00:32:31 -04:00
}
2017-09-07 23:15:05 -04:00
onAffirmPurchase() {
this.props.closeModal();
this.props.loadVideo(this.props.uri);
}
2017-09-07 17:18:33 -04:00
render() {
2018-05-03 11:22:10 -06:00
const {
cancelPurchase,
metadata: { title },
uri,
} = this.props;
2017-09-07 17:18:33 -04:00
const modalTitle = __('Confirm Purchase');
2017-09-07 17:18:33 -04:00
return (
<Modal type="card" isOpen contentLabel={modalTitle} onAborted={cancelPurchase}>
<Card
title={modalTitle}
subtitle={
<I18nMessage
tokens={{
claim_title: <strong>{title ? `"${title}"` : uri}</strong>,
amount: <FilePrice uri={uri} showFullPrice inheritStyle />,
}}
>
This will purchase %claim_title% for %amount%.
</I18nMessage>
}
actions={
<div className="section__actions">
<Button button="primary" label={__('Confirm')} onClick={this.onAffirmPurchase} />
<Button button="link" label={__('Cancel')} onClick={cancelPurchase} />
</div>
}
/>
2017-09-07 17:18:33 -04:00
</Modal>
);
}
}
export default ModalAffirmPurchase;