12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- // @flow
-
- import React, { useCallback } from 'react';
- import { useDispatch } from 'react-redux';
-
- type Props = {
-
- /**
- * Action to be dispatched on click.
- */
- action: Function,
-
- /**
- * The text of the button.
- */
- children: React$Node,
-
- /**
- * CSS class of the button.
- */
- className: string,
-
- /**
- * The `data-testid` used for the button.
- */
- testId: string,
-
- /**
- * The participant.
- */
- participant: Object
- }
-
- /**
- * Component used to display an approve/reject button.
- *
- * @returns {React$Element<'button'>}
- */
- export default function({ action, children, className, testId, participant }: Props) {
- const dispatch = useDispatch();
- const onClick = useCallback(() => dispatch(action(participant.id)), [ dispatch, participant ]);
-
- return (
- <button
- className = { className }
- data-testid = { testId }
- onClick = { onClick }
- type = 'button'>
- { children }
- </button>
- );
- }
|