share-project-button.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import ShareProjectModal from '@/features/share-project-modal/components/share-project-modal'
  2. import OLButton from '@/features/ui/components/ol/ol-button'
  3. import MaterialIcon from '@/shared/components/material-icon'
  4. import { useCallback, useState } from 'react'
  5. import { useTranslation } from 'react-i18next'
  6. import * as eventTracking from '@/infrastructure/event-tracking'
  7. export default function ShareProjectButton() {
  8. const { t } = useTranslation()
  9. const [showShareModal, setShowShareModal] = useState(false)
  10. const handleOpenShareModal = useCallback(() => {
  11. eventTracking.sendMBOnce('ide-open-share-modal-once')
  12. setShowShareModal(true)
  13. }, [])
  14. const handleHideShareModal = useCallback(() => {
  15. setShowShareModal(false)
  16. }, [])
  17. return (
  18. <>
  19. <div className="ide-redesign-toolbar-button-container">
  20. <OLButton
  21. size="sm"
  22. variant="primary"
  23. leadingIcon={<MaterialIcon type="person_add" />}
  24. onClick={handleOpenShareModal}
  25. >
  26. {t('share')}
  27. </OLButton>
  28. </div>
  29. <ShareProjectModal
  30. show={showShareModal}
  31. handleOpen={handleOpenShareModal}
  32. handleHide={handleHideShareModal}
  33. />
  34. </>
  35. )
  36. }