diff --git a/platform/src/common/components/Dropdowns/OrganizationDropdown.jsx b/platform/src/common/components/Dropdowns/OrganizationDropdown.jsx index 9f2f8b2135..9811b87452 100644 --- a/platform/src/common/components/Dropdowns/OrganizationDropdown.jsx +++ b/platform/src/common/components/Dropdowns/OrganizationDropdown.jsx @@ -14,15 +14,8 @@ const formatGroupName = (name) => { const trimmedName = name.trim(); if (!trimmedName) return 'Unknown'; - return trimmedName.toLowerCase() === 'airqo' - ? 'AirQo' - : trimmedName - .replace(/_/g, ' ') - .split(' ') - .map( - (word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(), - ) - .join(' '); + // make name upper case and replace _ or - with space + return trimmedName.toUpperCase().replace(/_/g, ' ').replace(/-/g, ' '); }; const getAbbreviation = (name) => { diff --git a/platform/src/common/components/Modal/dataDownload/components/CustomFields.jsx b/platform/src/common/components/Modal/dataDownload/components/CustomFields.jsx index be261453ff..14cb2b8868 100644 --- a/platform/src/common/components/Modal/dataDownload/components/CustomFields.jsx +++ b/platform/src/common/components/Modal/dataDownload/components/CustomFields.jsx @@ -4,11 +4,18 @@ import CheckIcon from '@/icons/tickIcon'; import CustomDropdown from '../../../Dropdowns/CustomDropdown'; import DatePicker from '../../../Calendar/DatePicker'; -const formatName = (name) => { - if (typeof name === 'string' && name.toLowerCase() === 'airqo') { - return 'AirQo'; - } - return name; +const capitalize = (name) => { + if (typeof name !== 'string' || !name) return name; + return name.charAt(0).toUpperCase() + name.slice(1); +}; + +const formatName = (name, textFormat = 'lowercase') => { + if (typeof name !== 'string' || !name) return name; + return typeof name === 'string' + ? textFormat === 'uppercase' + ? name.toUpperCase().replace(/_/g, ' ').replace(/-/g, ' ') + : name.replace(/_/g, ' ').replace(/-/g, ' ') + : capitalize(name); }; const CustomFields = ({ @@ -22,6 +29,7 @@ const CustomFields = ({ useCalendar = false, handleOptionSelect, defaultOption, + textFormat = 'lowercase', }) => { const [selectedOption, setSelectedOption] = useState( defaultOption || options[0], @@ -65,9 +73,13 @@ const CustomFields = ({ tabStyle="w-full bg-white px-3 py-2" dropdown tabIcon={icon} - btnText={btnText || formatName(selectedOption.name)} + btnText={ + formatName(btnText, textFormat) || + formatName(selectedOption.name, textFormat) + } customPopperStyle={{ left: '-7px' }} dropDownClass="w-full" + textFormat={textFormat} > {options.map((option) => ( - - {formatName(option.name)} + + {formatName(option.name, textFormat)} {selectedOption.id === option.id && ( @@ -102,6 +114,7 @@ CustomFields.propTypes = { useCalendar: PropTypes.bool, handleOptionSelect: PropTypes.func, defaultOption: PropTypes.object, + textFormat: PropTypes.oneOf(['uppercase', 'lowercase']), }; export default CustomFields; diff --git a/platform/src/common/components/Modal/dataDownload/modules/DataDownload.jsx b/platform/src/common/components/Modal/dataDownload/modules/DataDownload.jsx index 57f5d3aebf..96bea2eec8 100644 --- a/platform/src/common/components/Modal/dataDownload/modules/DataDownload.jsx +++ b/platform/src/common/components/Modal/dataDownload/modules/DataDownload.jsx @@ -301,6 +301,7 @@ const DataDownload = ({ onClose }) => { icon={} defaultOption={formData.network} handleOptionSelect={handleOptionSelect} + textFormat="uppercase" />