Skip to content

Commit

Permalink
Merge branch 'main' into NDT-524-Update-GCPE-report-to-include-Econom…
Browse files Browse the repository at this point in the history
…ic-Regions-data
  • Loading branch information
rafasdc authored Oct 16, 2024
2 parents c3dbc12 + 1a04352 commit f9de4f4
Show file tree
Hide file tree
Showing 14 changed files with 520 additions and 256 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # tag=v4.4.0
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # tag=v4.4.3
with:
name: SARIF file
path: results.sarif
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-containers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Self-hosted Renovate
uses: renovatebot/[email protected].1
uses: renovatebot/[email protected].3
with:
configurationFile: ./.github/renovate.json
token: ${{ secrets.RENOVATE_GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.197.2](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.197.1...v1.197.2) (2024-10-10)

## [1.197.1](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.197.0...v1.197.1) (2024-10-10)

# [1.197.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.195.4...v1.197.0) (2024-10-04)

### Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [SchemaSpy Database documentation](https://bcgov.github.io/CONN-CCBC-portal/schemaspy/)
- [Growthbook](#growthbook)
- [Metabase](#metabase)
- [Intake Updates Guide](docs/Necessary_changes_For_Intake_Update.md)

#### Local development

Expand Down
14 changes: 11 additions & 3 deletions app/components/Review/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Link from 'next/link';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faMinus, faPen, faPlus } from '@fortawesome/free-solid-svg-icons';
import CbcRecordLock from 'components/Analyst/CBC/CbcRecordLock';
import { Tooltip } from '@mui/material';
import AlertIcon from './AlertIcon';

export function getToggledState(
Expand Down Expand Up @@ -64,13 +65,18 @@ const StyledLink = styled(Link)`
text-decoration: none;
`;

const StyledTooltip = styled(Tooltip)`
cursor: pointer;
`;

const Accordion = ({
allowAnalystEdit,
children,
defaultToggled,
isCBC,
cbcId,
error,
sectionErrors,
name,
onToggle,
toggled,
Expand Down Expand Up @@ -131,9 +137,11 @@ const Accordion = ({
))}

{error && (
<StyledAlert>
<AlertIcon />
</StyledAlert>
<StyledTooltip title={sectionErrors?.join('\n')} placement="top">
<StyledAlert data-testid="styled-alert">
<AlertIcon />
</StyledAlert>
</StyledTooltip>
)}
<button type="button" onClick={handleToggle}>
{isToggled ? (
Expand Down
2 changes: 2 additions & 0 deletions app/components/Review/ReviewSectionField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const ReviewSectionField: React.FC<FieldProps> = (props) => {
const pageName = idSchema.$id?.split('_')?.[1];
const formErrorSchema = formContext?.formErrorSchema ?? formContext.errors;
const hasFormContextError = formErrorSchema?.[pageName];
const sectionErrors = hasFormContextError?.__errors;
const hasErrors = useMemo(
() => Object.keys(errorSchema || {}).length > 0 || !!hasFormContextError,
[errorSchema, hasFormContextError]
Expand All @@ -33,6 +34,7 @@ const ReviewSectionField: React.FC<FieldProps> = (props) => {
cbcId={formContext.cbcId}
isCBC={formContext.isCBC}
error={hasErrors}
sectionErrors={sectionErrors}
title={schema.title}
allowAnalystEdit={allowAnalystEdit}
recordLocked={formContext.recordLocked}
Expand Down
179 changes: 103 additions & 76 deletions app/lib/helpers/ccbcSummaryGenerateFormData.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import review from 'formSchema/analyst/summary/review';

const getEconomicRegions = (economicRegions) => {
if (!economicRegions) {
return null;
Expand Down Expand Up @@ -150,93 +152,118 @@ const getCommunities = (communities) => {
};
};

const getSowErrors = (sowData, schema, formDataSource) => {
if (sowData?.length) return null;
const errors = {};
Object.entries(schema?.properties || {}).forEach(([parentKey, value]) => {
const sectionSchema = value['properties'];
Object.keys(sectionSchema || {}).forEach((key) => {
if (formDataSource[key] === 'SOW') {
errors[parentKey] = errors[parentKey] || {
__errors: [
'Highlighted cells are null because SOW Excel table has not been uploaded in the portal',
],
};
errors[parentKey][key] = {
__errors: ['SOW excel table has not been uploaded in the portal'],
};
}
});
});

return errors;
};

const getSowData = (sowData, baseSowData) => {
const communitiesData = getCommunities(
sowData?.nodes[0]?.sowTab8SBySowId?.nodes[0]?.jsonData?.geoNames
);
const errors = {}; // errors may get added later
const communities =
sowData?.nodes[0]?.sowTab8SBySowId?.nodes[0]?.jsonData?.communitiesNumber;
const indigenousCommunities =
sowData?.nodes[0]?.sowTab8SBySowId?.nodes[0]?.jsonData
?.indigenousCommunitiesNumber;
return {
formData: {
counts: {
communities,
indigenousCommunities,
nonIndigenousCommunities:
communities && indigenousCommunities
? communities - indigenousCommunities
: communities,
totalHouseholdsImpacted:
sowData?.nodes[0]?.sowTab1SBySowId?.nodes[0]?.jsonData
?.numberOfHouseholds,
numberOfIndigenousHouseholds:
sowData?.nodes[0]?.sowTab1SBySowId?.nodes[0]?.jsonData
?.householdsImpactedIndigenous,
},
locations: {
benefitingCommunities: communitiesData?.benefitingCommunities,
benefitingIndigenousCommunities:
communitiesData?.benefitingIndigenousCommunities,
},
funding: {
bcFundingRequested:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.amountRequestedFromProvince,
federalFunding:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.amountRequestedFromFederalGovernment,
fundingRequestedCcbc:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.totalFundingRequestedCCBC,
applicantAmount:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.totalApplicantContribution,
cibFunding:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.totalInfrastructureBankFunding,
fhnaFunding:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.totalFNHAFunding,
otherFunding:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.fundingFromAllOtherSources,
totalProjectBudget:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.totalProjectCost,
},
eventsAndDates: {
effectiveStartDate: sowData?.nodes[0]?.jsonData?.effectiveStartDate,
proposedStartDate: sowData?.nodes[0]?.jsonData?.projectStartDate,
proposedCompletionDate:
sowData?.nodes[0]?.jsonData?.projectCompletionDate,
dateAgreementSigned:
baseSowData?.nodes[0]?.jsonData?.dateFundingAgreementSigned,
},
const formData = {
counts: {
communities,
indigenousCommunities,
nonIndigenousCommunities:
communities && indigenousCommunities
? communities - indigenousCommunities
: communities,
totalHouseholdsImpacted:
sowData?.nodes[0]?.sowTab1SBySowId?.nodes[0]?.jsonData
?.numberOfHouseholds,
numberOfIndigenousHouseholds:
sowData?.nodes[0]?.sowTab1SBySowId?.nodes[0]?.jsonData
?.householdsImpactedIndigenous,
},
formDataSource: {
communities: 'SOW',
benefitingCommunities: 'SOW',
indigenousCommunities: 'SOW',
nonIndigenousCommunities: 'SOW',
benefitingIndigenousCommunities: 'SOW',
totalHouseholdsImpacted: 'SOW',
numberOfIndigenousHouseholds: 'SOW',
bcFundingRequested: 'SOW',
federalFunding: 'SOW',
fundingRequestedCcbc: 'SOW',
applicantAmount: 'SOW',
cibFunding: 'SOW',
fhnaFunding: 'SOW',
otherFunding: 'SOW',
totalProjectBudget: 'SOW',
effectiveStartDate: 'SOW',
proposedStartDate: 'SOW',
proposedCompletionDate: 'SOW',
dateAgreementSigned: 'SOW',
locations: {
benefitingCommunities: communitiesData?.benefitingCommunities,
benefitingIndigenousCommunities:
communitiesData?.benefitingIndigenousCommunities,
},
funding: {
bcFundingRequested:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.amountRequestedFromProvince,
federalFunding:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.amountRequestedFromFederalGovernment,
fundingRequestedCcbc:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.totalFundingRequestedCCBC,
applicantAmount:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.totalApplicantContribution,
cibFunding:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.totalInfrastructureBankFunding,
fhnaFunding:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.totalFNHAFunding,
otherFunding:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.fundingFromAllOtherSources,
totalProjectBudget:
sowData?.nodes[0]?.sowTab7SBySowId?.nodes[0]?.jsonData?.summaryTable
?.totalProjectCost,
},
eventsAndDates: {
effectiveStartDate: sowData?.nodes[0]?.jsonData?.effectiveStartDate,
proposedStartDate: sowData?.nodes[0]?.jsonData?.projectStartDate,
proposedCompletionDate:
sowData?.nodes[0]?.jsonData?.projectCompletionDate,
dateAgreementSigned:
baseSowData?.nodes[0]?.jsonData?.dateFundingAgreementSigned,
},
};
const formDataSource = {
communities: 'SOW',
benefitingCommunities: 'SOW',
indigenousCommunities: 'SOW',
nonIndigenousCommunities: 'SOW',
benefitingIndigenousCommunities: 'SOW',
totalHouseholdsImpacted: 'SOW',
numberOfIndigenousHouseholds: 'SOW',
bcFundingRequested: 'SOW',
federalFunding: 'SOW',
fundingRequestedCcbc: 'SOW',
applicantAmount: 'SOW',
cibFunding: 'SOW',
fhnaFunding: 'SOW',
otherFunding: 'SOW',
totalProjectBudget: 'SOW',
effectiveStartDate: 'SOW',
proposedStartDate: 'SOW',
proposedCompletionDate: 'SOW',
dateAgreementSigned: 'SOW',
};
const errors = getSowErrors(sowData?.nodes, review, formDataSource);

return {
formData,
formDataSource,
errors,
};
};
Expand Down
16 changes: 8 additions & 8 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@mui/x-date-pickers": "^6.16.2",
"@rjsf/core": "^5.17.1",
"@rjsf/utils": "^5.17.1",
"@rjsf/validator-ajv8": "5.17.1",
"@rjsf/validator-ajv8": "5.18.0",
"@sentry/nextjs": "^7.36.0",
"@smithy/node-http-handler": "^3.2.4",
"@snowplow/browser-tracker": "^3.23.0",
Expand Down Expand Up @@ -89,8 +89,8 @@
"luxon": "^3.4.3",
"material-react-table": "2.13",
"morgan": "^1.10.0",
"next": "^14.2.10",
"openid-client": "^5.6.5",
"next": "^14.2.15",
"openid-client": "^5.7.0",
"passport": "^0.7.0",
"patch-package": "^8.0.0",
"path-to-regexp": "^6.3.0",
Expand All @@ -108,7 +108,7 @@
"relay-runtime": "^13.2.0",
"styled-components": "^5.3.5",
"typography": "^0.16.21",
"url": "^0.11.3",
"url": "^0.11.4",
"validator": "^13.12.0",
"vscode-json-languageservice": "^5.4.1",
"write-excel-file": "^2.0.2",
Expand All @@ -121,7 +121,7 @@
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^14.1.2",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.4.3",
"@testing-library/user-event": "^14.5.2",
"@types/archiver": "^5.3.1",
"@types/connect-pg-simple": "^7.0.0",
"@types/convict": "^6.1.6",
Expand Down Expand Up @@ -149,8 +149,8 @@
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-next": "^13.4.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-cypress": "^3.5.0",
"eslint-plugin-jest": "^28.5.0",
"eslint-plugin-cypress": "^3.6.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-relay": "^1.8.3",
"fetch-mock": "9.11.0",
Expand All @@ -162,7 +162,7 @@
"jest-environment-jsdom": "^28.1.0",
"jest-extended": "^4.0.2",
"jest-mock": "^29.7.0",
"nodemon": "^2.0.20",
"nodemon": "^3.1.7",
"prettier": "^3.2.5",
"react-dom": "^18.3.1",
"relay-compiler": "^13.2.0",
Expand Down
1 change: 0 additions & 1 deletion app/pages/analyst/application/[applicationId]/summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ const Summary = ({
isEditable: false,
errors,
formDataSource,
showErrorHint: true,
}}
formData={formData}
handleChange={() => {}}
Expand Down
Loading

0 comments on commit f9de4f4

Please sign in to comment.