import {formatMoney} from "./utils"; import React from "react"; import {useShopStore} from "./shop_store"; // #!render_count import {useRenderCount} from "@uidotdev/usehooks"; export function SummaryCrateHeader({crate_index}) { // #!render_count const renderCount = useRenderCount(); const currency = useShopStore((state) => state.currency); const crateParams = useShopStore((state) => state.crateParams); const clearCrate = useShopStore((state) => state.clearCrate); const delCrate = useShopStore((state) => state.delCrate); const crate_mode = useShopStore((state) => state.crates[crate_index].crate_mode); const crate_id = useShopStore((state) => state.crates[crate_index].id); const crate_name = useShopStore((state) => state.crates[crate_index].name); const modes_order = useShopStore((state) => state.modes_order); const crate_mode_displayed = modes_order.includes(crate_mode); // #!render_count console.log("SummaryCrateHeader renders: ", renderCount) let crate_type = crateParams(crate_mode); return ( {!!crate_name ? crate_name : crate_type.name + " #" + crate_index}
{crate_mode_displayed && `${currency} ${formatMoney(crate_type.price)}`} { crate_mode_displayed ? ( ) : }
) }