You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InviteButton.tsx 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React, { useCallback } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { useDispatch, useSelector } from 'react-redux';
  4. import { createToolbarEvent } from '../../../analytics/AnalyticsEvents';
  5. import { sendAnalytics } from '../../../analytics/functions';
  6. import { IReduxState } from '../../../app/types';
  7. import { IconAddUser } from '../../../base/icons/svg';
  8. import Button from '../../../base/ui/components/web/Button';
  9. import { BUTTON_TYPES } from '../../../base/ui/constants.web';
  10. import { beginAddPeople } from '../../../invite/actions';
  11. import { NOTIFY_CLICK_MODE } from '../../../toolbox/types';
  12. const INVITE_BUTTON_KEY = 'invite';
  13. export const InviteButton = () => {
  14. const dispatch = useDispatch();
  15. const { t } = useTranslation();
  16. const notifyMode = useSelector(
  17. (state: IReduxState) => state['features/toolbox'].buttonsWithNotifyClick?.get(INVITE_BUTTON_KEY));
  18. const onInvite = useCallback(() => {
  19. if (notifyMode) {
  20. APP.API.notifyToolbarButtonClicked(
  21. INVITE_BUTTON_KEY, notifyMode === NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY
  22. );
  23. }
  24. if (notifyMode === NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY) {
  25. return;
  26. }
  27. sendAnalytics(createToolbarEvent(INVITE_BUTTON_KEY));
  28. dispatch(beginAddPeople());
  29. }, [ dispatch, notifyMode ]);
  30. return (
  31. <Button
  32. accessibilityLabel = { t('participantsPane.actions.invite') }
  33. fullWidth = { true }
  34. icon = { IconAddUser }
  35. labelKey = { 'participantsPane.actions.invite' }
  36. onClick = { onInvite }
  37. type = { BUTTON_TYPES.PRIMARY } />
  38. );
  39. };