Skip to content

Commit

Permalink
Merge branch 'release-0.2.0' into fix/alex-marine-1498
Browse files Browse the repository at this point in the history
  • Loading branch information
prv-proton authored Jan 8, 2025
2 parents e53d4d6 + 70956ab commit fde3414
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion frontend/src/assets/locales/en/fuelCode.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"company": "Company",
"contactName": "Contact name",
"contactEmail": "Contact email",
"carbonIntensity": "Carbon intensity (gCO²e/MJ)",
"carbonIntensity": "Carbon intensity (gCOe/MJ)",
"edrms": "EDRMS#",
"applicationDate": "Application date",
"approvalDate": "Approval date",
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/BCDataGrid/BCDataGridServer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ const BCDataGridServer = ({

// Memorized default column definition parameters
const defaultColDefParams = useMemo(() => ({
headerComponent: AccessibleHeader,
headerComponentParams: {
innerHeaderComponent: AccessibleHeader
},
suppressHeaderFilterButton: true,
resizable: true,
sortable: true,
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/components/BCDataGrid/BCGridViewer.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import BCAlert, { FloatingAlert } from '@/components/BCAlert'
import BCBox from '@/components/BCBox'
import { BCGridBase } from '@/components/BCDataGrid/BCGridBase'
import { AccessibleHeader, BCPagination } from '@/components/BCDataGrid/components'
import {
AccessibleHeader,
BCPagination
} from '@/components/BCDataGrid/components'
import '@ag-grid-community/styles/ag-grid.css'
import '@ag-grid-community/styles/ag-theme-material.css'
import { useCallback, useMemo, useRef, useState } from 'react'
Expand Down Expand Up @@ -161,7 +164,9 @@ export const BCGridViewer = ({

const defaultColDefParams = useMemo(
() => ({
headerComponent: AccessibleHeader,
headerComponentParams: {
innerHeaderComponent: AccessibleHeader
},
suppressHeaderFilterButton: true,
resizable: true,
sortable: true,
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export const Login = () => {
<BCButton
variant="contained"
color="primary"
aria-label="Login with BCeID"
onClick={() => {
keycloak.login({
idpHint: IDENTITY_PROVIDERS.BCEID_BUSINESS,
Expand Down Expand Up @@ -221,6 +222,7 @@ export const Login = () => {
<BCButton
variant="outlined"
color="white"
aria-label="Login with IDIR"
onClick={() => {
keycloak.login({
idpHint: IDENTITY_PROVIDERS.IDIR,
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/hooks/useOrganization.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { apiRoutes } from '@/constants/routes'
import { useApiService } from '@/services/useApiService'
import { useQuery } from '@tanstack/react-query'
import { useCurrentUser } from './useCurrentUser'
import { roles } from '@/constants/roles'

export const useOrganization = (orgID, options) => {
const client = useApiService()
Expand Down Expand Up @@ -29,14 +30,24 @@ export const useOrganizationUser = (orgID, userID, options) => {

export const useOrganizationBalance = (orgID, options) => {
const client = useApiService()
const { hasRoles } = useCurrentUser()
const hasAccess = hasRoles(roles.government)

return useQuery({
queryKey: ['organization-balance', orgID],
queryFn: async () =>
orgID ? (await client.get(`/organizations/balances/${orgID}`)).data : {},
queryFn: async () => {
if (!hasAccess) {
return null
}
return orgID
? (await client.get(`/organizations/balances/${orgID}`)).data
: {}
},
enabled: hasAccess && !!orgID,
...options
})
}

export const useCurrentOrgBalance = (options) => {
const client = useApiService()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,9 @@ export const ViewOrganization = () => {
orgID ?? currentUser?.organization?.organizationId
)

let orgBalance = {}
if (hasRoles(roles.government)) {
// eslint-disable-next-line react-hooks/rules-of-hooks
orgBalance = useOrganizationBalance(orgID)
}
const { data: orgBalaceInfo } = orgBalance
const { data: orgBalanceInfo } = useOrganizationBalance(
orgID ?? currentUser?.organization?.organizationId
)

const canEdit = hasRoles(roles.administrator)
const editButtonRoute = canEdit
Expand Down Expand Up @@ -174,9 +171,9 @@ export const ViewOrganization = () => {
<Role roles={[roles.government]}>
<BCTypography variant="body4">
<strong>{t('org:complianceUnitBalance')}:</strong>{' '}
{orgBalaceInfo?.totalBalance.toLocaleString()} (
{orgBalanceInfo?.totalBalance?.toLocaleString()} (
{Math.abs(
orgBalaceInfo?.reservedBalance
orgBalanceInfo?.reservedBalance || 0
).toLocaleString()}
)
</BCTypography>
Expand Down

0 comments on commit fde3414

Please sign in to comment.