2023-03-27 13:40:55 +03:00
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-07-20 13:25:40 +03:00
|
|
|
import { useDispatch } from 'react-redux';
|
2022-12-06 19:29:33 +02:00
|
|
|
|
|
|
|
|
import { IconCheck } from '../../../base/icons/svg';
|
|
|
|
|
import ContextMenuItem from '../../../base/ui/components/web/ContextMenuItem';
|
|
|
|
|
import { startVerification } from '../../../e2ee/actions';
|
2024-03-08 09:59:02 -06:00
|
|
|
import { NOTIFY_CLICK_MODE } from '../../../toolbox/types';
|
2023-07-20 13:25:40 +03:00
|
|
|
import { IButtonProps } from '../../types';
|
2022-12-06 19:29:33 +02:00
|
|
|
|
|
|
|
|
/**
|
2023-07-20 13:25:40 +03:00
|
|
|
* Implements a React {@link Component} which displays a button that
|
|
|
|
|
* verifies the participant.
|
|
|
|
|
*
|
|
|
|
|
* @returns {JSX.Element}
|
2022-12-06 19:29:33 +02:00
|
|
|
*/
|
2023-03-27 13:40:55 +03:00
|
|
|
const VerifyParticipantButton = ({
|
2023-07-20 13:25:40 +03:00
|
|
|
notifyClick,
|
|
|
|
|
notifyMode,
|
2023-03-27 13:40:55 +03:00
|
|
|
participantID
|
2023-07-20 13:25:40 +03:00
|
|
|
}: IButtonProps): JSX.Element => {
|
2023-03-27 13:40:55 +03:00
|
|
|
const { t } = useTranslation();
|
2023-07-20 13:25:40 +03:00
|
|
|
const dispatch = useDispatch();
|
2022-12-06 19:29:33 +02:00
|
|
|
|
2023-03-27 13:40:55 +03:00
|
|
|
const _handleClick = useCallback(() => {
|
2023-07-20 13:25:40 +03:00
|
|
|
notifyClick?.();
|
|
|
|
|
if (notifyMode === NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-12-06 19:29:33 +02:00
|
|
|
dispatch(startVerification(participantID));
|
2023-07-20 13:25:40 +03:00
|
|
|
}, [ dispatch, notifyClick, notifyMode, participantID ]);
|
2023-03-27 13:40:55 +03:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ContextMenuItem
|
|
|
|
|
accessibilityLabel = { t('videothumbnail.verify') }
|
|
|
|
|
className = 'verifylink'
|
|
|
|
|
icon = { IconCheck }
|
|
|
|
|
id = { `verifylink_${participantID}` }
|
|
|
|
|
// eslint-disable-next-line react/jsx-handler-names
|
|
|
|
|
onClick = { _handleClick }
|
|
|
|
|
text = { t('videothumbnail.verify') } />
|
|
|
|
|
);
|
|
|
|
|
};
|
2022-12-06 19:29:33 +02:00
|
|
|
|
2023-07-20 13:25:40 +03:00
|
|
|
export default VerifyParticipantButton;
|