Skip to content

Commit

Permalink
Merge pull request #2330 from airqo-platform/staging
Browse files Browse the repository at this point in the history
move to production
  • Loading branch information
Baalmart authored Dec 11, 2024
2 parents 65c8458 + 08e7113 commit a7bacd2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion k8s/platform/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ replicaCount: 1
image:
repository: eu.gcr.io/airqo-250220/airqo-next-platform
pullPolicy: Always
tag: prod-823ae890-1733864897
tag: prod-65c8458f-1733919600
imagePullSecrets: []
nameOverride: ''
fullnameOverride: ''
Expand Down
2 changes: 1 addition & 1 deletion k8s/platform/values-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ replicaCount: 1
image:
repository: eu.gcr.io/airqo-250220/airqo-stage-next-platform
pullPolicy: Always
tag: stage-120af456-1733864746
tag: stage-de8088b6-1733919394
imagePullSecrets: []
nameOverride: ''
fullnameOverride: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,28 @@ import DatePicker from '../../../Calendar/DatePicker';
/**
* Formats the name based on the specified text format.
* Replaces underscores and hyphens with spaces.
* @param {string} name - The string to format.
* @param {string} textFormat - The desired text format ('uppercase' or 'lowercase').
* @returns {string} - The formatted string.
*/
const formatName = (name, textFormat = 'lowercase') => {
if (typeof name !== 'string' || !name) return name;
const formatted = name.replace(/[_-]/g, ' '); // Replace underscores and hyphens with spaces
const formatted = name.replace(/[_-]/g, ' ');
return textFormat === 'uppercase' ? formatted.toUpperCase() : formatted;
};

/**
* Formats the field value based on the field ID.
* If the field ID is 'organization', it returns the value in uppercase without altering hyphens.
* Otherwise, it applies the formatName function.
*/
const formatFieldValue = (value, fieldId, textFormat) => {
if (fieldId === 'organization') {
return value.toUpperCase();
}
return formatName(value, textFormat);
};

/**
* CustomFields Component
* Renders different types of input fields based on props.
*
* @param {object} props - Component properties.
* @returns {JSX.Element} - Rendered component.
*/
const CustomFields = ({
field = false,
Expand All @@ -38,22 +44,18 @@ const CustomFields = ({
textFormat = 'lowercase',
}) => {
const [selectedOption, setSelectedOption] = useState(
defaultOption || options[0],
defaultOption || (options.length > 0 ? options[0] : { id: '', name: '' }),
);

/**
* Handles the selection of an option.
* Conditionally formats the name based on the field's ID.
*
* @param {object} option - The selected option object.
*/
const handleSelect = useCallback(
(option) => {
// Determine if formatting should be applied
const shouldFormat = id !== 'organization';
const formattedOption = {
...option,
name: shouldFormat ? formatName(option.name, textFormat) : option.name,
name: formatFieldValue(option.name, id, textFormat),
};
setSelectedOption(formattedOption);
handleOptionSelect(id, formattedOption);
Expand All @@ -69,12 +71,10 @@ const CustomFields = ({
// Render a text input field
<input
className="bg-transparent text-[16px] font-medium leading-6 p-0 m-0 w-full h-auto border-none"
value={
id === 'organization'
? selectedOption.name
: formatName(selectedOption.name, textFormat)
value={formatFieldValue(selectedOption.name, id, textFormat)}
onChange={(e) =>
handleSelect({ ...selectedOption, name: e.target.value })
}
onChange={(e) => handleSelect({ name: e.target.value })}
type="text"
name={id}
disabled={!edit}
Expand All @@ -98,7 +98,7 @@ const CustomFields = ({
btnText={
btnText
? formatName(btnText, textFormat)
: formatName(selectedOption.name, textFormat)
: formatFieldValue(selectedOption.name, id, textFormat)
}
customPopperStyle={{ left: '-7px' }}
dropDownClass="w-full"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ const DataDownload = ({ onClose }) => {
*/
useEffect(() => {
if (formData.organization) {
dispatch(fetchSitesSummary({ group: formData.organization.name }));
dispatch(
fetchSitesSummary({ group: formData.organization.name.toLowerCase() }),
);
}
}, [dispatch, formData.organization]);

Expand Down

0 comments on commit a7bacd2

Please sign in to comment.