diff --git a/backend/lcfs/web/api/final_supply_equipment/schema.py b/backend/lcfs/web/api/final_supply_equipment/schema.py index 0751354bd..38f80b2fa 100644 --- a/backend/lcfs/web/api/final_supply_equipment/schema.py +++ b/backend/lcfs/web/api/final_supply_equipment/schema.py @@ -40,7 +40,7 @@ class FinalSupplyEquipmentCreateSchema(BaseSchema): compliance_report_id: Optional[int] = None supply_from_date: date supply_to_date: date - kwh_usage: Optional[float] = None + kwh_usage: float serial_nbr: str manufacturer: str model: Optional[str] = None diff --git a/frontend/src/views/FinalSupplyEquipments/AddEditFinalSupplyEquipments.jsx b/frontend/src/views/FinalSupplyEquipments/AddEditFinalSupplyEquipments.jsx index 5fb458294..fbfa3ceb3 100644 --- a/frontend/src/views/FinalSupplyEquipments/AddEditFinalSupplyEquipments.jsx +++ b/frontend/src/views/FinalSupplyEquipments/AddEditFinalSupplyEquipments.jsx @@ -151,8 +151,9 @@ export const AddEditFinalSupplyEquipments = () => { if (fields[0] === 'postalCode') { errMsg = t('finalSupplyEquipment:postalCodeError') } else { - errMsg = `Error updating row: ${fieldLabels.length === 1 ? fieldLabels[0] : '' - } ${String(message).toLowerCase()}` + errMsg = `Error updating row: ${ + fieldLabels.length === 1 ? fieldLabels[0] : '' + } ${String(message).toLowerCase()}` } } else { errMsg = error.response.data?.detail @@ -206,6 +207,7 @@ export const AddEditFinalSupplyEquipments = () => { const rowData = { ...params.node.data, id: newRowID, + kwhUsage: null, serialNbr: null, latitude: null, longitude: null, @@ -239,16 +241,21 @@ export const AddEditFinalSupplyEquipments = () => { ) }, [navigate, compliancePeriod, complianceReportId]) - const onAddRows = useCallback((numRows) => { - return Array(numRows).fill().map(() => ({ - id: uuid(), - complianceReportId, - supplyFromDate: `${compliancePeriod}-01-01`, - supplyToDate: `${compliancePeriod}-12-31`, - validationStatus: 'error', - modified: true - })) - }, [compliancePeriod, complianceReportId]) + const onAddRows = useCallback( + (numRows) => { + return Array(numRows) + .fill() + .map(() => ({ + id: uuid(), + complianceReportId, + supplyFromDate: `${compliancePeriod}-01-01`, + supplyToDate: `${compliancePeriod}-12-31`, + validationStatus: 'error', + modified: true + })) + }, + [compliancePeriod, complianceReportId] + ) return ( isFetched && diff --git a/frontend/src/views/FinalSupplyEquipments/_schema.jsx b/frontend/src/views/FinalSupplyEquipments/_schema.jsx index fb431246e..67a25c44d 100644 --- a/frontend/src/views/FinalSupplyEquipments/_schema.jsx +++ b/frontend/src/views/FinalSupplyEquipments/_schema.jsx @@ -14,11 +14,7 @@ import { CommonArrayRenderer } from '@/utils/grid/cellRenderers' import { StandardCellErrors } from '@/utils/grid/errorRenderers' import { apiRoutes } from '@/constants/routes' -export const finalSupplyEquipmentColDefs = ( - optionsData, - compliancePeriod, - errors -) => [ +export const finalSupplyEquipmentColDefs = (optionsData, compliancePeriod, errors) => [ validation, actions({ enableDuplicate: true, @@ -75,6 +71,7 @@ export const finalSupplyEquipmentColDefs = ( }, { field: 'kwhUsage', + headerComponent: RequiredHeader, headerName: i18n.t( 'finalSupplyEquipment:finalSupplyEquipmentColLabels.kwhUsage' ), @@ -83,9 +80,9 @@ export const finalSupplyEquipmentColDefs = ( cellDataType: 'text', cellStyle: (params) => StandardCellErrors(params, errors), valueFormatter: (params) => { - const value = parseFloat(params.value); - return !isNaN(value) ? value.toFixed(2) : ''; - }, + const value = parseFloat(params.value) + return !isNaN(value) ? value.toFixed(2) : '' + } }, { field: 'serialNbr', @@ -110,13 +107,15 @@ export const finalSupplyEquipmentColDefs = ( queryKey: 'fuel-code-search', queryFn: async ({ client, queryKey }) => { try { - const [, searchTerm] = queryKey; - const path = `${apiRoutes.searchFinalSupplyEquipments}manufacturer=${encodeURIComponent(searchTerm)}`; - const response = await client.get(path); - return response.data; + const [, searchTerm] = queryKey + const path = `${ + apiRoutes.searchFinalSupplyEquipments + }manufacturer=${encodeURIComponent(searchTerm)}` + const response = await client.get(path) + return response.data } catch (error) { - console.error('Error fetching manufacturer data:', error); - return []; + console.error('Error fetching manufacturer data:', error) + return [] } }, optionLabel: 'manufacturer',