Skip to content

Commit

Permalink
Merge pull request #126 from bcgov/BCAT-545-538
Browse files Browse the repository at this point in the history
BCAT-545, 538 | Switch funding year dropdown to input for future easier maintain
  • Loading branch information
jerry-ey authored May 16, 2024
2 parents 7911568 + 468e8e6 commit 69be7c2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 29 deletions.
8 changes: 6 additions & 2 deletions api/src/application/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export class ApplicationService {
}

if (query.fundingYear) {
queryBuilder.andWhere('app.fundingYear = :fundingYear', { fundingYear: query.fundingYear });
queryBuilder.andWhere('app.fundingYear ILIKE :fundingYear', {
fundingYear: `%${query.fundingYear}%`,
});
}

if (query.status) {
Expand Down Expand Up @@ -276,9 +278,10 @@ export class ApplicationService {

async getApplicationsRawData(): Promise<Application[]> {
// done this way to remove the submission object from response
return this.applicationRepository
return this.applicationViewRepository
.createQueryBuilder('a')
.select([
'a.fundingYear',
'a.applicantName',
'a.asks',
'a.confirmationId',
Expand All @@ -298,6 +301,7 @@ export class ApplicationService {
.where('status.name NOT ILIKE :rejectedStatus', {
rejectedStatus: `%${ApplicationStatus.DENIED}%`,
})
.orderBy('a.fundingYear', 'DESC', 'NULLS LAST')
.getMany();
}
}
22 changes: 3 additions & 19 deletions api/src/score/ro/raw-data.ro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ export class RawDataRo {
return item.workshopScores && item.workshopScores.length > 0;
};

const getFundingYear = (signedDate: any) => {
if (!signedDate) return NO_VALUE;
return `${dayjs(signedDate).format('YY')}/${dayjs(signedDate).add(1, 'year').format('YY')}`;
};

const checkGovernmentApplicant = (primaryApplicant: string, secondaryApplicant: string) => {
const YES = 'Y';
const NO = 'N';
Expand Down Expand Up @@ -154,7 +149,7 @@ export class RawDataRo {
eligibility: checkIfItemHasWorkshopScore(item)
? item.workshopScores[0].data?.eligibilityScore
: NO_VALUE,
fundingYear: getFundingYear(submission?.s10Container?.s10ProjectMangerApproverDate),
fundingYear: submission?.s1Container?.s1FundingYear,
applicantName: item.applicantName,
indigenousGovernment: checkGovernmentApplicant(
submission.s1Container?.s1GovernmentType,
Expand Down Expand Up @@ -200,11 +195,6 @@ export class RawDataRo {
return dayjs(itemDate).isValid() ? dayjs(itemDate).format('YYYY-MM-DD') : NO_VALUE;
};

const getFundingYear = (signedDate: any) => {
if (!signedDate) return NO_VALUE;
return `${dayjs(signedDate).format('YY')}/${dayjs(signedDate).add(1, 'year').format('YY')}`;
};

for (const item of data) {
if (item.applicationType?.name === ApplicationType.NETWORK_FORM) continue;

Expand All @@ -218,10 +208,7 @@ export class RawDataRo {
submission.s4Container?.s4ProjectTitle ||
submission.s3Container?.s3ProjectTitle ||
NO_VALUE,
fundingYear: getFundingYear(
submission.s10Container?.s10ProjectMangerApproverDate ||
submission.s11Container?.s11ProjectMangerApproverDate
),
fundingYear: submission.s1Container?.s1FundingYear,
usageCountDate: NO_VALUE,
usageCountTime: NO_VALUE,
usageCountLocation: NO_VALUE,
Expand All @@ -241,10 +228,7 @@ export class RawDataRo {
submission.s4Container?.s4ProjectTitle ||
submission.s3Container?.s3ProjectTitle ||
NO_VALUE,
fundingYear: getFundingYear(
submission.s10Container?.s10ProjectMangerApproverDate ||
submission.s11Container?.s11ProjectMangerApproverDate
),
fundingYear: row.fundingYear,
usageCountDate: formatDate(row.dateCell),
usageCountTime: row.countPeriodCell || NO_VALUE,
usageCountLocation: row.stationLocationCell || NO_VALUE,
Expand Down
1 change: 1 addition & 0 deletions client/components/application/BroaderReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const BroaderReview: React.FC<BroaderReviewProps> = ({
label={item.label}
name={item.name}
tooltiptext={item.tooltiptext}
maxScore={item.maxScore}
/>
<Error name={item.name} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const ApplicationDashboard: React.FC<any> = () => {
searchAssignedTo.length === 0 &&
searchConfirmationID.length == 0 &&
searchTotalCost.length === 0 &&
searchFundingYear == null &&
searchFundingYear.length === 0 &&
searchStatus == null;

return noValues;
Expand Down Expand Up @@ -225,15 +225,10 @@ export const ApplicationDashboard: React.FC<any> = () => {
<div className='w-full border py-4 px-8 mb-2'>
Filter By:
<div className='grid grid-cols-4 gap-1'>
<SelectFilter
<InputFilter
placeholder='Funding Year'
searchType={searchFundingYear}
onChange={(e: any) => setState(p => ({ ...p, searchFundingYear: e.target.value }))}
options={[
{ name: '2024/25', value: '2024/25' },
{ name: '2025/26', value: '2025/26' },
{ name: '2026/27', value: '2026/27' },
]}
/>
<SelectFilter
placeholder='Status'
Expand Down
8 changes: 8 additions & 0 deletions client/components/broader-review/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type InputProps = {
name: string;
secondaryList?: string[];
tooltiptext?: string;
maxScore?: number;
};

export const Input: React.FC<InputProps> = ({
Expand All @@ -27,6 +28,7 @@ export const Input: React.FC<InputProps> = ({
name,
secondaryList,
tooltiptext,
maxScore,
}) => {
return (
<div className='md:flex md:items-center'>
Expand All @@ -44,6 +46,12 @@ export const Input: React.FC<InputProps> = ({
</div>
)}

{maxScore && !disabled && (
<div className='flex items-center gap-1 py-2'>
<span>Max score:</span> <strong>{maxScore}</strong>
</div>
)}

{descriptionList && (
<ul className='text-bcBluePrimary list-disc list-inside'>
{descriptionList.map((item: string, index: number) => {
Expand Down
2 changes: 1 addition & 1 deletion client/constants/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const INFRASTRUCTURE_REVIEW_VALIDATION_SCHEMA = Yup.object().shape({

communityNeedsAndSafetyGuidelinesScore: Yup.number()
.min(0, minValidationText + '0')
.max(15, maxValidationText + '15')
.max(10, maxValidationText + '10')
.required('This field is required'),

safetyScore: Yup.number()
Expand Down

0 comments on commit 69be7c2

Please sign in to comment.