web2019/static/js/shop/CardWarnings.jsx
Egor Savkin 9d5ed66985 Do not show reminders in summary
Signed-off-by: Egor Savkin <es@m-labs.hk>
2024-01-23 11:44:01 +08:00

46 lines
1.7 KiB
JavaScript

import {OverlayTrigger} from "react-bootstrap";
import React from "react";
import {Levels, MaxLevel} from "./warnings";
import {useShopStore} from "./shop_store";
import {compareArraysLevelOne} from "./utils";
export function CardWarnings({crate_index, card_index}) {
const warnings = useShopStore(state => state.crates[crate_index].items[card_index].show_warnings, compareArraysLevelOne);
const max_level = MaxLevel(warnings);
return (
<OverlayTrigger
placement="bottom"
trigger={['click', 'hover', 'focus']}
overlay={
({arrowProps, hasDoneInitialMeasure, show, ...props}) => (
<div className="k-popup-warning" {...props}>
{warnings.map((warning, _i) => {
return (
<p className="rule warning" key={`warnmsg_${card_index}_${warning.name}`}>
<i>{warning.message}</i>
</p>
)
})}
</div>)
}
rootClose
>
<img className="alert-warning" src={max_level.icon}/>
</OverlayTrigger>
)
}
export function WarningIndicator({crate_index, card_index}) {
const warnings = useShopStore(state => state.crates[crate_index].items[card_index].show_warnings, compareArraysLevelOne);
const max_level = MaxLevel(warnings);
return max_level.priority === Levels.warning.priority ? (
<img
className="alert-warning align-self-start d-block"
src={max_level.icon}
/>
) : (<span className="alert-warning align-self-start d-block"></span>);
}