Sha256: eec94bcd8ab97c4417fdd377c760afd6a930b7f6c3085127d7485df69a67ba7b
Contents?: true
Size: 1.51 KB
Versions: 52
Compression:
Stored size: 1.51 KB
Contents
import React, { useContext, useState } from 'react'; import { useSelector } from 'react-redux'; import { translate as __ } from 'foremanReact/common/I18n'; import { DualListSelector } from '@patternfly/react-core'; import ACSCreateContext from '../ACSCreateContext'; import WizardHeader from '../../../ContentViews/components/WizardHeader'; import { selectProducts } from '../../ACSSelectors'; const ACSProducts = () => { const { setProductIds, productNames, setProductNames, } = useContext(ACSCreateContext); const availableProducts = useSelector(selectProducts); const { results } = availableProducts; const [availableOptions, setAvailableOptions] = useState(results?.map(product => product.name)?.filter(pName => !productNames.includes(pName))); const onListChange = (newAvailableOptions, newChosenOptions) => { setAvailableOptions(newAvailableOptions); setProductNames(newChosenOptions); setProductIds(results?.filter(product => newChosenOptions.includes(product.name))?.map(p => p?.id)); }; return ( <> <WizardHeader title={__('Select products')} description={__('Select products to associate to this source.')} /> <DualListSelector isSearchable availableOptions={availableOptions} chosenOptions={productNames} addAll={onListChange} removeAll={onListChange} addSelected={onListChange} removeSelected={onListChange} id="product_selector" /> </> ); }; export default ACSProducts;
Version data entries
52 entries across 52 versions & 1 rubygems