CustomParamAction.tsx 733 B

1234567891011121314151617181920212223242526
  1. import React from 'react';
  2. import CustomParamButton, { CustomParamButtonType } from './CustomParamButton';
  3. import { isFirstParam } from './CustomParams';
  4. interface Props {
  5. index: string;
  6. onAdd: (event: React.MouseEvent<HTMLButtonElement>) => void;
  7. onRemove: (index: string) => void;
  8. }
  9. const CustomParamAction: React.FC<Props> = ({
  10. index,
  11. onAdd,
  12. onRemove,
  13. }) => (
  14. <>
  15. <label className='label'>&nbsp;</label>
  16. {
  17. isFirstParam(index)
  18. ? <CustomParamButton className="is-success" type={CustomParamButtonType.plus} onClick={onAdd} />
  19. : <CustomParamButton className="is-danger" type={CustomParamButtonType.minus} onClick={() => onRemove(index)} />
  20. }
  21. </>
  22. )
  23. export default CustomParamAction;