import React from 'react'; import {Draggable} from "@hello-pangea/dnd"; import {formatMoney, productStyle} from "./utils"; import {useShopStore} from "./shop_store"; /** * Component that renders a product. * Used in the aside (e.g backlog of product) */ export function ProductItem({card_index}) { const {card, currency, onAddCard} = useShopStore(state => ({ card: state.getCardDescription(card_index), currency: state.currency, onAddCard: state.addCardFromBacklog })); const render_specs = (card.specs && card.specs.length > 0 && ( )); const render_datasheet_link = (card.datasheet_file && card.datasheet_name && (
{card.datasheet_name}
)); return (

{card.name}

{card.name_codename ? (

{card.name_codename}

) : null}
{`${currency} ${formatMoney(card.price)}`}
{render_specs} {render_datasheet_link}
{(provided, snapshot) => ( {/* Allows to simulate a clone */} {snapshot.isDragging && ( )} )}
); }