Skip to content

Commit

Permalink
fix(web): use product ID instead of generated slug
Browse files Browse the repository at this point in the history
The product selection page was using a dynamically generated slug based
on the product name. Since each product already has a unique ID, it is
more reliable and efficient to use it instead of generating a new one.
  • Loading branch information
dgdavid committed Jan 8, 2025
1 parent 1ec82fe commit 395bbe4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions web/src/components/product/ProductSelectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { Center } from "~/components/layout";
import { useConfigMutation, useProduct } from "~/queries/software";
import pfTextStyles from "@patternfly/react-styles/css/utilities/Text/text";
import pfRadioStyles from "@patternfly/react-styles/css/components/Radio/radio";
import { slugify } from "~/utils";
import { sprintf } from "sprintf-js";
import { _ } from "~/i18n";
import { useNavigate } from "react-router-dom";
Expand All @@ -51,8 +50,7 @@ const ResponsiveGridItem = ({ children }) => (
);

const Option = ({ product, isChecked, onChange }) => {
const id = slugify(product.name);
const detailsId = `${id}-details`;
const detailsId = `${product.id}-details`;
const logoSrc = `assets/logos/${product.icon}`;
// TRANSLATORS: %s will be replaced by a product name. E.g., "openSUSE Tumbleweed"
const logoAltText = sprintf(_("%s logo"), product.name);
Expand All @@ -63,7 +61,7 @@ const Option = ({ product, isChecked, onChange }) => {
<CardBody>
<Split hasGutter>
<input
id={id}
id={product.id}
type="radio"
name="product"
className={pfRadioStyles.radioInput}
Expand All @@ -74,7 +72,7 @@ const Option = ({ product, isChecked, onChange }) => {
<img aria-hidden src={logoSrc} alt={logoAltText} />
<Stack hasGutter>
<label
htmlFor={id}
htmlFor={product.id}
className={`${pfTextStyles.fontSizeLg} ${pfTextStyles.fontWeightBold}`}
>
{product.name}
Expand Down

0 comments on commit 395bbe4

Please sign in to comment.