UNPKG

@tractorzoom/equipment-attributes

Version:

Source of truth for equipment attributes by category

54 lines (53 loc) 1.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAttrText = void 0; const format_1 = require("./format"); const get_width_text_1 = require("./get-width-text"); const getAttrText = (attr, props) => { const attrName = attr.name; const subcategory = props.subcategory || ''; if (attr.type === 'string') { return props[attrName]; } if (attrName === 'width' && (props.widthFeet || props.widthInches)) { return (0, get_width_text_1.getWidthText)({ widthFeet: props.widthFeet, widthInches: props.widthInches, subcategory, }); } if (attrName === 'capacity' && (props.ton || props.gallon || props.bushels)) { const ton = props.ton; const gallon = props.gallon; const bushels = props.bushels; if (ton) { return `${(0, format_1.formatNumberWithThousandSeparator)(ton)} T`; } if (bushels) { return `${(0, format_1.formatNumberWithThousandSeparator)(bushels)} Bu`; } return `${(0, format_1.formatNumberWithThousandSeparator)(gallon)} Gal`; } if (attr.switch || typeof props[attrName] === 'boolean') { if (props[attrName]) { return 'Yes'; } else if (props[attrName] === false) { return 'No'; } else return ''; } // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation> if (props.hasOwnProperty(attrName)) { const value = props[attrName]; if (attr.shortName) { return `${(0, format_1.formatNumberWithThousandSeparator)(value)} ${attr.shortName}`; } else { return (0, format_1.formatNumberWithThousandSeparator)(value); } } return ''; }; exports.getAttrText = getAttrText;