Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/db/seeds/data/common/common-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import {
acceptPixOrgaTermsOfService,
createPixAppTermsOfService,
createPixCertifTermsOfService,
createPixOrgaTermsOfService,
} from './tooling/legal-documents.js';
import { createTargetProfile } from './tooling/target-profile-tooling.js';
Expand All @@ -39,6 +40,7 @@ export const commonBuilder = async function ({ databaseBuilder }) {
// legal-document
createPixOrgaTermsOfService(databaseBuilder);
createPixAppTermsOfService(databaseBuilder);
createPixCertifTermsOfService(databaseBuilder);

// administration teams
_createAdministrationTeams(databaseBuilder);
Expand Down
4 changes: 4 additions & 0 deletions api/db/seeds/data/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const LEGAL_DOCUMENT_PIX_ORGA_TOS_ID_V1 = COMMON_OFFSET_ID;
const LEGAL_DOCUMENT_PIX_ORGA_TOS_ID_V2 = COMMON_OFFSET_ID + 1;
const LEGAL_DOCUMENT_PIX_APP_TOS_ID_V1 = COMMON_OFFSET_ID + 2;
const LEGAL_DOCUMENT_PIX_APP_TOS_ID_V2 = COMMON_OFFSET_ID + 3;
const LEGAL_DOCUMENT_PIX_CERTIF_TOS_ID_V1 = COMMON_OFFSET_ID + 4;
const LEGAL_DOCUMENT_PIX_CERTIF_TOS_ID_V2 = COMMON_OFFSET_ID + 5;

//TAGS
const AGRICULTURE_TAG = {
Expand Down Expand Up @@ -122,6 +124,8 @@ export {
IMPORT_FORMAT_ONDE_ID,
LEGAL_DOCUMENT_PIX_APP_TOS_ID_V1,
LEGAL_DOCUMENT_PIX_APP_TOS_ID_V2,
LEGAL_DOCUMENT_PIX_CERTIF_TOS_ID_V1,
LEGAL_DOCUMENT_PIX_CERTIF_TOS_ID_V2,
LEGAL_DOCUMENT_PIX_ORGA_TOS_ID_V1,
LEGAL_DOCUMENT_PIX_ORGA_TOS_ID_V2,
LYCEE_TAG,
Expand Down
17 changes: 17 additions & 0 deletions api/db/seeds/data/common/tooling/legal-documents.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
LEGAL_DOCUMENT_PIX_APP_TOS_ID_V1,
LEGAL_DOCUMENT_PIX_APP_TOS_ID_V2,
LEGAL_DOCUMENT_PIX_CERTIF_TOS_ID_V1,
LEGAL_DOCUMENT_PIX_CERTIF_TOS_ID_V2,
LEGAL_DOCUMENT_PIX_ORGA_TOS_ID_V1,
LEGAL_DOCUMENT_PIX_ORGA_TOS_ID_V2,
} from '../constants.js';
Expand Down Expand Up @@ -49,3 +51,18 @@ export function createPixAppTermsOfService(databaseBuilder) {
versionAt: '2022-01-01',
});
}

export function createPixCertifTermsOfService(databaseBuilder) {
databaseBuilder.factory.buildLegalDocumentVersion({
id: LEGAL_DOCUMENT_PIX_CERTIF_TOS_ID_V1,
type: 'TOS',
service: 'pix-certif',
versionAt: '2018-01-01',
});
databaseBuilder.factory.buildLegalDocumentVersion({
id: LEGAL_DOCUMENT_PIX_CERTIF_TOS_ID_V2,
type: 'TOS',
service: 'pix-certif',
versionAt: '2021-01-01',
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const getCertificationPointOfContact = async function ({
userId,
centerRepository,
certificationPointOfContactRepository,
legalDocumentApiRepository,
}) {
const { authorizedCenterIds, certificationPointOfContactDTO } =
await certificationPointOfContactRepository.getAuthorizedCenterIds(userId);
Expand All @@ -26,10 +27,13 @@ const getCertificationPointOfContact = async function ({
centerList,
});

const pixCertifTosStatus = await legalDocumentApiRepository.getPixCertifTosStatus({ userId });

return certificationPointOfContactRepository.getPointOfContact({
userId,
certificationPointOfContactDTO,
allowedCertificationCenterAccesses,
pixCertifTosStatus,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ const getAuthorizedCenterIds = async function (userId) {
lastName: 'users.lastName',
email: 'users.email',
lang: 'users.lang',
pixCertifTermsOfServiceAccepted: 'users.pixCertifTermsOfServiceAccepted',
certificationCenterIds: knexConn.raw('array_agg(?? order by ?? asc)', [
'certificationCenterId',
'certificationCenterId',
Expand Down Expand Up @@ -117,13 +116,15 @@ const getPointOfContact = async function ({
userId,
certificationPointOfContactDTO,
allowedCertificationCenterAccesses,
pixCertifTosStatus,
}) {
const certificationCenterMemberships = await _findNotDisabledCertificationCenterMemberships(userId);

return new CertificationPointOfContact({
...certificationPointOfContactDTO,
allowedCertificationCenterAccesses,
certificationCenterMemberships,
pixCertifTosStatus,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const serialize = function (certificationPointOfContact) {
'email',
'lang',
'pixCertifTermsOfServiceAccepted',
'pixCertifTermsOfServiceStatus',
'pixCertifTermsOfServiceDocumentPath',
'lastPixCertifTermsOfServiceValidatedAt',
'allowedCertificationCenterAccesses',
CERTIFICATION_CENTER_MEMBERSHIP_ATTRIBUTE,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const getPixAppTosStatus = async ({ userId, dependencies = { legalDocumentApi }
return dependencies.legalDocumentApi.getLegalDocumentStatusByUserId({ userId, service: 'pix-app', type: 'TOS' });
};

const getPixCertifTosStatus = async ({ userId, dependencies = { legalDocumentApi } }) => {
return dependencies.legalDocumentApi.getLegalDocumentStatusByUserId({ userId, service: 'pix-certif', type: 'TOS' });
};

const getPixOrgaTosStatus = async ({ userId, dependencies = { legalDocumentApi } }) => {
return dependencies.legalDocumentApi.getLegalDocumentStatusByUserId({
userId,
Expand All @@ -25,4 +29,5 @@ export const legalDocumentApiRepository = {
acceptPixOrgaTos,
getPixAppTosStatus,
getPixOrgaTosStatus,
getPixCertifTosStatus,
};
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ export class LegalDocumentStatus {
documentPath: null,
});
}

get isAccepted() {
Comment thread
nlepage marked this conversation as resolved.
return this.status === STATUS.ACCEPTED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ class CertificationPointOfContact {
lastName,
email,
lang,
pixCertifTermsOfServiceAccepted,
allowedCertificationCenterAccesses,
certificationCenterMemberships,
pixCertifTosStatus,
}) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.lang = lang;
this.pixCertifTermsOfServiceAccepted = pixCertifTermsOfServiceAccepted;
this.pixCertifTermsOfServiceAccepted = pixCertifTosStatus.isAccepted;
this.allowedCertificationCenterAccesses = allowedCertificationCenterAccesses;
this.certificationCenterMemberships = certificationCenterMemberships;
this.pixCertifTermsOfServiceStatus = pixCertifTosStatus.status;
this.pixCertifTermsOfServiceDocumentPath = pixCertifTosStatus.documentPath;
this.lastPixCertifTermsOfServiceValidatedAt = pixCertifTosStatus.acceptedAt;
}
}

Expand Down
Loading
Loading