diff --git a/admin/app/components/users/cgu.gjs b/admin/app/components/users/cgu.gjs new file mode 100644 index 00000000000..555b53fe4fe --- /dev/null +++ b/admin/app/components/users/cgu.gjs @@ -0,0 +1,58 @@ +import { service } from '@ember/service'; +import Component from '@glimmer/component'; +import dayjs from 'dayjs'; +import { t } from 'ember-intl'; + +export default class Cgu extends Component { + @service accessControl; + @service intl; + + get userHasValidatePixAppTermsOfService() { + return this._formatValidatedTermsOfServiceText(this.args.lastTermsOfServiceValidatedAt, this.args.cgu); + } + + get userHasValidatePixOrgaTermsOfService() { + return this._formatValidatedTermsOfServiceText( + this.args.lastPixOrgaTermsOfServiceValidatedAt, + this.args.pixOrgaTermsOfServiceAccepted, + ); + } + + get userHasValidatePixCertifTermsOfService() { + return this._formatValidatedTermsOfServiceText( + this.args.lastPixCertifTermsOfServiceValidatedAt, + this.args.pixCertifTermsOfServiceAccepted, + ); + } + _formatValidatedTermsOfServiceText(date, hasValidatedTermsOfService) { + if (!hasValidatedTermsOfService) { + return this.intl.t('components.users.user-detail-personal-information.cgu.validation.status.non-validated'); + } + + return date + ? this.intl.t('components.users.user-detail-personal-information.cgu.validation.status.validated-with-date', { + formattedDate: dayjs(date).format('DD/MM/YYYY'), + }) + : this.intl.t('components.users.user-detail-personal-information.cgu.validation.status.validated'); + } + + +} diff --git a/admin/app/components/users/user-overview.gjs b/admin/app/components/users/user-overview.gjs index 6ee9a39d59e..186cf38f015 100644 --- a/admin/app/components/users/user-overview.gjs +++ b/admin/app/components/users/user-overview.gjs @@ -64,24 +64,6 @@ export default class UserOverview extends Component { return false; } - get userHasValidatePixAppTermsOfService() { - return this._formatValidatedTermsOfServiceText(this.args.user.lastTermsOfServiceValidatedAt, this.args.user.cgu); - } - - get userHasValidatePixOrgaTermsOfService() { - return this._formatValidatedTermsOfServiceText( - this.args.user.lastPixOrgaTermsOfServiceValidatedAt, - this.args.user.pixOrgaTermsOfServiceAccepted, - ); - } - - get userHasValidatePixCertifTermsOfService() { - return this._formatValidatedTermsOfServiceText( - this.args.user.lastPixCertifTermsOfServiceValidatedAt, - this.args.user.pixCertifTermsOfServiceAccepted, - ); - } - get languageOptions() { return this.languages; } @@ -95,11 +77,6 @@ export default class UserOverview extends Component { return hasBeenAnonymised || isPixAgent; } - _formatValidatedTermsOfServiceText(date, hasValidatedTermsOfService) { - const formattedDateText = date ? `, le ${dayjs(date).format('DD/MM/YYYY')}` : ''; - return hasValidatedTermsOfService ? `OUI${formattedDateText}` : 'NON'; - } - _initForm() { this.form.firstName = this.args.user.firstName; this.form.lastName = this.args.user.lastName; @@ -346,14 +323,7 @@ export default class UserOverview extends Component { - +