Merge Dev in Staging
This commit is contained in:
commit
7160bbed3f
@ -35,13 +35,11 @@ export default class CustomerController extends ApiController {
|
||||
}
|
||||
try {
|
||||
const enrollment = await this.id360Service.getEnrollment(callbackToken);
|
||||
console.log("enrollment", enrollment);
|
||||
if (enrollment.status !== "OK") {
|
||||
this.httpUnauthorized(response, "Enrollment status is not OK");
|
||||
return;
|
||||
}
|
||||
const customerData = await this.id360Service.getReport(enrollment.id);
|
||||
console.log(customerData.external_methods.france_connect.results);
|
||||
const customer = await this.customerService.get({
|
||||
where: {
|
||||
contact: {
|
||||
@ -55,7 +53,6 @@ export default class CustomerController extends ApiController {
|
||||
contact: true,
|
||||
}
|
||||
});
|
||||
console.log(customer);
|
||||
// const contact = await this.customerService.getByEmail(
|
||||
// customerData.external_methods.france_connect.results.france_connect_out_userinfo[0].email,
|
||||
// );
|
||||
|
@ -50,10 +50,7 @@ export default class DocumentController extends ApiController {
|
||||
this.httpBadRequest(response, "Missing document id");
|
||||
return;
|
||||
}
|
||||
|
||||
const enrl = await this.id360Service.createEnrollment(documentId!);
|
||||
console.log(enrl)
|
||||
|
||||
await this.id360Service.createEnrollment(documentId!);
|
||||
//success
|
||||
this.httpSuccess(response);
|
||||
} catch (error) {
|
||||
|
@ -110,7 +110,6 @@ export default class Id360Service extends BaseService {
|
||||
);
|
||||
|
||||
const resJson = (await res.json()) as EnrollmentResponse;
|
||||
console.log(resJson.id);
|
||||
return {
|
||||
franceConnectUrl: `${this.variables.DOCAPOST_BASE_URL}static/process_ui/index.html#/enrollment/${resJson.api_key}`,
|
||||
processId: resJson.id,
|
||||
@ -139,10 +138,8 @@ export default class Id360Service extends BaseService {
|
||||
);
|
||||
|
||||
const resJson = (await res.json()) as EnrollmentResponse;
|
||||
console.log(resJson);
|
||||
const route = await this.getRouteId(resJson.api_key);
|
||||
await this.selectRoute(resJson.api_key, route);
|
||||
console.log(route);
|
||||
await this.uploadDocument(resJson.api_key, documentUid);
|
||||
|
||||
return await this.getReport(resJson.id);
|
||||
|
@ -355,39 +355,34 @@ export default class IdNotService extends BaseService {
|
||||
updated_at: null,
|
||||
},
|
||||
};
|
||||
|
||||
let userHydrated = User.hydrate<User>(userToAdd);
|
||||
const user = await this.userService.create(userHydrated);
|
||||
const userOffice = await this.officeService.getByUid(user.office_uid);
|
||||
userHydrated = User.hydrate<User>(user);
|
||||
const userOfficeHydrated = Office.hydrate<Office>(userOffice!);
|
||||
|
||||
const officeRoles = await this.officeRolesService.get({
|
||||
where: { office: { idNot: "0000" } },
|
||||
include: { office: true, rules: true },
|
||||
});
|
||||
const documentTypes = await this.documentTypesService.get({ where: { office: { idNot: "0000" } }, include: { office: true } });
|
||||
const deedTypes = await this.deedTypesService.get({
|
||||
where: { office: { idNot: "0000" } },
|
||||
include: { office: true, document_types: { include: { office: true } } },
|
||||
});
|
||||
const documentTypes = await this.documentTypesService.get({
|
||||
where: { office: { idNot: "0000" } },
|
||||
include: { office: true },
|
||||
});
|
||||
|
||||
const officeRolesHydrated = OfficeRole.hydrateArray<OfficeRole>(officeRoles);
|
||||
const documentTypesHydrated = DocumentType.hydrateArray<DocumentType>(documentTypes);
|
||||
const deedTypesHydrated = DeedType.hydrateArray<DeedType>(deedTypes);
|
||||
const documentTypesHydrated = DocumentType.hydrateArray<DocumentType>(documentTypes);
|
||||
|
||||
officeRolesHydrated.forEach(async (officeRole) => {
|
||||
officeRole.office.uid = user.office_uid;
|
||||
await this.officeRolesService.create(officeRole);
|
||||
});
|
||||
documentTypesHydrated.forEach(async (documentType) => {
|
||||
documentType.office!.uid = user.office_uid;
|
||||
await this.documentTypesService.create(documentType);
|
||||
});
|
||||
deedTypesHydrated.forEach(async (deedType) => {
|
||||
deedType.office!.uid = user.office_uid;
|
||||
deedType.document_types!.forEach((documentType) => {
|
||||
documentType.office!.uid = user.office_uid;
|
||||
});
|
||||
await this.deedTypesService.create(deedType);
|
||||
});
|
||||
|
||||
await this.duplicateOfficeRoles(officeRolesHydrated, userOfficeHydrated);
|
||||
const documentTypesCreated = await this.duplicateDocumentTypes(documentTypesHydrated, userOfficeHydrated);
|
||||
await this.duplicateDeedTypes(deedTypesHydrated, documentTypesCreated, userOfficeHydrated);
|
||||
|
||||
const officeRole = await this.getOfficeRole(userData.typeLien.name, user.office_uid);
|
||||
|
||||
@ -402,6 +397,38 @@ export default class IdNotService extends BaseService {
|
||||
return user;
|
||||
}
|
||||
|
||||
public async duplicateDocumentTypes(documentTypes: DocumentType[], office: Office): Promise<DocumentType[]> {
|
||||
let newDocumentTypes: DocumentType[] = [];
|
||||
for(const documentType of documentTypes) {
|
||||
documentType.office = office;
|
||||
const documentTypeCreated = await this.documentTypesService.create(documentType);
|
||||
newDocumentTypes.push(DocumentType.hydrate<DocumentType>(documentTypeCreated));
|
||||
};
|
||||
return newDocumentTypes;
|
||||
}
|
||||
|
||||
public async duplicateDeedTypes(deedTypes: DeedType[], documentTypes: DocumentType[], office: Office) {
|
||||
for (const deedType of deedTypes) {
|
||||
let newDocumentTypes: DocumentType[] = [];
|
||||
for (const document of deedType.document_types!) {
|
||||
const newDocumentType = documentTypes.find((documentType) => documentType.name === document.name);
|
||||
newDocumentTypes.push(newDocumentType!);
|
||||
};
|
||||
deedType.document_types = newDocumentTypes;
|
||||
deedType.office = office;
|
||||
await this.deedTypesService.create(deedType);
|
||||
};
|
||||
}
|
||||
|
||||
public async duplicateOfficeRoles(officeRoles: OfficeRole[], office: Office){
|
||||
for(const officeRole of officeRoles) {
|
||||
officeRole.office = office;
|
||||
await this.officeRolesService.create(officeRole);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async updateUsers() {
|
||||
const usersReq = await this.userService.getUsersToBeChecked();
|
||||
const users = User.hydrateArray<User>(usersReq);
|
||||
|
Loading…
x
Reference in New Issue
Block a user