Skip to content

Commit

Permalink
Merge branch 'main' into NDT-375-Investigate-Regional-Districts-and-E…
Browse files Browse the repository at this point in the history
…conomic-Regions-for-CCBC
  • Loading branch information
rafasdc committed Sep 3, 2024
2 parents b07f252 + f546533 commit 07b81dd
Show file tree
Hide file tree
Showing 46 changed files with 1,858 additions and 200 deletions.
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/github-action@v40.2.6
uses: renovatebot/github-action@v40.2.7
with:
configurationFile: ./.github/renovate.json
token: ${{ secrets.RENOVATE_GITHUB_TOKEN }}
62 changes: 62 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
# [1.189.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.188.0...v1.189.0) (2024-08-30)

### Features

- change to announced by bc/ised in gcpe report ([cbb5871](https://github.com/bcgov/CONN-CCBC-portal/commit/cbb58714e29ab57a08ac4ceeac4d016a03155294))

# [1.188.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.187.0...v1.188.0) (2024-08-30)

### Features

- colour is now a background colour ([46584e5](https://github.com/bcgov/CONN-CCBC-portal/commit/46584e5e4d9beacbbf21bf9313cb6bd88092b526))

# [1.187.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.186.4...v1.187.0) (2024-08-29)

### Features

- add toast for second review emails ([88b51d4](https://github.com/bcgov/CONN-CCBC-portal/commit/88b51d486927507285ac311a3e4755a77fd10b59))

## [1.186.4](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.186.3...v1.186.4) (2024-08-29)

## [1.186.3](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.186.2...v1.186.3) (2024-08-28)

### Bug Fixes

- sa permission for communities source data ([cc1d2e3](https://github.com/bcgov/CONN-CCBC-portal/commit/cc1d2e3e17e82d7807d078d1895cbfdb36958f7c))

## [1.186.2](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.186.1...v1.186.2) (2024-08-28)

### Bug Fixes

- cbc household count validation ([9c203db](https://github.com/bcgov/CONN-CCBC-portal/commit/9c203db6d2a4e6f2a40d3d785137f2c62a0abc98))

## [1.186.1](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.186.0...v1.186.1) (2024-08-27)

### Bug Fixes

- analyst status to show in report correctly ([657bf9f](https://github.com/bcgov/CONN-CCBC-portal/commit/657bf9fc1818644ec2c8d409d8283bfa86b8aa2a))
- filtering for ccbc gcpe report ([dcd2b52](https://github.com/bcgov/CONN-CCBC-portal/commit/dcd2b52ea8f43a82a259cdbfa76cd7e87d05e03e))

# [1.186.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.185.0...v1.186.0) (2024-08-27)

### Bug Fixes

- 500 error when visiting non-locations page ([b3a101c](https://github.com/bcgov/CONN-CCBC-portal/commit/b3a101c68f6ee5351f335e872b8583a8391dbce8))
- add permissions for executing function ([6defd8f](https://github.com/bcgov/CONN-CCBC-portal/commit/6defd8f09689bdf6f9cfc320294c2953ca70e182))
- cleanup of [section] to remove dataBySection ([35a85ee](https://github.com/bcgov/CONN-CCBC-portal/commit/35a85ee778573f92f526c8bff124c79abd40b43c))
- clear button and inputs show correct values at all times ([abd9f20](https://github.com/bcgov/CONN-CCBC-portal/commit/abd9f20a15b2d15564a114f13f18ac4faa8b8542))
- empty communities are not saved ([9c0c906](https://github.com/bcgov/CONN-CCBC-portal/commit/9c0c906e4b17c9e6e5105903bcfee4a74a7c0dc1))
- geographic name options are by economic region and regional district ([a1c6927](https://github.com/bcgov/CONN-CCBC-portal/commit/a1c6927b67f89e81683716e0de8a39a4b0fd080d))
- geographic name options are populated with only economic region ([40b9438](https://github.com/bcgov/CONN-CCBC-portal/commit/40b9438ef9793d5b83c178d9901e0eb587c8771d))
- update on save instead of after refresh ([56b42f2](https://github.com/bcgov/CONN-CCBC-portal/commit/56b42f246d06b423ad279333199115fcccec035a))
- user correct rowId ([378dcfc](https://github.com/bcgov/CONN-CCBC-portal/commit/378dcfcebef4b01a48e8da34ae92b03f3c2d3269))

### Features

- add and remove community source behaves as expected ([ce70b29](https://github.com/bcgov/CONN-CCBC-portal/commit/ce70b29e6f100032f9c92b6f8d7023d18d0e10a3))
- added community sources are read only ([39e3834](https://github.com/bcgov/CONN-CCBC-portal/commit/39e3834d2b75707dd0cdf0ebcc1379b3ede77869))
- community source data is now displayed properly ([b8e811e](https://github.com/bcgov/CONN-CCBC-portal/commit/b8e811e456700752e0d18c9ca18ea835915c790c))
- disable previously selected options ([7c810e3](https://github.com/bcgov/CONN-CCBC-portal/commit/7c810e3ace1a19e3da2217f28b9dd2a5dd3c0236))
- section community source data behaves similar to quick edit ([b9d8e7c](https://github.com/bcgov/CONN-CCBC-portal/commit/b9d8e7c96d348515f99a3b3b8644a3dad618fa6b))
- style buttons for add, remove, and clear ([35698ff](https://github.com/bcgov/CONN-CCBC-portal/commit/35698ff6ee1164d2a9e90828ce3d1a79193ecf24))

# [1.185.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.184.2...v1.185.0) (2024-08-26)

### Features
Expand Down
5 changes: 3 additions & 2 deletions app/backend/lib/reporting/gcpe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const getCbcDataQuery = `
const getCcbcQuery = `
query getCcbc {
allApplications(
filter: {status: {in: ["conditionally_approved", "approved", "on_hold", "closed", "recommendation", "complete"]}}
filter: {analystStatus: {in: ["conditionally_approved", "approved", "on_hold", "closed", "recommendation", "complete"]}}
) {
edges {
node {
Expand Down Expand Up @@ -119,6 +119,7 @@ const getCcbcQuery = `
package
projectName
status
analystStatus
intakeNumber
organizationName
}
Expand Down Expand Up @@ -337,7 +338,7 @@ const generateExcelData = async (
// federal funding source
{ value: 'ISED-UBF Core' },
// status
{ value: convertStatus(node?.status) },
{ value: convertStatus(node?.analystStatus) },
// project milestone complete percent
{
value:
Expand Down
2 changes: 1 addition & 1 deletion app/backend/lib/reporting/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const HEADER_ROW: Row = [
wrap: true,
},
{
value: 'Announced by Province',
value: 'Announced by BC/ISED',
fontWeight: 'bold',
type: String,
height: 95,
Expand Down
2 changes: 1 addition & 1 deletion app/backend/lib/reporting/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const compareAndMarkArrays = (array1: any, array2: any) => {
if (item?.value !== item2?.value) {
return {
...item,
color: '#2FA7DD',
backgroundColor: '#2FA7DD',
};
}

Expand Down
84 changes: 59 additions & 25 deletions app/components/Analyst/Assessments/AssessmentsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useCreateAssessmentMutation } from 'schema/mutations/assessment/createA
import assessmentsUiSchema from 'formSchema/uiSchema/analyst/assessmentsUiSchema';
import { RJSFSchema } from '@rjsf/utils';
import * as Sentry from '@sentry/nextjs';
import { useToast } from 'components/AppProvider';

interface Props {
addedContext?: any;
Expand All @@ -34,6 +35,12 @@ const StyledFormBase = styled(FormBase)`
}
`;

const StyledNotifyButton = styled(Button)`
svg {
height: 18px;
}
`;

const AssessmentsForm: React.FC<Props> = ({
addedContext,
formData,
Expand All @@ -52,9 +59,14 @@ const AssessmentsForm: React.FC<Props> = ({
query.applicationByRowId
);

const { showToast, hideToast } = useToast();

const [createAssessment, isCreating] = useCreateAssessmentMutation();
const [newFormData, setNewFormData] = useState(formData);
const [isFormSaved, setIsFormSaved] = useState(true);
const [emailStatus, setEmailStatus] = useState<
'idle' | 'inProgress' | 'sent'
>('idle');

const handleSubmit = async (e: IChangeEvent<any>) => {
if (!isFormSaved) {
Expand All @@ -69,31 +81,6 @@ const AssessmentsForm: React.FC<Props> = ({
},
onCompleted: () => {
setIsFormSaved(true);
if (
e.formData?.nextStep === 'Needs 2nd review' &&
e.formData?.nextStep !== formData?.nextStep
) {
fetch('/api/email/notifySecondReviewRequest', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
applicationId: queryFragment.rowId,
host: window.location.origin,
ccbcNumber: addedContext?.ccbcNumber,
assessmentType: slug,
}),
}).then((response) => {
if (!response.ok) {
Sentry.captureException({
name: 'Email sending failed',
message: response,
});
}
return response.json();
});
}
},
optimisticResponse: {
jsonData: e.formData,
Expand All @@ -110,6 +97,42 @@ const AssessmentsForm: React.FC<Props> = ({
}
};

const notifyByEmail = async () => {
hideToast();
if (newFormData?.nextStep === 'Needs 2nd review') {
setEmailStatus('inProgress');
fetch('/api/email/notifySecondReviewRequest', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
applicationId: queryFragment.rowId,
host: window.location.origin,
ccbcNumber: addedContext?.ccbcNumber,
assessmentType: slug,
}),
}).then((response) => {
if (!response.ok) {
showToast(
'Email notification did not work, please try again',
'error',
5000
);
Sentry.captureException({
name: 'Email sending failed',
message: response,
});
setEmailStatus('idle');
} else {
showToast('Email notification sent successfully', 'success', 5000);
setEmailStatus('sent');
}
return response.json();
});
}
};

return (
<StyledFormBase
schema={schema}
Expand All @@ -130,6 +153,17 @@ const AssessmentsForm: React.FC<Props> = ({
<Button variant="primary" disabled={isCreating}>
{!isFormSaved ? 'Save' : 'Saved'}
</Button>
&nbsp;
<StyledNotifyButton
variant="primary"
disabled={
newFormData?.nextStep !== 'Needs 2nd review' || emailStatus !== 'idle'
}
title="Email notification of 2nd review needed will be sent to Mike and Karina"
onClick={notifyByEmail}
>
{emailStatus === 'inProgress' && <LoadingSpinner />} Notify by email
</StyledNotifyButton>
{isCreating && <LoadingSpinner />}
</StyledFormBase>
);
Expand Down
6 changes: 4 additions & 2 deletions app/components/Analyst/CBC/CbcTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import {
TextWidget,
DatePickerWidget,
} from 'lib/theme/widgets';
import ArrayLocationFieldTemplate from 'lib/theme/fields/ArrayLocationDataField';
import CommunitySourceWidget from 'lib/theme/widgets/custom/CommunitySourceWidget';
import ArrayBooleanField from '../../Review/fields/ArrayBooleanField';
import ReviewCheckboxField from '../../Review/fields/ReviewCheckboxField';
import ReviewInlineArrayField from '../../Review/fields/ReviewInlineArrayField';
import ReviewObjectFieldTemplate from '../../Review/ReviewObjectFieldTemplate';
import ReviewSectionField from '../../Review/ReviewSectionField';
import ReviewArrayFieldTemplate from '../../Review/fields/ReviewArrayFieldTemplate';
import ReviewFieldTemplate from '../../Review/fields/ReviewFieldTemplate';
import DefaultWidget from '../../Review/widgets/DefaultWidget';
import BooleanWidget from '../../Review/widgets/BooleanWidget';
Expand Down Expand Up @@ -47,12 +48,13 @@ const CbcTheme: ThemeProps = {
NumberWidget,
NumericStringWidget,
ReadOnlyWidget: DefaultWidget,
CommunitySourceWidget,
},
templates: {
...templates,
ObjectFieldTemplate: ReviewObjectFieldTemplate,
FieldTemplate: ReviewFieldTemplate,
ArrayFieldTemplate: ReviewArrayFieldTemplate,
ArrayFieldTemplate: ArrayLocationFieldTemplate,
},
};

Expand Down
2 changes: 2 additions & 0 deletions app/components/Analyst/Project/ProjectTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ArrayFieldTemplate from 'lib/theme/fields/ArrayFieldTemplate';
import * as widgets from 'lib/theme/widgets';
import ReadOnlyWidget from 'components/Analyst/Project/ConditionalApproval/widgets/ReadOnlyWidget';
import ExcelImportFileWidget from 'components/Analyst/Project/ProjectInformation/widgets/ExcelImportFileWidget';
import CommunitySourceWidget from 'lib/theme/widgets/custom/CommunitySourceWidget';
import { StatusSelectWidget } from './ConditionalApproval/widgets';
import ProjectFieldTemplate from './fields/ProjectFieldTemplate';
import ProjectObjectFieldTemplate from './fields/ProjectObjectFieldTemplate';
Expand Down Expand Up @@ -30,6 +31,7 @@ const ProjectTheme: ThemeProps = {
CcbcIdWidget,
HiddenWidget,
ContextErrorWidget,
CommunitySourceWidget,
},
templates: {
...templates,
Expand Down
10 changes: 9 additions & 1 deletion app/components/Review/fields/ReviewFieldTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ const ReviewFieldTemplate: React.FC<FieldTemplateProps> = ({
const title =
(uiSchema?.['ui:options']?.customTitle as JSX.Element) ?? schema.title;

const isExcludeTableFormat = uiSchema?.['ui:options']?.excludeTableFormat;

if (isExcludeTableFormat) {
return <>{children}</>;
}

const before = uiSchema?.['ui:before'];
const after = uiSchema?.['ui:after'];
const fieldName = id?.split('_')?.[2];
Expand Down Expand Up @@ -75,7 +81,9 @@ const ReviewFieldTemplate: React.FC<FieldTemplateProps> = ({
)}
</StyledColError>
) : (
<StyledColRight id={`${id}-value`}>{children}</StyledColRight>
<StyledColRight data-testid={`${id}-value`}>
{children}
</StyledColRight>
)}
</tr>
{after}
Expand Down
3 changes: 2 additions & 1 deletion app/cypress/e2e/analyst/cbc/[cbcId].cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ describe('The cbc project view', () => {
cy.contains('h1', 'Project 1');
cy.contains('h2', 'Tombstone');
cy.contains('h2', 'Project type');
cy.contains('h2', 'Locations and counts');
cy.contains('h2', 'Locations');
cy.contains('h2', 'Counts');
cy.contains('h2', 'Funding');
cy.contains('h2', 'Events and dates');
cy.contains('h2', 'Miscellaneous');
Expand Down
36 changes: 36 additions & 0 deletions app/formSchema/analyst/cbc/locations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { RJSFSchema } from '@rjsf/utils';

const locations: RJSFSchema = {
title: 'Locations',
description: '',
type: 'object',
required: [],
properties: {
projectLocations: {
type: 'string',
title: 'Project Locations',
},
geographicNames: {
type: 'string',
title: 'Geographic Names',
},
regionalDistricts: {
type: 'string',
title: 'Regional Districts',
},
economicRegions: {
type: 'string',
title: 'Economic Regions',
},
communitySourceData: {
type: 'array',
default: [],
items: {
type: 'integer',
enum: [],
},
},
},
};

export default locations;
20 changes: 2 additions & 18 deletions app/formSchema/analyst/cbc/locationsAndCounts.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
import { RJSFSchema } from '@rjsf/utils';

const locationsAndCounts: RJSFSchema = {
title: 'Locations and counts',
title: 'Counts',
description: '',
type: 'object',
required: [
'projectLocations',
'communitiesAndLocalesCount',
'householdCount',
'indigenousCommunities',
],
properties: {
projectLocations: {
type: 'string',
title: 'Project Locations',
},
geographicNames: {
type: 'string',
title: 'Geographic Names',
},
regionalDistricts: {
type: 'string',
title: 'Regional Districts',
},
economicRegions: {
type: 'string',
title: 'Economic Regions',
},
communitiesAndLocalesCount: {
type: 'number',
title: 'Communities and locales count',
Expand Down
Loading

0 comments on commit 07b81dd

Please sign in to comment.