import React from 'react';
import {selectPlantingAction} from '../plantingActions';
import ActionsMenu from './ActionsMenu';
import CropChip from './CropChip';
// A planting's crop chip, which is also its menu: click it for view, edit,
// harvest and the rest, the same for annuals and perennials. Someone who can't
// change the planting has no menu, so for them it stays a plain link to it.
export default function PlantingChip({planting, defaultIconUrl, highlighted, handlers}) {
const {id, url, crop, actions} = planting;
if (!actions || actions.length === 0) {
return ;
}
return (
{crop.name}
>
)}
ariaLabel={`Actions for ${crop.name}`}
className={`chip crop-chip chip-menu-toggle dropdown-toggle${highlighted ? ' planting-just-added' : ''}`}
menuClassName="dropdown-menu-start planting-menu"
onSelect={selectPlantingAction(planting, handlers)}
/>
);
}