2023-12-04 17:40:23 +08:00
|
|
|
import {OverlayTrigger} from "react-bootstrap";
|
|
|
|
import React from "react";
|
2023-12-05 17:35:31 +08:00
|
|
|
import {MaxLevel} from "./warnings";
|
2023-12-15 13:49:54 +08:00
|
|
|
import {useShopStore} from "./shop_store";
|
|
|
|
import {compareArraysLevelOne} from "./utils";
|
2023-12-04 17:40:23 +08:00
|
|
|
|
|
|
|
|
2023-12-15 13:49:54 +08:00
|
|
|
export function CardWarnings({crate_index, card_index}) {
|
|
|
|
|
|
|
|
const warnings = useShopStore(state => state.crates[crate_index].items[card_index].show_warnings, compareArraysLevelOne);
|
|
|
|
|
2023-12-05 17:35:31 +08:00
|
|
|
const max_level = MaxLevel(warnings);
|
2023-12-04 17:40:23 +08:00
|
|
|
return (
|
|
|
|
<OverlayTrigger
|
|
|
|
placement="bottom"
|
|
|
|
trigger={['click', 'hover', 'focus']}
|
|
|
|
overlay={
|
|
|
|
({arrowProps, hasDoneInitialMeasure, show, ...props}) => (
|
|
|
|
<div className="k-popup-warning" {...props}>
|
2023-12-05 17:35:31 +08:00
|
|
|
{warnings.map((warning, _i) => {
|
|
|
|
return (
|
2023-12-15 13:49:54 +08:00
|
|
|
<p className="rule warning" key={`warnmsg_${card_index}_${warning.name}`}>
|
2023-12-05 17:35:31 +08:00
|
|
|
<i>{warning.message}</i>
|
|
|
|
</p>
|
|
|
|
)
|
|
|
|
})}
|
2023-12-04 17:40:23 +08:00
|
|
|
</div>)
|
|
|
|
}
|
|
|
|
rootClose
|
|
|
|
>
|
2023-12-05 17:35:31 +08:00
|
|
|
<img className="alert-warning" src={max_level.icon}/>
|
2023-12-04 17:40:23 +08:00
|
|
|
</OverlayTrigger>
|
|
|
|
)
|
2023-12-06 16:27:43 +08:00
|
|
|
}
|
|
|
|
|
2023-12-15 13:49:54 +08:00
|
|
|
export function WarningIndicator({crate_index, card_index}) {
|
|
|
|
const warnings = useShopStore(state => state.crates[crate_index].items[card_index].show_warnings, compareArraysLevelOne);
|
|
|
|
|
2023-12-06 16:27:43 +08:00
|
|
|
const max_level = MaxLevel(warnings);
|
|
|
|
return (
|
|
|
|
<img
|
2024-01-23 11:36:56 +08:00
|
|
|
className="alert-warning align-self-start d-block"
|
2023-12-06 16:27:43 +08:00
|
|
|
src={max_level.icon}
|
|
|
|
/>
|
|
|
|
)
|
2023-12-04 17:40:23 +08:00
|
|
|
}
|