| 1 |
import { useLocation } from '@reach/router'; |
| 2 |
import Kit from '../models/kit'; |
| 3 |
import KitListItem from './kit-list-item'; |
| 4 |
import NewPageKitListItem from '../../../../onboarding/assets/js/components/new-page-kit-list-item'; |
| 5 |
import { CssGrid } from '@elementor/app-ui'; |
| 6 |
|
| 7 |
export default function KitList( props ) { |
| 8 |
const location = useLocation(); |
| 9 |
|
| 10 |
const referrer = new URLSearchParams( location.pathname.split( '?' )?.[ 1 ] ).get( 'referrer' ); |
| 11 |
|
| 12 |
return ( |
| 13 |
<CssGrid spacing={ 24 } colMinWidth={ 290 }> |
| 14 |
{ |
| 15 |
'onboarding' === referrer && |
| 16 |
<NewPageKitListItem /> |
| 17 |
} |
| 18 |
{ |
| 19 |
props.data.map( ( model, index ) => ( |
| 20 |
// The + 1 was added in order to start the map.index from 1 and not from 0. |
| 21 |
<KitListItem key={ model.id } model={ model } index={ index + 1 } queryParams={ props.queryParams?.search } source={ props.source } /> |
| 22 |
) ) |
| 23 |
} |
| 24 |
</CssGrid> |
| 25 |
); |
| 26 |
} |
| 27 |
|
| 28 |
KitList.propTypes = { |
| 29 |
data: PropTypes.arrayOf( PropTypes.instanceOf( Kit ) ), |
| 30 |
queryParams: PropTypes.shape( { |
| 31 |
search: PropTypes.string, |
| 32 |
} ), |
| 33 |
source: PropTypes.string, |
| 34 |
}; |
| 35 |
|