import React, {useState, useEffect} from 'react'; import {observer, inject} from "mobx-react"; import { f7, Popup, Navbar, NavLeft, NavRight, NavTitle, Link, Input, Icon } from 'framework7-react'; import { useTranslation } from 'react-i18next'; import {Device} from '../../../utils/device'; const AddCommentPopup = inject("storeComments")(observer(props => { const { t } = useTranslation(); const _t = t('Common.Collaboration', {returnObjects: true}); useEffect(() => { f7.popup.open('.add-comment-popup'); }); const userInfo = props.userInfo; const [stateText, setText] = useState(''); return ( { props.storeComments.openAddComment(false); f7.popup.close('.add-comment-popup'); }}>{_t.textCancel} {_t.textAddComment} { if (props.onAddNewComment(stateText, false)) { props.storeComments.openAddComment(false); f7.popup.close('.add-comment-popup'); } }}> {Device.android ? : _t.textDone}
{Device.android &&
{userInfo.initials}
}
{userInfo.name}
{setText(event.target.value);}}>
) })); const AddCommentDialog = inject("storeComments")(observer(props => { const { t } = useTranslation(); const _t = t('Common.Collaboration', {returnObjects: true}); const userInfo = props.userInfo; const templateInitials = `
${userInfo.initials}
`; useEffect(() => { f7.dialog.create({ destroyOnClose: true, containerEl: document.getElementById('add-comment-dialog'), content: `
${Device.android ? templateInitials : ''}
${userInfo.name}
`, on: { opened: () => { const cancel = document.getElementById('comment-cancel'); cancel.addEventListener('click', () => { f7.dialog.close(); props.storeComments.openAddComment(false); }); const done = document.getElementById('comment-done'); done.addEventListener('click', () => { const value = document.getElementById('comment-text').value; if (value.length > 0 && props.onAddNewComment(value, false)) { f7.dialog.close(); props.storeComments.openAddComment(false); } }); const area = document.getElementById('comment-text'); area.addEventListener('input', (event) => { if (event.target.value.length === 0 && !done.classList.contains('disabled')) { done.classList.add('disabled'); } else if (event.target.value.length > 0 && done.classList.contains('disabled')) { done.classList.remove('disabled'); } }); done.classList.add('disabled'); } } }).open(); }); return (
); })); const AddComment = props => { return ( Device.phone ? : ) }; export {AddComment}