move checkbox

This commit is contained in:
Greg 2026-07-04 23:23:30 +03:00
parent 78c08be6b8
commit 39cc31eeca

View file

@ -39,12 +39,6 @@ const Price = ({ price, toggleCountry, isSelected }) => {
const hover = useCallback(() => setHover(true)); const hover = useCallback(() => setHover(true));
const leave = useCallback(() => setHover(false)); const leave = useCallback(() => setHover(false));
const openLink = useCallback((e) => {
// Don't open if the click was on the checkbox
if (e.target.type === "checkbox") return;
window.open(bookUrl(countryCode), "_blank");
});
const style = { const style = {
display: "flex", display: "flex",
flexDirection: "row", flexDirection: "row",
@ -52,23 +46,20 @@ const Price = ({ price, toggleCountry, isSelected }) => {
alignItems: "center", alignItems: "center",
backgroundColor: isHovered ? "#d7d7d7" : "", backgroundColor: isHovered ? "#d7d7d7" : "",
padding: "4px 10px", padding: "4px 10px",
cursor: "pointer",
}; };
const checkbox = h("input", { const checkbox = h("input", {
type: "checkbox", type: "checkbox",
checked: isSelected, checked: isSelected,
onChange: () => toggleCountry(), onChange: () => toggleCountry(),
onClick: (e) => e.stopPropagation(),
}); });
const nameLabel = h( const link = h(
"span", "a",
{ {
style: { style: { textDecoration: "underline", marginLeft: "8px" },
marginLeft: "8px", href: bookUrl(countryCode),
textDecoration: isHovered ? "underline" : "none", target: "_blank",
},
}, },
countryName || countryCode.toUpperCase(), countryName || countryCode.toUpperCase(),
); );
@ -80,15 +71,10 @@ const Price = ({ price, toggleCountry, isSelected }) => {
); );
return h( return h(
"div", "label",
{ { style, onMouseEnter: hover, onMouseLeave: leave },
style,
onMouseEnter: hover,
onMouseLeave: leave,
onClick: openLink,
},
checkbox, checkbox,
nameLabel, link,
priceLabel, priceLabel,
); );
}; };