Skip to content

Commit

Permalink
chore: various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rafasdc committed Jan 15, 2025
1 parent fb0684b commit 70e5cd9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
35 changes: 28 additions & 7 deletions app/backend/lib/dashboard/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
formatCurrency,
handleCbcCommunities,
handleCcbcCommunities,
handleLastMileSpeed,
} from './util';
import columnOptions from './column_options';

Expand Down Expand Up @@ -201,6 +202,16 @@ const getCbcDataQuery = `
}
}
}
cbcApplicationPendingChangeRequestsByCbcId(
last: 1
filter: { archivedAt: { isNull: true } }
) {
edges {
node {
isPending
}
}
}
}
}
`;
Expand Down Expand Up @@ -278,7 +289,9 @@ export const generateDashboardExport = async (applicationData, cbcData) => {
data?.applicationByRowId
?.applicationPendingChangeRequestsByApplicationId?.nodes?.[0]
?.isPending
),
)
? 'YES'
: 'NO',
},
// project title
{ value: data?.applicationByRowId?.projectName },
Expand All @@ -289,8 +302,8 @@ export const generateDashboardExport = async (applicationData, cbcData) => {
// 830 million funding
{
value: data?.applicationByRowId?.ccbcNumber.includes('CCBC')
? 'Yes'
: 'No',
? 'YES'
: 'NO',
},
// federal funding source
{ value: 'ISED-UBF Core' },
Expand All @@ -310,7 +323,7 @@ export const generateDashboardExport = async (applicationData, cbcData) => {
// last mile technology
{ value: null },
// last mile minimum speed
{ value: null },
{ value: handleLastMileSpeed(data?.applicationByRowId?.status) },
// connected coast network dependent
{
value: `${summaryData?.formData?.dependency?.connectedCoastNetworkDependent || ''} (${summaryData?.formDataSource?.connectedCoastNetworkDependent && summaryData?.formData?.dependency?.connectedCoastNetworkDependent ? `(${summaryData?.formDataSource?.connectedCoastNetworkDependent})` : ''})`,
Expand Down Expand Up @@ -428,7 +441,10 @@ export const generateDashboardExport = async (applicationData, cbcData) => {
},
// phase
{
value: cbcDataByCbcId?.phase,
value: cbcDataByCbcId?.phase
? parseInt(cbcDataByCbcId?.phase, 10)
: null,
type: Number,
},
// zone
{ value: null },
Expand All @@ -445,7 +461,12 @@ export const generateDashboardExport = async (applicationData, cbcData) => {
value: convertStatus(cbcDataByCbcId?.projectStatus),
},
// change request pending
{ value: null },
{
value: data?.cbcByRowId?.cbcApplicationPendingChangeRequestsByCbcId
?.edges?.[0]?.node?.isPending
? 'YES'
: 'NO',
},
// project title
{
value: cbcDataByCbcId?.projectTitle,
Expand Down Expand Up @@ -484,7 +505,7 @@ export const generateDashboardExport = async (applicationData, cbcData) => {
},
// last mile technology
{
value: cbcDataByCbcId?.lastMileTechnology,
value: cbcDataByCbcId?.lastMileProjectType,
},
// last mile minimum speed
{
Expand Down
16 changes: 15 additions & 1 deletion app/backend/lib/dashboard/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const convertStatus = (status: string): string => {
case 'conditionally_approved':
return 'Conditionally Approved';
case 'approved':
return 'Approved';
return 'Agreement Signed';
case 'on_hold':
return 'On Hold';
case 'closed':
Expand All @@ -87,3 +87,17 @@ export const formatCurrency = (value: number | null | undefined): string => {

return formatMoney(numberValue);
};

export const handleLastMileSpeed = (status): number => {
if (
status === 'conditionally_approved' ||
status === 'approved' ||
status === 'applicant_approved' ||
status === 'applicant_conditionally_approved' ||
status === 'applicant_complete' ||
status === 'complete'
) {
return 50;
}
return null;
};

0 comments on commit 70e5cd9

Please sign in to comment.