2022-05-06 01:01:23 +03:00
|
|
|
import { Button } from 'antd';
|
2022-10-22 08:24:29 +03:00
|
|
|
import { FC } from 'react';
|
2022-12-12 08:06:20 +03:00
|
|
|
import cn from 'classnames';
|
2022-09-03 21:38:52 +03:00
|
|
|
import { ExternalAction } from '../../../interfaces/external-action';
|
2022-09-07 10:00:28 +03:00
|
|
|
import styles from './ActionButton.module.scss';
|
2022-05-06 01:01:23 +03:00
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export type ActionButtonProps = {
|
2022-05-06 01:01:23 +03:00
|
|
|
action: ExternalAction;
|
2022-08-30 09:17:12 +03:00
|
|
|
primary?: boolean;
|
2022-10-22 08:24:29 +03:00
|
|
|
externalActionSelected: (action: ExternalAction) => void;
|
2022-08-30 09:17:12 +03:00
|
|
|
};
|
2022-05-06 01:01:23 +03:00
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export const ActionButton: FC<ActionButtonProps> = ({
|
2022-10-22 08:24:29 +03:00
|
|
|
action,
|
2022-09-07 10:00:28 +03:00
|
|
|
primary = true,
|
2022-10-22 08:24:29 +03:00
|
|
|
externalActionSelected,
|
2022-09-07 10:00:28 +03:00
|
|
|
}) => {
|
2022-10-22 08:24:29 +03:00
|
|
|
const { title, description, icon, color } = action;
|
2022-05-10 01:34:02 +03:00
|
|
|
|
2022-05-06 01:01:23 +03:00
|
|
|
return (
|
2022-10-22 08:24:29 +03:00
|
|
|
<Button
|
|
|
|
type={primary ? 'primary' : 'default'}
|
2022-12-12 08:06:20 +03:00
|
|
|
className={cn([`${styles.button}`, 'action-button'])}
|
2022-10-22 08:24:29 +03:00
|
|
|
onClick={() => externalActionSelected(action)}
|
|
|
|
style={{ backgroundColor: color }}
|
2023-06-21 06:23:09 +03:00
|
|
|
title={description || title}
|
2022-10-22 08:24:29 +03:00
|
|
|
>
|
2023-07-30 01:57:45 +03:00
|
|
|
{icon && <img src={icon} className={styles.icon} alt={description} />}
|
2022-10-22 08:24:29 +03:00
|
|
|
{title}
|
|
|
|
</Button>
|
2022-05-06 01:01:23 +03:00
|
|
|
);
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|