Skip to content

Commit

Permalink
Add nil check for null or undefined before posting to FireBat API (#3961
Browse files Browse the repository at this point in the history
)

We had a null or undefined check for fuelTypeDetails but not for weatherStation. Replaces all checks with isNil to check for null and undefined.
  • Loading branch information
conbrad authored Sep 24, 2024
1 parent efa0524 commit 8b16372
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions web/src/features/fbaCalculator/slices/fbaCalculatorSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FBAStation, FBAWeatherStationsResponse, postFBAStations } from 'api/fba
import { AppThunk } from 'app/store'
import { logError } from 'utils/error'
import { FuelTypes } from '../fuelTypes'
import { isEmpty, isEqual, isNull, isUndefined } from 'lodash'
import { isEmpty, isNil } from 'lodash'
import { FBATableRow } from 'features/fbaCalculator/RowManager'
import { DateTime } from 'luxon'
import { PST_UTC_OFFSET } from 'utils/constants'
Expand Down Expand Up @@ -60,12 +60,7 @@ export const fetchFireBehaviourStations =
async dispatch => {
const fetchableFireStations = fbcInputRows.flatMap(row => {
const fuelTypeDetails = FuelTypes.lookup(row.fuelType?.value)
if (
isNull(fuelTypeDetails) ||
isUndefined(fuelTypeDetails) ||
isUndefined(row.weatherStation) ||
isEqual(row.weatherStation, 'undefined')
) {
if (isNil(fuelTypeDetails) || isNil(row.weatherStation)) {
return []
}
return {
Expand Down

0 comments on commit 8b16372

Please sign in to comment.