Skip to content

Commit

Permalink
feat(grants): formatting fixes for dates
Browse files Browse the repository at this point in the history
  • Loading branch information
lsr-explore committed Oct 21, 2024
1 parent 2c33b95 commit 17e2fdf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
4 changes: 4 additions & 0 deletions packages/client/src/components/GrantsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ export default {
};
const generateOpenDate = (date, status) => {
const formattedDate = new Date(date).toLocaleDateString('en-US', { timeZone: 'UTC' });
const dateExists = date && date !== '2100-01-01';
if (!dateExists) {
return 'Not yet issued';
}
if (status === 'forecasted') {
return `est. ${formattedDate}`;
}
Expand Down
29 changes: 21 additions & 8 deletions packages/client/src/views/GrantDetailsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
hover
>
<template #cell()="data">
<span :class="{ 'text-muted font-weight-normal': data.item.displayMuted }">
<i v-if="data.item.displayEstimatedText">est.&nbsp;</i>
<span :class="{'text-muted font-weight-normal': data.item.displayMuted}">
{{ data.value }}
</span>
</template>
Expand Down Expand Up @@ -223,7 +224,8 @@ import GrantActivity from '@/components/GrantActivity.vue';
const HEADER = '__HEADER__';
const FAR_FUTURE_CLOSE_DATE = '2100-01-01';
const NOT_AVAILABLE_TEXT = 'Not Available';
const NOT_YET_ISSUED_TEXT = 'Not yet issued';
const FORECASTED = 'forecasted';
export default {
components: {
Expand Down Expand Up @@ -283,10 +285,12 @@ export default {
}, {
name: 'Open Date',
value: this.openDateDisplay,
displayEstimatedText: this.displayEstimatedOpenDateText,
}, {
name: 'Close Date',
value: this.closeDateDisplay,
displayMuted: this.closeDateDisplayMuted,
displayEstimatedText: this.displayEstimatedCloseDateText,
}, {
name: 'Grant ID',
value: this.currentGrant.grant_id,
Expand Down Expand Up @@ -315,19 +319,22 @@ export default {
];
},
openDateDisplay() {
// make 'forecasted' a constant
if (this.currentGrant.opportunity_status === 'forecasted') {
if (!this.currentGrant.open_date || this.currentGrant.open_date === FAR_FUTURE_CLOSE_DATE) {
return NOT_YET_ISSUED_TEXT;
}
if (this.currentGrant.opportunity_status === FORECASTED) {
// check for date validity here and in closeDateDisplay
return `est. ${this.formatDate(this.currentGrant.open_date)}`;
return `${this.formatDate(this.currentGrant.open_date)}`;
}
return this.formatDate(this.currentGrant.open_date);
},
closeDateDisplay() {
// If we have an explainer text instead of a real close date, display that instead
if (!this.currentGrant.close_date || this.currentGrant.close_date === FAR_FUTURE_CLOSE_DATE) {
return this.currentGrant.close_date_explanation ?? NOT_AVAILABLE_TEXT;
} if (this.currentGrant.opportunity_status === 'forecasted') {
return `est. ${this.formatDate(this.currentGrant.close_date)}`;
return this.currentGrant.close_date_explanation ?? NOT_YET_ISSUED_TEXT;
}
if (this.currentGrant.opportunity_status === FORECASTED) {
return `${this.formatDate(this.currentGrant.close_date)}`;
}
return this.formatDate(this.currentGrant.close_date);
},
Expand Down Expand Up @@ -360,6 +367,12 @@ export default {
statusSubmitButtonDisabled() {
return this.selectedInterestedCode === null;
},
displayEstimatedCloseDateText() {
return this.currentGrant.close_date && this.currentGrant.opportunity_status === 'forecasted';
},
displayEstimatedOpenDateText() {
return this.currentGrant.open_date && this.currentGrant.opportunity_status === 'forecasted';
},
},
watch: {
async currentGrant() {
Expand Down

0 comments on commit 17e2fdf

Please sign in to comment.