diff --git a/backend/lcfs/tests/fuel_code/test_fuel_code_repo.py b/backend/lcfs/tests/fuel_code/test_fuel_code_repo.py
index 99bf2341d..6805a1e3a 100644
--- a/backend/lcfs/tests/fuel_code/test_fuel_code_repo.py
+++ b/backend/lcfs/tests/fuel_code/test_fuel_code_repo.py
@@ -158,7 +158,7 @@ async def test_get_fuel_categories(fuel_code_repo, mock_db):
@pytest.mark.anyio
-async def test_get_fuel_category_by_name(fuel_code_repo, mock_db):
+async def test_get_fuel_category_by(fuel_code_repo, mock_db):
mock_fc = FuelCategory(
fuel_category_id=2, category="Fossil", default_carbon_intensity=0
)
diff --git a/backend/lcfs/tests/notional_transfer/test_notional_transfer_services.py b/backend/lcfs/tests/notional_transfer/test_notional_transfer_services.py
index 073530a3b..3633b9910 100644
--- a/backend/lcfs/tests/notional_transfer/test_notional_transfer_services.py
+++ b/backend/lcfs/tests/notional_transfer/test_notional_transfer_services.py
@@ -47,7 +47,7 @@ async def test_get_table_options(notional_transfer_service):
async def test_create_notional_transfer(notional_transfer_service):
service, mock_repo, mock_fuel_repo = notional_transfer_service
notional_transfer_data = create_mock_schema({})
- mock_fuel_repo.get_fuel_category_by_name = AsyncMock(
+ mock_fuel_repo.get_fuel_category_by = AsyncMock(
return_value=MagicMock(fuel_category_id=1)
)
@@ -93,7 +93,7 @@ async def test_update_notional_transfer(notional_transfer_service):
mock_repo.get_latest_notional_transfer_by_group_uuid = AsyncMock(
return_value=mock_existing_transfer
)
- mock_fuel_repo.get_fuel_category_by_name = AsyncMock(
+ mock_fuel_repo.get_fuel_category_by = AsyncMock(
return_value=MagicMock(category="Gasoline")
)
diff --git a/backend/lcfs/tests/other_uses/test_other_uses_services.py b/backend/lcfs/tests/other_uses/test_other_uses_services.py
index 14b3bb518..f2c5094d4 100644
--- a/backend/lcfs/tests/other_uses/test_other_uses_services.py
+++ b/backend/lcfs/tests/other_uses/test_other_uses_services.py
@@ -66,10 +66,14 @@ async def test_create_other_use(other_uses_service):
mock_fuel_code.fuel_code = "FuelCode123"
# Mock fuel repository methods
- mock_fuel_repo.get_fuel_category_by_name = AsyncMock(return_value=mock_fuel_category)
+ mock_fuel_repo.get_fuel_category_by = AsyncMock(return_value=mock_fuel_category)
mock_fuel_repo.get_fuel_type_by_name = AsyncMock(return_value=mock_fuel_type)
- mock_fuel_repo.get_expected_use_type_by_name = AsyncMock(return_value=mock_expected_use)
- mock_fuel_repo.get_provision_of_the_act_by_name = AsyncMock(return_value=mock_provision_of_the_act)
+ mock_fuel_repo.get_expected_use_type_by_name = AsyncMock(
+ return_value=mock_expected_use
+ )
+ mock_fuel_repo.get_provision_of_the_act_by_name = AsyncMock(
+ return_value=mock_provision_of_the_act
+ )
mock_fuel_repo.get_fuel_code_by_name = AsyncMock(return_value=mock_fuel_code)
# Create a mock for the created other use
@@ -135,8 +139,10 @@ async def test_update_other_use(other_uses_service):
# Mock fuel repository methods
mock_fuel_repo.get_fuel_type_by_name = AsyncMock(return_value=mock_fuel_type)
- mock_fuel_repo.get_fuel_category_by_name = AsyncMock(return_value=mock_fuel_category)
- mock_fuel_repo.get_expected_use_type_by_name = AsyncMock(return_value=mock_expected_use)
+ mock_fuel_repo.get_fuel_category_by = AsyncMock(return_value=mock_fuel_category)
+ mock_fuel_repo.get_expected_use_type_by_name = AsyncMock(
+ return_value=mock_expected_use
+ )
mock_fuel_repo.get_provision_of_the_act_by_name = AsyncMock(
return_value=mock_provision_of_the_act
)
@@ -181,7 +187,6 @@ async def test_update_other_use(other_uses_service):
mock_repo.update_other_use.assert_awaited_once()
-
@pytest.mark.anyio
async def test_update_other_use_not_found(other_uses_service):
service, mock_repo, _ = other_uses_service
diff --git a/backend/lcfs/web/api/notional_transfer/services.py b/backend/lcfs/web/api/notional_transfer/services.py
index 4fdca07f4..cda146e32 100644
--- a/backend/lcfs/web/api/notional_transfer/services.py
+++ b/backend/lcfs/web/api/notional_transfer/services.py
@@ -6,6 +6,7 @@
from fastapi import Depends
from lcfs.db.base import UserTypeEnum, ActionTypeEnum
+from lcfs.tests.fuel_supply.test_fuel_supplies_services import fuel_category
from lcfs.web.api.notional_transfer.repo import NotionalTransferRepository
from lcfs.web.core.decorators import service_handler
from lcfs.db.models.compliance.NotionalTransfer import NotionalTransfer
@@ -50,8 +51,8 @@ async def convert_to_model(
"""
Converts data from NotionalTransferCreateSchema to NotionalTransfer data model to store into the database.
"""
- fuel_category = await self.fuel_repo.get_fuel_category_by_name(
- notional_transfer_data.fuel_category
+ fuel_category = await self.fuel_repo.get_fuel_category_by(
+ category=notional_transfer_data.fuel_category
)
return NotionalTransfer(
**notional_transfer_data.model_dump(
@@ -164,8 +165,8 @@ async def update_notional_transfer(
!= notional_transfer_data.fuel_category
):
existing_transfer.fuel_category = (
- await self.fuel_repo.get_fuel_category_by_name(
- notional_transfer_data.fuel_category
+ await self.fuel_repo.get_fuel_category_by(
+ category=notional_transfer_data.fuel_category
)
)
diff --git a/backend/lcfs/web/api/other_uses/services.py b/backend/lcfs/web/api/other_uses/services.py
index 6fcc42f85..71630658b 100644
--- a/backend/lcfs/web/api/other_uses/services.py
+++ b/backend/lcfs/web/api/other_uses/services.py
@@ -6,6 +6,7 @@
from fastapi import Depends
from lcfs.db.base import UserTypeEnum, ActionTypeEnum
+from lcfs.tests.fuel_supply.test_fuel_supplies_services import fuel_category
from lcfs.web.api.other_uses.repo import OtherUsesRepository
from lcfs.web.core.decorators import service_handler
from lcfs.db.models.compliance.OtherUses import OtherUses
@@ -52,8 +53,8 @@ async def schema_to_model(self, other_use: OtherUsesCreateSchema) -> OtherUses:
"""
Converts data from OtherUsesCreateSchema to OtherUses data model to store into the database.
"""
- fuel_category = await self.fuel_repo.get_fuel_category_by_name(
- other_use.fuel_category
+ fuel_category = await self.fuel_repo.get_fuel_category_by(
+ category=other_use.fuel_category
)
fuel_type = await self.fuel_repo.get_fuel_type_by_name(other_use.fuel_type)
expected_use = await self.fuel_repo.get_expected_use_type_by_name(
@@ -200,10 +201,8 @@ async def update_other_use(
)
if other_use.fuel_category.category != other_use_data.fuel_category:
- other_use.fuel_category = (
- await self.fuel_repo.get_fuel_category_by_name(
- other_use_data.fuel_category
- )
+ other_use.fuel_category = await self.fuel_repo.get_fuel_category_by(
+ category=other_use_data.fuel_category
)
if other_use.expected_use.name != other_use_data.expected_use:
diff --git a/frontend/src/views/Admin/AdminMenu/components/Users.jsx b/frontend/src/views/Admin/AdminMenu/components/Users.jsx
index 28f2e021b..a84541c83 100644
--- a/frontend/src/views/Admin/AdminMenu/components/Users.jsx
+++ b/frontend/src/views/Admin/AdminMenu/components/Users.jsx
@@ -1,21 +1,16 @@
-/* eslint-disable react-hooks/exhaustive-deps */
-// @mui component
import BCTypography from '@/components/BCTypography'
import BCButton from '@/components/BCButton'
import BCBox from '@/components/BCBox'
import BCAlert from '@/components/BCAlert'
import BCDataGridServer from '@/components/BCDataGrid/BCDataGridServer'
-// icons
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faCirclePlus } from '@fortawesome/free-solid-svg-icons'
-// hooks
import { useLocation, useNavigate } from 'react-router-dom'
-import { useCallback, useRef, useState, useEffect } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { ROUTES, apiRoutes } from '@/constants/routes'
-import { usersColumnDefs, idirUserDefaultFilter } from './_schema'
-import { calculateRowHeight } from '@/utils/formatters'
+import { apiRoutes, ROUTES } from '@/constants/routes'
+import { idirUserDefaultFilter, usersColumnDefs } from './_schema'
export const Users = () => {
const { t } = useTranslation(['common', 'admin'])
@@ -46,10 +41,6 @@ export const Users = () => {
return params.data.userProfileId
}, [])
- const handleRowClicked = useCallback((params) => {
- navigate(`${ROUTES.ADMIN_USERS}/${params.data.userProfileId}`)
- })
-
const gridRef = useRef()
useEffect(() => {
if (location.state?.message) {
@@ -99,7 +90,6 @@ export const Users = () => {
defaultSortModel={defaultSortModel}
defaultFilterModel={idirUserDefaultFilter}
handleGridKey={handleGridKey}
- handleRowClicked={handleRowClicked}
enableResetButton={false}
enableCopyButton={false}
/>
diff --git a/frontend/src/views/Admin/AdminMenu/components/_schema.js b/frontend/src/views/Admin/AdminMenu/components/_schema.js
index 70b652b71..980da4fed 100644
--- a/frontend/src/views/Admin/AdminMenu/components/_schema.js
+++ b/frontend/src/views/Admin/AdminMenu/components/_schema.js
@@ -109,15 +109,6 @@ export const usersColumnDefs = (t) => [
}
]
-export const usersDefaultColDef = {
- resizable: true,
- sortable: true,
- filter: true,
- minWidth: 300,
- floatingFilter: true, // enables the filter boxes under the header label
- suppressHeaderMenuButton: true // suppresses the menu button appearing next to the Header Label
-}
-
export const idirUserDefaultFilter = [
{ filterType: 'text', type: 'blank', field: 'organizationId', filter: '' }
]
diff --git a/frontend/src/views/Admin/__tests__/Users.test.jsx b/frontend/src/views/Admin/__tests__/Users.test.jsx
index 166b59d24..aaf2e0b51 100644
--- a/frontend/src/views/Admin/__tests__/Users.test.jsx
+++ b/frontend/src/views/Admin/__tests__/Users.test.jsx
@@ -34,14 +34,7 @@ vi.mock('@/utils/formatters', () => ({
// Mock BCDataGridServer component
vi.mock('@/components/BCDataGrid/BCDataGridServer', () => ({
- default: ({ handleRowClicked }) => (
-
handleRowClicked({ data: { userProfileId: '123' } })}
- >
- Mocked DataGrid
-
- )
+ default: ({}) => Mocked DataGrid
}))
// Helper component to access current location
@@ -137,22 +130,4 @@ describe('Users Component', () => {
)
expect(screen.getByText('Test alert message')).toBeInTheDocument()
})
-
- it('handles row click correctly', async () => {
- render(
-
-
-
- )
-
- // Simulate a row click
- const mockedDataGrid = screen.getByTestId('mocked-data-grid')
- fireEvent.click(mockedDataGrid)
-
- // Check if the navigation occurred
- await waitFor(() => {
- const locationDisplay = screen.getByTestId('location-display')
- expect(locationDisplay.textContent).toBe('/admin/users/123')
- })
- })
})
diff --git a/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx b/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx
index 70a536d18..9c1b6577d 100644
--- a/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx
+++ b/frontend/src/views/AllocationAgreements/AllocationAgreementSummary.jsx
@@ -1,25 +1,25 @@
import BCAlert from '@/components/BCAlert'
import BCBox from '@/components/BCBox'
import BCDataGridServer from '@/components/BCDataGrid/BCDataGridServer'
-import { apiRoutes, ROUTES } from '@/constants/routes'
+import { apiRoutes } from '@/constants/routes'
import Grid2 from '@mui/material/Unstable_Grid2/Grid2'
import { formatNumberWithCommas as valueFormatter } from '@/utils/formatters'
import { useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocation, useParams, useNavigate } from 'react-router-dom'
+import { useLocation, useParams } from 'react-router-dom'
import { v4 as uuid } from 'uuid'
import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
+import { LinkRenderer } from '@/utils/grid/cellRenderers.jsx'
export const AllocationAgreementSummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
- const [gridKey, setGridKey] = useState(`allocation-agreements-grid`)
- const { complianceReportId, compliancePeriod } = useParams()
+ const [gridKey, setGridKey] = useState('allocation-agreements-grid')
+ const { complianceReportId } = useParams()
const gridRef = useRef()
const { t } = useTranslation(['common', 'allocationAgreement'])
const location = useLocation()
- const navigate = useNavigate()
useEffect(() => {
if (location.state?.message) {
@@ -47,9 +47,16 @@ export const AllocationAgreementSummary = ({ data, status }) => {
const defaultColDef = useMemo(
() => ({
floatingFilter: false,
- filter: false
+ filter: false,
+ cellRenderer:
+ status === COMPLIANCE_REPORT_STATUSES.DRAFT ? LinkRenderer : undefined,
+ cellRendererParams: {
+ url: () => {
+ return 'allocation-agreements'
+ }
+ }
}),
- []
+ [status]
)
const columns = useMemo(
@@ -137,17 +144,6 @@ export const AllocationAgreementSummary = ({ data, status }) => {
setGridKey(`allocation-agreements-grid-${uuid()}`)
}
- const handleRowClicked = (params) => {
- if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
- navigate(
- ROUTES.REPORTS_ADD_ALLOCATION_AGREEMENTS.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
- }
- }
-
return (
@@ -159,10 +155,10 @@ export const AllocationAgreementSummary = ({ data, status }) => {
{
enableCopyButton={false}
defaultColDef={defaultColDef}
suppressPagination={data.allocationAgreements.length <= 10}
- handleRowClicked={handleRowClicked}
/>
diff --git a/frontend/src/views/ComplianceReports/EditViewComplianceReport.jsx b/frontend/src/views/ComplianceReports/EditViewComplianceReport.jsx
index dc6b075b1..e11d269f3 100644
--- a/frontend/src/views/ComplianceReports/EditViewComplianceReport.jsx
+++ b/frontend/src/views/ComplianceReports/EditViewComplianceReport.jsx
@@ -36,7 +36,6 @@ export const EditViewComplianceReport = ({ reportData, isError, error }) => {
const { t } = useTranslation(['common', 'report'])
const location = useLocation()
const [modalData, setModalData] = useState(null)
- const [internalComment, setInternalComment] = useState('')
const [hasMet, setHasMet] = useState(false)
const [isSigningAuthorityDeclared, setIsSigningAuthorityDeclared] =
useState(false)
@@ -59,9 +58,7 @@ export const EditViewComplianceReport = ({ reportData, isError, error }) => {
})
}
}
- const handleCommentChange = useCallback((newComment) => {
- setInternalComment(newComment)
- }, [])
+
const handleScroll = useCallback(() => {
const scrollTop = window.pageYOffset || document.documentElement.scrollTop
setIsScrollingUp(scrollTop < lastScrollTop || scrollTop === 0)
@@ -73,7 +70,6 @@ export const EditViewComplianceReport = ({ reportData, isError, error }) => {
return () => window.removeEventListener('scroll', handleScroll)
}, [handleScroll])
- // hooks
const {
data: currentUser,
isLoading: isCurrentUserLoading,
@@ -237,9 +233,8 @@ export const EditViewComplianceReport = ({ reportData, isError, error }) => {
diff --git a/frontend/src/views/ComplianceReports/components/ReportDetails.jsx b/frontend/src/views/ComplianceReports/components/ReportDetails.jsx
index 351110c15..cf665b3a0 100644
--- a/frontend/src/views/ComplianceReports/components/ReportDetails.jsx
+++ b/frontend/src/views/ComplianceReports/components/ReportDetails.jsx
@@ -174,7 +174,6 @@ const ReportDetails = ({ currentStatus = 'Draft' }) => {
const [expanded, setExpanded] = useState(() =>
activityList.map((_, index) => `panel${index}`)
)
- const [allExpanded, setAllExpanded] = useState(true)
const handleChange = (panel) => (event, isExpanded) => {
setExpanded((prev) =>
@@ -184,7 +183,6 @@ const ReportDetails = ({ currentStatus = 'Draft' }) => {
const handleExpandAll = () => {
setExpanded(activityList.map((_, index) => `panel${index}`))
- setAllExpanded(true)
}
const handleCollapseAll = () => {
diff --git a/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx b/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx
index a8c7935a1..e9a6d299e 100644
--- a/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx
+++ b/frontend/src/views/FinalSupplyEquipments/FinalSupplyEquipmentSummary.jsx
@@ -1,12 +1,12 @@
import BCAlert from '@/components/BCAlert'
import BCBox from '@/components/BCBox'
import BCDataGridServer from '@/components/BCDataGrid/BCDataGridServer'
-import { apiRoutes, ROUTES } from '@/constants/routes'
-import { CommonArrayRenderer } from '@/utils/grid/cellRenderers'
+import { apiRoutes } from '@/constants/routes'
+import { CommonArrayRenderer, LinkRenderer } from '@/utils/grid/cellRenderers'
import Grid2 from '@mui/material/Unstable_Grid2/Grid2'
import { useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocation, useParams, useNavigate } from 'react-router-dom'
+import { useLocation, useParams } from 'react-router-dom'
import { v4 as uuid } from 'uuid'
import { numberFormatter } from '@/utils/formatters.js'
import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
@@ -15,12 +15,11 @@ export const FinalSupplyEquipmentSummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
const [gridKey, setGridKey] = useState('final-supply-equipments-grid')
- const { complianceReportId, compliancePeriod } = useParams()
+ const { complianceReportId } = useParams()
const gridRef = useRef()
const { t } = useTranslation(['common', 'finalSupplyEquipments'])
const location = useLocation()
- const navigate = useNavigate()
useEffect(() => {
if (location.state?.message) {
@@ -29,26 +28,37 @@ export const FinalSupplyEquipmentSummary = ({ data, status }) => {
}
}, [location.state])
- const gridOptions = useMemo(() => ({
- overlayNoRowsTemplate: t(
- 'finalSupplyEquipment:noFinalSupplyEquipmentsFound'
- ),
- autoSizeStrategy: {
- type: 'fitCellContents',
- defaultMinWidth: 50,
- defaultMaxWidth: 600
- },
- enableCellTextSelection: true, // enables text selection on the grid
- ensureDomOrder: true
- }))
+ const gridOptions = useMemo(
+ () => ({
+ overlayNoRowsTemplate: t(
+ 'finalSupplyEquipment:noFinalSupplyEquipmentsFound'
+ ),
+ autoSizeStrategy: {
+ type: 'fitCellContents',
+ defaultMaxWidth: 600
+ },
+ enableCellTextSelection: true, // enables text selection on the grid
+ ensureDomOrder: true
+ }),
+ [t]
+ )
const defaultColDef = useMemo(
() => ({
+ minWidth: 200,
floatingFilter: false,
- filter: false
+ filter: false,
+ cellRenderer:
+ status === COMPLIANCE_REPORT_STATUSES.DRAFT ? LinkRenderer : undefined,
+ cellRendererParams: {
+ url: () => {
+ return 'final-supply-equipments'
+ }
+ }
}),
- []
+ [status]
)
+
const columns = useMemo(
() => [
{
@@ -188,17 +198,6 @@ export const FinalSupplyEquipmentSummary = ({ data, status }) => {
setGridKey(`final-supply-equipments-grid-${uuid()}`)
}
- const handleRowClicked = () => {
- if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
- navigate(
- ROUTES.REPORTS_ADD_FINAL_SUPPLY_EQUIPMENTS.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
- }
- }
-
return (
@@ -210,10 +209,10 @@ export const FinalSupplyEquipmentSummary = ({ data, status }) => {
{
enableCopyButton={false}
defaultColDef={defaultColDef}
suppressPagination={data.finalSupplyEquipments.length <= 10}
- handleRowClicked={handleRowClicked}
/>
diff --git a/frontend/src/views/FuelExports/FuelExportSummary.jsx b/frontend/src/views/FuelExports/FuelExportSummary.jsx
index 76898317f..6a5f76366 100644
--- a/frontend/src/views/FuelExports/FuelExportSummary.jsx
+++ b/frontend/src/views/FuelExports/FuelExportSummary.jsx
@@ -6,20 +6,19 @@ import { formatNumberWithCommas as valueFormatter } from '@/utils/formatters'
import Grid2 from '@mui/material/Unstable_Grid2/Grid2'
import { useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocation, useParams, useNavigate } from 'react-router-dom'
+import { useLocation, useParams } from 'react-router-dom'
import i18n from '@/i18n'
-import { ROUTES } from '@/constants/routes'
import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
+import { LinkRenderer } from '@/utils/grid/cellRenderers.jsx'
export const FuelExportSummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
- const { complianceReportId, compliancePeriod } = useParams()
+ const { complianceReportId } = useParams()
const gridRef = useRef()
const { t } = useTranslation(['common', 'fuelExport'])
const location = useLocation()
- const navigate = useNavigate()
useEffect(() => {
if (location.state?.message) {
@@ -44,13 +43,20 @@ export const FuelExportSummary = ({ data, status }) => {
const defaultColDef = useMemo(
() => ({
+ minWidth: 200,
floatingFilter: false,
- filter: false
+ filter: false,
+ cellRenderer:
+ status === COMPLIANCE_REPORT_STATUSES.DRAFT ? LinkRenderer : undefined,
+ cellRendererParams: {
+ url: () => {
+ return 'fuel-exports'
+ }
+ }
}),
- []
+ [status]
)
- // TODO: The values for the following columns must be determined
const columns = useMemo(
() => [
{
@@ -125,17 +131,6 @@ export const FuelExportSummary = ({ data, status }) => {
return params.data.fuelExportId.toString()
}
- const handleRowClicked = () => {
- if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
- navigate(
- ROUTES.REPORTS_ADD_FUEL_EXPORTS.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
- }
- }
-
return (
@@ -147,10 +142,10 @@ export const FuelExportSummary = ({ data, status }) => {
{
enableCopyButton={false}
defaultColDef={defaultColDef}
suppressPagination={data.fuelExports.length <= 10}
- onRowClicked={handleRowClicked}
/>
diff --git a/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx b/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx
index 6944b0383..45d327b06 100644
--- a/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx
+++ b/frontend/src/views/FuelSupplies/FuelSupplySummary.jsx
@@ -1,27 +1,26 @@
import BCAlert from '@/components/BCAlert'
import BCBox from '@/components/BCBox'
import BCDataGridServer from '@/components/BCDataGrid/BCDataGridServer'
-import { apiRoutes, ROUTES } from '@/constants/routes'
+import { apiRoutes } from '@/constants/routes'
import { formatNumberWithCommas as valueFormatter } from '@/utils/formatters'
import Grid2 from '@mui/material/Unstable_Grid2/Grid2'
import { useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocation, useNavigate, useParams } from 'react-router-dom'
+import { useLocation, useParams } from 'react-router-dom'
import { v4 as uuid } from 'uuid'
import i18n from '@/i18n'
-import { StandardCellWarningAndErrors } from '@/utils/grid/errorRenderers'
import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
+import { LinkRenderer } from '@/utils/grid/cellRenderers.jsx'
export const FuelSupplySummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
const [gridKey, setGridKey] = useState(`fuel-supplies-grid`)
- const { complianceReportId, compliancePeriod } = useParams()
+ const { complianceReportId } = useParams()
const gridRef = useRef()
const { t } = useTranslation(['common', 'fuelSupply'])
const location = useLocation()
- const navigate = useNavigate()
useEffect(() => {
if (location.state?.message) {
@@ -35,7 +34,6 @@ export const FuelSupplySummary = ({ data, status }) => {
overlayNoRowsTemplate: t('fuelSupply:noFuelSuppliesFound'),
autoSizeStrategy: {
type: 'fitCellContents',
- defaultMinWidth: 50,
defaultMaxWidth: 600
},
enableCellTextSelection: true, // enables text selection on the grid
@@ -46,10 +44,18 @@ export const FuelSupplySummary = ({ data, status }) => {
const defaultColDef = useMemo(
() => ({
+ minWidth: 200,
floatingFilter: false,
- filter: false
+ filter: false,
+ cellRenderer:
+ status === COMPLIANCE_REPORT_STATUSES.DRAFT ? LinkRenderer : undefined,
+ cellRendererParams: {
+ url: () => {
+ return 'supply-of-fuel'
+ }
+ }
}),
- []
+ [status]
)
// TODO: The values for the following columns must be determined
@@ -92,7 +98,10 @@ export const FuelSupplySummary = ({ data, status }) => {
field: 'quantity',
valueFormatter
},
- { headerName: t('fuelSupply:fuelSupplyColLabels.units'), field: 'units' },
+ {
+ headerName: t('fuelSupply:fuelSupplyColLabels.units'),
+ field: 'units'
+ },
{
headerName: t('fuelSupply:fuelSupplyColLabels.targetCi'),
field: 'targetCi'
@@ -109,7 +118,10 @@ export const FuelSupplySummary = ({ data, status }) => {
headerName: t('fuelSupply:fuelSupplyColLabels.energyDensity'),
field: 'energyDensity'
},
- { headerName: t('fuelSupply:fuelSupplyColLabels.eer'), field: 'eer' },
+ {
+ headerName: t('fuelSupply:fuelSupplyColLabels.eer'),
+ field: 'eer'
+ },
{
headerName: t('fuelSupply:fuelSupplyColLabels.energy'),
field: 'energy',
@@ -127,17 +139,6 @@ export const FuelSupplySummary = ({ data, status }) => {
setGridKey(`fuel-supplies-grid-${uuid()}`)
}
- const handleRowClicked = () => {
- if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
- navigate(
- ROUTES.REPORTS_ADD_SUPPLY_OF_FUEL.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
- }
- }
-
return (
@@ -162,7 +163,6 @@ export const FuelSupplySummary = ({ data, status }) => {
enableCopyButton={false}
defaultColDef={defaultColDef}
suppressPagination={data.fuelSupplies.length <= 10}
- handleRowClicked={handleRowClicked}
/>
diff --git a/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx b/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx
index daa71fae1..4af53f091 100644
--- a/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx
+++ b/frontend/src/views/NotionalTransfers/NotionalTransferSummary.jsx
@@ -3,21 +3,20 @@ import BCBox from '@/components/BCBox'
import { BCGridViewer } from '@/components/BCDataGrid/BCGridViewer'
import { useGetNotionalTransfers } from '@/hooks/useNotionalTransfer'
import Grid2 from '@mui/material/Unstable_Grid2/Grid2'
-import { useEffect, useState, useMemo } from 'react'
+import { useEffect, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useLocation, useParams, useNavigate } from 'react-router-dom'
+import { useLocation, useParams } from 'react-router-dom'
import { formatNumberWithCommas as valueFormatter } from '@/utils/formatters'
-import { ROUTES } from '@/constants/routes'
import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
+import { LinkRenderer } from '@/utils/grid/cellRenderers.jsx'
export const NotionalTransferSummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
- const { complianceReportId, compliancePeriod } = useParams()
+ const { complianceReportId } = useParams()
const { t } = useTranslation(['common', 'notionalTransfers'])
const location = useLocation()
- const navigate = useNavigate()
useEffect(() => {
if (location.state?.message) {
@@ -29,37 +28,32 @@ export const NotionalTransferSummary = ({ data, status }) => {
const getRowId = (params) => params.data.notionalTransferId
const defaultColDef = useMemo(
() => ({
+ minWidth: 200,
floatingFilter: false,
- filter: false
+ filter: false,
+ cellRenderer:
+ status === COMPLIANCE_REPORT_STATUSES.DRAFT ? LinkRenderer : undefined,
+ cellRendererParams: {
+ url: () => {
+ return 'notional-transfers'
+ }
+ }
}),
- []
+ [status]
)
- const handleRowClicked = () => {
- if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
- navigate(
- ROUTES.REPORTS_ADD_NOTIONAL_TRANSFERS.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
- }
- }
-
const columns = [
{
headerName: t('notionalTransfer:notionalTransferColLabels.legalName'),
field: 'legalName',
- flex: 1,
- minWidth: 200
+ flex: 1
},
{
headerName: t(
'notionalTransfer:notionalTransferColLabels.addressForService'
),
field: 'addressForService',
- flex: 1,
- minWidth: 200
+ flex: 1
},
{
headerName: t('notionalTransfer:notionalTransferColLabels.fuelCategory'),
@@ -89,13 +83,13 @@ export const NotionalTransferSummary = ({ data, status }) => {
{
enableCellTextSelection
ensureDomOrder
handleRo
- onRowClicked={handleRowClicked}
/>
diff --git a/frontend/src/views/OtherUses/OtherUsesSummary.jsx b/frontend/src/views/OtherUses/OtherUsesSummary.jsx
index 4c6a203ed..cefd8754a 100644
--- a/frontend/src/views/OtherUses/OtherUsesSummary.jsx
+++ b/frontend/src/views/OtherUses/OtherUsesSummary.jsx
@@ -3,25 +3,24 @@ import BCBox from '@/components/BCBox'
import { BCGridViewer } from '@/components/BCDataGrid/BCGridViewer'
import { useGetOtherUses } from '@/hooks/useOtherUses'
import Grid2 from '@mui/material/Unstable_Grid2/Grid2'
-import { useEffect, useState } from 'react'
-import { useLocation, useParams, useNavigate } from 'react-router-dom'
+import { useEffect, useMemo, useState } from 'react'
+import { useLocation, useParams } from 'react-router-dom'
import {
- formatNumberWithCommas as valueFormatter,
- decimalFormatter
+ decimalFormatter,
+ formatNumberWithCommas as valueFormatter
} from '@/utils/formatters'
import { useTranslation } from 'react-i18next'
-import { ROUTES } from '@/constants/routes'
import { COMPLIANCE_REPORT_STATUSES } from '@/constants/statuses.js'
+import { LinkRenderer } from '@/utils/grid/cellRenderers.jsx'
export const OtherUsesSummary = ({ data, status }) => {
const [alertMessage, setAlertMessage] = useState('')
const [alertSeverity, setAlertSeverity] = useState('info')
const { t } = useTranslation(['common', 'otherUses'])
- const { complianceReportId, compliancePeriod } = useParams()
+ const { complianceReportId } = useParams()
const location = useLocation()
- const navigate = useNavigate()
useEffect(() => {
if (location.state?.message) {
@@ -30,6 +29,22 @@ export const OtherUsesSummary = ({ data, status }) => {
}
}, [location.state])
+ const defaultColDef = useMemo(
+ () => ({
+ minWidth: 200,
+ floatingFilter: false,
+ filter: false,
+ cellRenderer:
+ status === COMPLIANCE_REPORT_STATUSES.DRAFT ? LinkRenderer : undefined,
+ cellRendererParams: {
+ url: () => {
+ return 'fuels-other-use'
+ }
+ }
+ }),
+ [status]
+ )
+
const columns = [
{
headerName: t('otherUses:otherUsesColLabels.fuelType'),
@@ -73,30 +88,17 @@ export const OtherUsesSummary = ({ data, status }) => {
headerName: t('otherUses:otherUsesColLabels.expectedUse'),
field: 'expectedUse',
floatingFilter: false,
- flex: 1,
- minWidth: 200
+ flex: 1
},
{
headerName: t('otherUses:otherUsesColLabels.rationale'),
field: 'rationale',
floatingFilter: false,
- flex: 1,
- minWidth: 200
+ flex: 1
}
]
- const getRowId = (params) => params.data.otherUsesId
-
- const handleRowClicked = () => {
- if (status === COMPLIANCE_REPORT_STATUSES.DRAFT) {
- navigate(
- ROUTES.REPORTS_ADD_OTHER_USE_FUELS.replace(
- ':compliancePeriod',
- compliancePeriod
- ).replace(':complianceReportId', complianceReportId)
- )
- }
- }
+ const getRowId = (params) => params.data.otherUsesId.toString()
return (
@@ -109,22 +111,20 @@ export const OtherUsesSummary = ({ data, status }) => {