Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | 16x 16x 16x 16x 16x 16x 20x 20x 21x 20x 16x 22x 22x 22x 22x 22x 22x 22x 22x 3x 19x 20x 16x | import { ShippingOption } from '@bigcommerce/checkout-sdk'; import React, { memo, useCallback, FunctionComponent } from 'react'; import { EMPTY_ARRAY } from '../../common/utility'; import { Checklist, ChecklistItem } from '../../ui/form'; import { LoadingOverlay } from '../../ui/loading'; import StaticShippingOption from './StaticShippingOption'; interface ShippingOptionListItemProps { consignmentId: string; shippingOption: ShippingOption; } const ShippingOptionListItem: FunctionComponent<ShippingOptionListItemProps> = ({ consignmentId, shippingOption, }) => { const renderLabel = useCallback(() => ( <div className="shippingOptionLabel"> <StaticShippingOption displayAdditionalInformation={ true } method={ shippingOption } /> </div> ), [shippingOption]); return <ChecklistItem htmlId={ `shippingOptionRadio-${consignmentId}-${shippingOption.id}` } label={ renderLabel } value={ shippingOption.id } />; }; export interface ShippingOptionListProps { consignmentId: string; inputName: string; isLoading: boolean; selectedShippingOptionId?: string; shippingOptions?: ShippingOption[]; onSelectedOption(consignmentId: string, shippingOptionId: string): void; } const ShippingOptionsList: FunctionComponent<ShippingOptionListProps> = ({ consignmentId, inputName, isLoading, shippingOptions = EMPTY_ARRAY, selectedShippingOptionId, onSelectedOption, }) => { const handleSelect = useCallback((value: string) => { onSelectedOption(consignmentId, value); }, [ consignmentId, onSelectedOption, ]); if (!shippingOptions.length) { return null; } return ( <LoadingOverlay isLoading={ isLoading }> <Checklist aria-live="polite" defaultSelectedItemId={ selectedShippingOptionId } name={ inputName } onSelect={ handleSelect } > { shippingOptions.map(shippingOption => ( <ShippingOptionListItem consignmentId={ consignmentId } key={ shippingOption.id } shippingOption={ shippingOption } /> )) } </Checklist> </LoadingOverlay> ); }; export default memo(ShippingOptionsList); |