import React from 'react';
import {Draggable} from "@hello-pangea/dnd";
import {formatMoney, productStyle} from "./utils";
import {useShopStore} from "./shop_store";
// #!render_count
import {useRenderCount} from "@uidotdev/usehooks";
function DatasheetLink({datasheet_file, datasheet_name}) {
return datasheet_file && datasheet_name && (
)
}
function CardSpecs({specs}) {
return specs && specs.length > 0 && (
{specs.map((spec, index) =>
- {spec}
)}
)
}
function AddButton({onAdd}) {
return
}
/**
* Component that renders a product.
* Used in the aside (e.g catalog of products)
*/
export function ProductItem({card_index}) {
// #!render_count
const renderCount = useRenderCount();
const getCardDescription = useShopStore((state) => state.getCardDescription);
const currency = useShopStore((state) => state.currency);
const addCardFromCatalog = useShopStore((state) => state.addCardFromCatalog);
const card = getCardDescription(card_index);
// #!render_count
console.log("ProductItem renders: ", renderCount)
return (
{card.name_number} {card.name}
{card.name_codename ? (
{card.name_codename}
) : null}
{`${currency} ${formatMoney(card.price)}`}
addCardFromCatalog(null, card_index, null)} />
{(provided, snapshot) => (
{/* Allows to simulate a clone */}
{snapshot.isDragging && (
)}
)}
);
}