2022-09-17 20:21:50 +03:00

38 lines
787 B
TypeScript

import { Button as AntButton } from 'antd';
import type { BaseButtonProps } from 'antd/lib/button/button';
import { throttle } from 'radash/dist/curry';
import type { FC } from 'react';
import type { BaseElementProps } from './types';
type ElementProps = {
action: () => void;
text: string;
};
type ButtonProps = BaseButtonProps & Pick<ElementProps, 'text'>;
export default (function Button({
status,
action,
text,
...props
}: BaseElementProps<never> & ElementProps) {
const throttledAction = throttle(
{
interval: 1200,
},
action
);
return (
<AntButton
disabled={status === 'Disabled'}
loading={status === 'Loading'}
onClick={throttledAction}
{...props}
>
{text}
</AntButton>
);
} as FC<ButtonProps>);