2022-03-15 23:02:54 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
|
|
import Service from './service';
|
|
|
|
import Styled from './styles';
|
2022-10-07 01:46:06 +08:00
|
|
|
import { useState } from 'react';
|
2022-03-15 23:02:54 +08:00
|
|
|
|
|
|
|
const DEBOUNCE_TIMEOUT = 15000;
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
convertAndUploadLabel: {
|
|
|
|
id: 'app.note.converter-button.convertAndUpload',
|
|
|
|
description: 'Export shared notes as a PDF and upload to the main room',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
amIPresenter: PropTypes.bool.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
const ConverterButtonComponent = ({
|
|
|
|
intl,
|
|
|
|
amIPresenter,
|
2022-10-07 01:46:06 +08:00
|
|
|
}) => {
|
|
|
|
[converterButtonDisabled, setConverterButtonDisabled] = useState(false);
|
|
|
|
return (amIPresenter
|
2022-03-15 23:02:54 +08:00
|
|
|
? (
|
|
|
|
<Styled.ConvertAndUpload
|
2022-10-07 01:46:06 +08:00
|
|
|
disabled={converterButtonDisabled}
|
2022-10-08 03:10:08 +08:00
|
|
|
onClick={() => {
|
2022-10-07 01:46:06 +08:00
|
|
|
setConverterButtonDisabled(true);
|
|
|
|
setTimeout(() => setConverterButtonDisabled(false), DEBOUNCE_TIMEOUT);
|
2022-10-08 03:10:08 +08:00
|
|
|
return Service.convertAndUpload()}}
|
2022-03-15 23:02:54 +08:00
|
|
|
label={intl.formatMessage(intlMessages.convertAndUploadLabel)}
|
|
|
|
icon="upload"
|
|
|
|
/>
|
|
|
|
)
|
2022-10-07 01:46:06 +08:00
|
|
|
: null)};
|
2022-03-15 23:02:54 +08:00
|
|
|
|
|
|
|
ConverterButtonComponent.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default injectIntl(ConverterButtonComponent);
|