| 1 |
export const fillRateAttrValues = function ( carrierRateId, data, source, rateAttrValues ) { |
| 2 |
for ( let attrKey in data ) { |
| 3 |
if ( ! data.hasOwnProperty( attrKey ) ) { |
| 4 |
continue; |
| 5 |
} |
| 6 |
|
| 7 |
const { name, widgetResultField, isWidgetResultField } = |
| 8 |
data[ attrKey ]; |
| 9 |
|
| 10 |
if ( false === isWidgetResultField ) { |
| 11 |
continue; |
| 12 |
} |
| 13 |
|
| 14 |
let widgetField = widgetResultField || attrKey; |
| 15 |
let addressFieldValue = source[ widgetField ]; |
| 16 |
|
| 17 |
rateAttrValues[ carrierRateId ] = |
| 18 |
rateAttrValues[ carrierRateId ] || {}; |
| 19 |
rateAttrValues[ carrierRateId ][ name ] = addressFieldValue; |
| 20 |
} |
| 21 |
|
| 22 |
return rateAttrValues; |
| 23 |
}; |
| 24 |
|