actions-copy-project.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { useCallback, useState } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import EditorCloneProjectModalWrapper from '../../clone-project-modal/components/editor-clone-project-modal-wrapper'
  4. import LeftMenuButton from './left-menu-button'
  5. import { useLocation } from '../../../shared/hooks/use-location'
  6. type ProjectCopyResponse = {
  7. project_id: string
  8. }
  9. export default function ActionsCopyProject() {
  10. const [showModal, setShowModal] = useState(false)
  11. const { t } = useTranslation()
  12. const location = useLocation()
  13. const openProject = useCallback(
  14. ({ project_id: projectId }: ProjectCopyResponse) => {
  15. location.assign(`/project/${projectId}`)
  16. },
  17. [location]
  18. )
  19. return (
  20. <>
  21. <LeftMenuButton
  22. onClick={() => setShowModal(true)}
  23. icon={{
  24. type: 'copy',
  25. fw: true,
  26. }}
  27. >
  28. {t('copy_project')}
  29. </LeftMenuButton>
  30. <EditorCloneProjectModalWrapper
  31. show={showModal}
  32. handleHide={() => setShowModal(false)}
  33. openProject={openProject}
  34. />
  35. </>
  36. )
  37. }