diff --git a/frontend/src/modules/member/components/suggestions/member-merge-suggestions-details.vue b/frontend/src/modules/member/components/suggestions/member-merge-suggestions-details.vue index 257f92ccbf..b1c0985561 100644 --- a/frontend/src/modules/member/components/suggestions/member-merge-suggestions-details.vue +++ b/frontend/src/modules/member/components/suggestions/member-merge-suggestions-details.vue @@ -224,7 +224,7 @@ Joined date

- {{ moment(member.joinedAt).format('YYYY-MM-DD') }} + {{ formatJoinedDate(member.joinedAt) }}

{ }, 0); }); +const formatJoinedDate = (date) => { + if (!date || new Date(date).getFullYear() <= 1970) { + return '-'; + } + return moment(date).format('YYYY-MM-DD'); +}; + defineExpose({ more, }); diff --git a/frontend/src/modules/member/member-model.js b/frontend/src/modules/member/member-model.js index 061a8614c6..e8342f29b9 100644 --- a/frontend/src/modules/member/member-model.js +++ b/frontend/src/modules/member/member-model.js @@ -8,6 +8,7 @@ import { OrganizationField } from '@/modules/organization/organization-field'; import StringArrayField from '@/shared/fields/string-array-field'; import GenericField from '@/shared/fields/generic-field'; import MemberEngagementLevelField from './member-engagement-level-field'; +import moment from 'moment'; function label(name) { return i18n(`entities.member.fields.${name}`); @@ -48,7 +49,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', diff --git a/frontend/src/shared/fields/date-time-field.js b/frontend/src/shared/fields/date-time-field.js index deb8a0561a..fb662e6e9d 100644 --- a/frontend/src/shared/fields/date-time-field.js +++ b/frontend/src/shared/fields/date-time-field.js @@ -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;