/
austin_s
/
react-interview-components
Обзор
Документация
Войти
/
austin_s
/
react-interview-components
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/lib/offer/components/action-button.component.tsx
24 строки
668 B
spanic
Adds imageUrl prop for the Offer component
23 фев 2025, 18:00
23 фев 2025, 18:00
7096e58
Код
Авторство
О чём код?
import React, {FC} from 'react'; import {DeleteOutlined, PlusOutlined} from '@ant-design/icons'; import {Button, ButtonProps} from 'antd'; export enum ActionType { ADD, REMOVE, } export interface IActionButtonProps extends ButtonProps { actionType: ActionType; } export const ActionButton: FC<IActionButtonProps> = ({ actionType, ...buttonProps }) => { const props: ButtonProps = { icon: actionType === ActionType.ADD ? <PlusOutlined /> : <DeleteOutlined />, children: actionType === ActionType.ADD ? 'Add to cart' : 'Remove', ...(actionType === ActionType.REMOVE && {danger: true}), }; return <Button {...props} {...buttonProps} />; };