({ name, group }: ProductSelectionCardProps)
| 13 | } |
| 14 | |
| 15 | export const ProductSelectionCard = ({ name, group }: ProductSelectionCardProps) => { |
| 16 | const router = useRouter() |
| 17 | const { currentVersion } = useVersion() |
| 18 | const { isFPT } = useMainContext() |
| 19 | |
| 20 | function href(product: ProductT) { |
| 21 | return `${!product.external ? `/${router.locale}` : ''}${ |
| 22 | product.versions?.includes(currentVersion) && !isFPT |
| 23 | ? `/${currentVersion}/${product.id}` |
| 24 | : product.href |
| 25 | }` |
| 26 | } |
| 27 | |
| 28 | const groupIcon = { |
| 29 | height: '22px', |
| 30 | } |
| 31 | |
| 32 | function showProduct(product: ProductT) { |
| 33 | return isFPT || product.versions?.includes(currentVersion) || product.external |
| 34 | } |
| 35 | |
| 36 | function icon(group: ProductGroupT) { |
| 37 | if (group.icon) { |
| 38 | return ( |
| 39 | <div className="pr-3"> |
| 40 | <img src={group.icon} alt={group.name} style={groupIcon}></img> |
| 41 | </div> |
| 42 | ) |
| 43 | } else if (group.octicon) { |
| 44 | const octicon: React.FunctionComponent = ( |
| 45 | Octicons as { [name: string]: React.FunctionComponent } |
| 46 | )[group.octicon] as React.FunctionComponent |
| 47 | |
| 48 | return ( |
| 49 | <div className="mr-2"> |
| 50 | {React.createElement(octicon, groupIcon as React.Attributes, null)} |
| 51 | </div> |
| 52 | ) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | return ( |
| 57 | <div className="d-flex flex-column col-12 col-sm-6 col-lg-4 pb-4"> |
| 58 | <div className="flex-auto ws-normal"> |
| 59 | <div className="d-flex flex-items-center"> |
| 60 | {icon(group)} |
| 61 | |
| 62 | <div> |
| 63 | <h2 className="h3">{name}</h2> |
| 64 | </div> |
| 65 | </div> |
| 66 | |
| 67 | <div className="pt-2 mb-4 text-normal"> |
| 68 | <ul className="list-style-none"> |
| 69 | {group.children.map((product) => { |
| 70 | if (!showProduct(product)) { |
| 71 | return null |
| 72 | } |
nothing calls this directly
no test coverage detected