2023-12-14 17:45:54 +08:00
|
|
|
import {range} from "./utils";
|
|
|
|
import React from "react";
|
|
|
|
import {useShopStore} from "./shop_store";
|
|
|
|
import {SummaryCrateHeader} from "./SummaryCrateHeader";
|
|
|
|
import {SummaryCrateCard} from "./SummaryCrateCard";
|
2024-01-30 13:02:01 +08:00
|
|
|
import {SummaryCratePricedOptions} from "./SummaryCratePricedOptions";
|
2023-12-14 17:45:54 +08:00
|
|
|
|
|
|
|
// #!render_count
|
|
|
|
import {useRenderCount} from "@uidotdev/usehooks";
|
2024-01-30 13:02:01 +08:00
|
|
|
|
2023-12-14 17:45:54 +08:00
|
|
|
|
|
|
|
export function SummaryCrate({crate_index}) {
|
|
|
|
// #!render_count
|
|
|
|
const renderCount = useRenderCount();
|
|
|
|
|
|
|
|
const crate_id = useShopStore((state) => state.crates[crate_index].id);
|
|
|
|
const crate_len = useShopStore((state) => state.crates[crate_index].items.length);
|
2024-11-01 17:32:20 +08:00
|
|
|
const crate_h_len = useShopStore((state) => state.crates[crate_index].h_items.length);
|
2023-12-14 17:45:54 +08:00
|
|
|
|
|
|
|
// #!render_count
|
|
|
|
console.log("SummaryCrate renders: ", renderCount)
|
|
|
|
|
|
|
|
return (
|
|
|
|
<tbody key={"summary_crate_body" + crate_id}>
|
|
|
|
|
|
|
|
<SummaryCrateHeader crate_index={crate_index}/>
|
|
|
|
|
|
|
|
{range(0, crate_len).map((index, _i) =>
|
|
|
|
<SummaryCrateCard crate_index={crate_index} card_index={index} key={"summary_crate_" + crate_id + "_" +index} />
|
|
|
|
)}
|
2024-01-30 13:02:01 +08:00
|
|
|
|
2024-11-01 17:32:20 +08:00
|
|
|
{range(0, crate_h_len).map((index, _i) =>
|
|
|
|
<SummaryCrateCard
|
|
|
|
crate_index={crate_index}
|
|
|
|
card_index={index}
|
|
|
|
horizontal={true}
|
|
|
|
key={"summary_crate_h_" + crate_id + "_" +index} />
|
|
|
|
)}
|
|
|
|
|
2024-01-30 13:02:01 +08:00
|
|
|
<SummaryCratePricedOptions crate_index={crate_index}/>
|
2023-12-14 17:45:54 +08:00
|
|
|
</tbody>
|
|
|
|
)
|
|
|
|
}
|