From e5e7510a04363373fbcfcbfc90abf4aad9630ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Wed, 15 Nov 2023 11:23:33 +0000 Subject: [PATCH] [web] Use early return --- .../components/product/ProductSelector.jsx | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/web/src/components/product/ProductSelector.jsx b/web/src/components/product/ProductSelector.jsx index 05b2842bf6..311a6a7e89 100644 --- a/web/src/components/product/ProductSelector.jsx +++ b/web/src/components/product/ProductSelector.jsx @@ -23,32 +23,27 @@ import React from "react"; import { Card, CardBody, Radio } from "@patternfly/react-core"; import { _ } from "~/i18n"; -import { If } from "~/components/core"; import { noop } from "~/utils"; export default function ProductSelector({ value, products = [], onChange = noop }) { + if (products.length === 0) return

{_("No products available for selection")}

; + const isSelected = (product) => product.id === value; return ( - {_("No products available for selection")}

} - else={ - products.map((p) => ( - - - onChange(p.id)} - /> - - - )) - } - /> + products.map((p) => ( + + + onChange(p.id)} + /> + + + )) ); }