import React, { useMemo, useState } from 'react' import { Modal, Alert, Button, FormGroup, ControlLabel, FormControl } from 'react-bootstrap' import PropTypes from 'prop-types' import { useTranslation } from 'react-i18next' function CloneProjectModalContent({ cloneProject, projectName = '', error, cancel, inFlight }) { const { t } = useTranslation() const [clonedProjectName, setClonedProjectName] = useState( `${projectName} (Copy)` ) const valid = useMemo(() => !!clonedProjectName, [clonedProjectName]) function handleSubmit(event) { event.preventDefault() if (valid) { cloneProject(clonedProjectName) } } return ( <> {t('copy_project')}
{t('new_name')} setClonedProjectName(event.target.value)} />
{error && ( {error.message || t('generic_something_went_wrong')} )}
) } CloneProjectModalContent.propTypes = { cloneProject: PropTypes.func.isRequired, error: PropTypes.oneOfType([ PropTypes.bool, PropTypes.shape({ message: PropTypes.string }) ]), cancel: PropTypes.func.isRequired, inFlight: PropTypes.bool.isRequired, projectName: PropTypes.string } export default CloneProjectModalContent