29 lines
583 B
TypeScript

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