Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
areyeslo committed Dec 20, 2024
1 parent da7a5b4 commit eace15c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
6 changes: 4 additions & 2 deletions frontend/src/views/FuelSupplies/AddEditFuelSupplies.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
useGetFuelSupplies,
useSaveFuelSupply
} from '@/hooks/useFuelSupply'
import { isArrayEmpty } from '@/utils/formatters'
import { isArrayEmpty, cleanEmptyStringValues } from '@/utils/formatters'
import BCTypography from '@/components/BCTypography'
import Grid2 from '@mui/material/Unstable_Grid2/Grid2'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
Expand Down Expand Up @@ -201,7 +201,9 @@ export const AddEditFuelSupplies = () => {
severity: 'pending'
})

let updatedData = params.node.data
// clean up any null or empty string values
let updatedData = cleanEmptyStringValues(params.node.data)

if (updatedData.fuelType === 'Other') {
updatedData.ciOfFuel = DEFAULT_CI_FUEL[updatedData.fuelCategory]
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/FuelSupplies/FuelSupplySummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const FuelSupplySummary = ({ data, status }) => {
valueGetter: (params) => params.data.fuelType?.fuelType
},
{
headerName: t('fuelSupply:fuelSupplyColLabels.fuelCategory'),
headerName: t('fuelSupply:fuelSupplyColLabels.fuelCategoryId'),
field: 'fuelCategory',
valueGetter: (params) => params.data.fuelCategory?.category
},
Expand Down
14 changes: 3 additions & 11 deletions frontend/src/views/FuelSupplies/_schema.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const fuelSupplyColDefs = (optionsData, errors, warnings) => [
params.data.fuelTypeId = fuelType?.fuelTypeId
params.data.fuelTypeOther = null
params.data.fuelCategory = null
params.data.fuelCategoryId = null
params.data.endUseId = null
params.data.endUseType = null
params.data.eer = null
Expand Down Expand Up @@ -145,7 +146,7 @@ export const fuelSupplyColDefs = (optionsData, errors, warnings) => [
minWidth: 250
},
{
field: 'fuelCategoryId',
field: 'fuelCategory',
headerComponent: RequiredHeader,
headerName: i18n.t('fuelSupply:fuelSupplyColLabels.fuelCategoryId'),
cellEditor: AutocompleteCellEditor,
Expand Down Expand Up @@ -182,16 +183,7 @@ export const fuelSupplyColDefs = (optionsData, errors, warnings) => [
},
suppressKeyboardEvent,
minWidth: 135,
valueGetter: (params) => {
const options = optionsData?.fuelTypes
?.find((obj) => params.data.fuelType === obj.fuelType)
?.fuelCategories.map((item) => item.fuelCategory)
if (options?.length === 1) {
return options[0]
} else {
return params.data.fuelCategory
}
},
valueGetter: (params) => params.data.fuelCategory,
editable: (params) =>
optionsData?.fuelTypes
?.find((obj) => params.data.fuelType === obj.fuelType)
Expand Down

0 comments on commit eace15c

Please sign in to comment.