lbry-desktop/ui/component/claimRepostButton/view.jsx
Bradley Ray e5072c8681
Modal repost (#7341)
* make repost into a modal

* remove unecessary import

* removed page/repost

* fixed yarn lint errors

* added page/repost back

* added "Repost" title bar

* fixed yarn lint errors
2021-12-12 01:03:00 -05:00

44 lines
1.3 KiB
JavaScript

// @flow
import { SITE_NAME } from 'config';
import * as MODALS from 'constants/modal_types';
import * as ICONS from 'constants/icons';
import React from 'react';
import Button from 'component/button';
type Props = {
uri: string,
claim: StreamClaim,
hasChannels: boolean,
doOpenModal: (string, {}) => void,
doToast: ({ message: string }) => void,
};
export default function ClaimRepostButton(props: Props) {
const { uri, claim, hasChannels, doOpenModal, doToast } = props;
const [contentUri, setContentUri] = React.useState('');
const [repostUri, setRepostUri] = React.useState('');
return (
<Button
button="alt"
className="button--file-action"
icon={ICONS.REPOST}
label={
claim.meta.reposted > 1 ? __(`%repost_total% Reposts`, { repost_total: claim.meta.reposted }) : __('Repost')
}
description={__('Repost')}
requiresAuth={IS_WEB}
onClick={() => {
if (!hasChannels) {
doToast({
message: __('A channel is required to repost on %SITE_NAME%', { SITE_NAME }),
linkText: __('Create Channel'),
linkTarget: '/channel/new',
});
} else {
doOpenModal(MODALS.REPOST, { uri, contentUri, setContentUri, repostUri, setRepostUri, isModal: true });
}
}}
/>
);
}