Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LCFS-1515: Fuel supply, Other, Jet fuel category #1521

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/assets/locales/en/fuelSupply.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"fuelSupplyId": "Fuel supply ID",
"fuelType": "Fuel type",
"fuelTypeOther": "Fuel type other",
"fuelCategory": "Fuel category",
"fuelCategoryId": "Fuel category",
"endUse": "End use",
"provisionOfTheActId": "Determining carbon intensity",
"fuelCode": "Fuel code",
Expand Down
16 changes: 10 additions & 6 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 @@ -161,10 +161,12 @@ export const AddEditFuelSupplies = () => {
(item) => item.fuelCategory
)

params.node.setDataValue(
'fuelCategory',
fuelCategoryOptions[0] ?? null
)
// Set to null if multiple options, otherwise use first item
const categoryValue = fuelCategoryOptions.length === 1
? fuelCategoryOptions[0]
: null

params.node.setDataValue('fuelCategory', categoryValue)
}
}
},
Expand Down Expand Up @@ -199,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
areyeslo marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -147,7 +148,7 @@ export const fuelSupplyColDefs = (optionsData, errors, warnings) => [
{
field: 'fuelCategory',
headerComponent: RequiredHeader,
headerName: i18n.t('fuelSupply:fuelSupplyColLabels.fuelCategory'),
headerName: i18n.t('fuelSupply:fuelSupplyColLabels.fuelCategoryId'),
areyeslo marked this conversation as resolved.
Show resolved Hide resolved
cellEditor: AutocompleteCellEditor,
cellRenderer: (params) =>
params.value ||
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
Loading