2022-05-18 21:54:29 +03:00

29 lines
601 B
TypeScript

import type { ButtonProps } from 'antd';
import { Button as AntButton } from 'antd';
import { throttle } from 'lodash';
import type { Status } from './types';
type ElementProps = {
status: Status;
action: () => void;
text: string;
};
export default function Button({ status, action, text }: ElementProps) {
const throttledAction = throttle(action, 1200, {
trailing: false,
});
return (
<AntButton
disabled={status === 'Disabled'}
loading={status === 'Loading'}
onClick={throttledAction}
>
{text}
</AntButton>
);
}
export type { ButtonProps };