2023-12-07 17:08:22 +08:00
|
|
|
import React from "react";
|
2023-12-12 16:09:29 +08:00
|
|
|
import {LevelUI} from "./warnings";
|
2023-12-11 17:05:35 +08:00
|
|
|
import {useShopStore} from "./shop_store";
|
2023-12-15 13:49:54 +08:00
|
|
|
import {compareArraysWithIds} from "./utils";
|
|
|
|
|
2023-12-14 16:29:32 +08:00
|
|
|
// #!render_count
|
2023-12-14 16:09:33 +08:00
|
|
|
import {useRenderCount} from "@uidotdev/usehooks";
|
|
|
|
|
2023-12-07 17:08:22 +08:00
|
|
|
|
2023-12-11 17:05:35 +08:00
|
|
|
export function CrateWarnings({crate_index}) {
|
2023-12-14 16:29:32 +08:00
|
|
|
// #!render_count
|
2023-12-14 16:09:33 +08:00
|
|
|
const renderCount = useRenderCount();
|
2023-12-14 16:29:32 +08:00
|
|
|
|
2023-12-15 13:49:54 +08:00
|
|
|
const crate_warnings = useShopStore(state => (state.crates[crate_index].warnings), compareArraysWithIds)
|
2023-12-14 16:29:32 +08:00
|
|
|
|
|
|
|
// #!render_count
|
2023-12-14 16:09:33 +08:00
|
|
|
console.log("CrateWarnings renders: ", renderCount)
|
2023-12-07 17:08:22 +08:00
|
|
|
return (
|
|
|
|
<div className="crate-info">
|
2023-12-11 17:05:35 +08:00
|
|
|
{crate_warnings.map((rule, index) => (
|
2023-12-12 16:09:29 +08:00
|
|
|
<p key={index} className="rule" style={{'color': LevelUI(rule.level).color}}>
|
|
|
|
<img src={LevelUI(rule.level).icon} /> <i>{rule.message}</i>
|
2023-12-07 17:08:22 +08:00
|
|
|
</p>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|