Skip to content

Commit

Permalink
Merge branch 'main' into NDT-541-Split-the-CCBC-requested-50-50-for-I…
Browse files Browse the repository at this point in the history
…SED-and-BC-funding-requested-Application
  • Loading branch information
RRanath authored Oct 15, 2024
2 parents 7e88944 + 87c9f6c commit 19a25b2
Show file tree
Hide file tree
Showing 12 changed files with 486 additions and 207 deletions.
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
8 changes: 4 additions & 4 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 Down Expand Up @@ -150,7 +150,7 @@
"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-jest": "^28.8.3",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-relay": "^1.8.3",
"fetch-mock": "9.11.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 19a25b2

Please sign in to comment.