Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
masimons committed Aug 6, 2024
1 parent 06de27e commit 5cb5189
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
34 changes: 24 additions & 10 deletions packages/client/src/components/GrantsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ import GrantDetailsLegacy from '@/components/Modals/GrantDetailsLegacy.vue';
import SearchPanel from '@/components/Modals/SearchPanel.vue';
import SavedSearchPanel from '@/components/Modals/SavedSearchPanel.vue';
import SearchFilter from '@/components/SearchFilter.vue';
import moment from 'moment';
// import moment from 'moment';
const DEFAULT_CURRENT_PAGE = 1;
const DEFAULT_ORDER_BY = 'rank';
Expand Down Expand Up @@ -280,15 +280,29 @@ export default {
txt.innerHTML = t;
return txt.value;
};
const generateCloseDate = (date, status) => {
if (status === 'posted' && !date) {
return "Not yet issued";
} if (['closed', 'archived', 'posted'].includes(status) && !!date && !moment(date).isValid()) {
return 'See details';
const generateCloseDate = (date, status, close_date_explanation) => {

Check failure on line 283 in packages/client/src/components/GrantsTable.vue

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Identifier 'close_date_explanation' is not in camel case
const formattedDate = new Date(date).toLocaleDateString('en-US', { timeZone: 'UTC' });
if (['posted'].includes(status) && !date) {
return 'Not yet issued';
} else if (status === 'forecasted') {

Check failure on line 287 in packages/client/src/components/GrantsTable.vue

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Unnecessary 'else' after 'return'
if (!!date) {

Check failure on line 288 in packages/client/src/components/GrantsTable.vue

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Redundant double negation
return `est. ${formattedDate}`;
} else if (!!close_date_explanation) {

Check failure on line 290 in packages/client/src/components/GrantsTable.vue

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Unnecessary 'else' after 'return'

Check failure on line 290 in packages/client/src/components/GrantsTable.vue

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Redundant double negation

Check failure on line 290 in packages/client/src/components/GrantsTable.vue

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Identifier 'close_date_explanation' is not in camel case
return "See details";

Check failure on line 291 in packages/client/src/components/GrantsTable.vue

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Strings must use singlequote
} else {
return "Not yet issued";

Check failure on line 293 in packages/client/src/components/GrantsTable.vue

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Strings must use singlequote
}
} else {
return new Date(date).toLocaleDateString('en-US', { timeZone: 'UTC' });
return formattedDate;
}
}
};
const generateOpenDate = (date, status) => {
const formattedDate = new Date(date).toLocaleDateString('en-US', { timeZone: 'UTC' });
if (status === 'forecasted') {
return `est. ${formattedDate}`;
}
return formattedDate;
};
return this.grants.map((grant) => ({
...grant,
title: generateTitle(grant.title),
Expand All @@ -300,8 +314,8 @@ export default {
.join(', '),
status: titleize(grant.opportunity_status),
award_ceiling: grant.award_ceiling,
open_date: new Date(grant.open_date).toLocaleDateString('en-US', { timeZone: 'UTC' }),
close_date: generateCloseDate(grant.close_date, grant.opportunity_status?.toLowerCase()),
open_date: generateOpenDate(grant.open_date, grant.opportunity_status?.toLowerCase()),
close_date: generateCloseDate(grant.close_date, grant.opportunity_status?.toLowerCase(), grant.close_date_explanation),
_cellVariants: (() => {
const daysUntilClose = daysUntil(grant.close_date);
if (daysUntilClose <= dangerThreshold) {
Expand Down
11 changes: 3 additions & 8 deletions packages/client/src/views/GrantDetailsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,12 @@ export default {
// If we have an explainer text instead of a real close date, display that instead
if (this.currentGrant.close_date === FAR_FUTURE_CLOSE_DATE) {
return this.currentGrant.close_date_explanation ?? NOT_AVAILABLE_TEXT;
} else if (this.currentGrant.opportunity_status === 'forecasted') {
// if it's a valid date, `est. ${this.formatDate(this.currentGrant.close_date)}`
// if blank, show "Not yet issued"
// else, show text - estimated_synopsis_close_date_explanation
// change this.currentGrant.close_date to relevant field
} else if (this.currentGrant.opportunity_status === 'forecasted') { // what if we check for posted status as well?

Check failure on line 390 in packages/client/src/views/GrantDetailsView.vue

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Unnecessary 'else' after 'return'
if (!this.currentGrant.close_date) {
return 'Not yet issued';
} else if (moment(this.currentGrant.close_date).isValid()) {
return this.currentGrant.close_date_explanation ? this.currentGrant.close_date_explanation : "Not yet issued";
} else {
return `est. ${this.formatDate(this.currentGrant.close_date)}`;
}
return this.currentGrant.estimated_synopsis_close_date_explanation; // This field is subject to change
}
return this.formatDate(this.currentGrant.close_date);
},
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ async function getGrantsNew(filters, paginationParams, orderingParams, tenantId,
'grants.cfda_list',
'grants.open_date',
'grants.close_date',
'grants.close_date_explanation',
'grants.archive_date',
'grants.reviewer_name',
'grants.opportunity_category',
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/lib/grants-ingest.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function mapSourceDataToGrant(source) {
// depending on how we model the estimated open date, we may need to do the
// date comparison with the new field for estimated date
grant.opportunity_status = 'forecasted'

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (91% of all statements in
the enclosing function
have an explicit semicolon).
// when do we actually reference opportunity_status? This may be extraneous code
// This may be extraneous code
// because in the knex query, we are deriving the status based on
// archive_date and close_date
} else {
Expand Down

0 comments on commit 5cb5189

Please sign in to comment.