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