Skip to content

Commit

Permalink
fix(merge-dialog): display '-' for unknown joined date
Browse files Browse the repository at this point in the history
  • Loading branch information
use-tusk[bot] authored Oct 9, 2024
1 parent 4a42b42 commit d34009c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
Joined date
</p>
<p class="text-xs text-gray-900 whitespace-normal">
{{ moment(member.joinedAt).format('YYYY-MM-DD') }}
{{ formatJoinedDate(member.joinedAt) }}
</p>
</article>
<article
Expand Down Expand Up @@ -340,6 +340,13 @@ onMounted(() => {
}, 0);
});
const formatJoinedDate = (date) => {
if (!date || new Date(date).getFullYear() <= 1970) {
return '-';
}
return moment(date).format('YYYY-MM-DD');
};
defineExpose({
more,
});
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/modules/member/member-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ const fields = {
'organizations',
'Organizations',
),
joinedAt: new DateTimeField('joinedAt', 'Joined date'),
joinedAt: new DateTimeField('joinedAt', 'Joined date', {
filterable: true,
formatter: (value) => {
if (!value || new Date(value).getFullYear() <= 1970) {
return '-';
}
return moment(value).format('YYYY-MM-DD');
},
}),
bio: new StringField('bio', label('bio')),
location: new StringField(
'location',
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/shared/fields/date-time-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ export default class DateTimeField extends GenericField {
this.placeholder = config.placeholder;
this.hint = config.hint;
this.filterable = config.filterable || false;
this.formatter = config.formatter || null;
}

forPresenter(value) {
if (this.formatter) {
return this.formatter(value);
}
return value
? moment(value).format('YYYY-MM-DD HH:mm')
: null;
}

forFilterPreview(value) {
if (this.formatter) {
return this.formatter(value);
}
return value
? moment(value).format('YYYY-MM-DD HH:mm')
: null;
Expand Down

0 comments on commit d34009c

Please sign in to comment.