remove console log
This commit is contained in:
parent
5bd5e096ca
commit
bcd12b5317
@ -220,7 +220,7 @@ export default class CustomersController extends ApiController {
|
|||||||
/**
|
/**
|
||||||
* @description Send a reminder to a specific customer by uid to signe specific documents
|
* @description Send a reminder to a specific customer by uid to signe specific documents
|
||||||
*/
|
*/
|
||||||
@Post("/api/v1/notary/customers/:uid/send_reminder", [authHandler, ruleHandler, customerHandler])
|
@Post("/api/v1/notary/customers/:uid/send_reminder", [authHandler, ruleHandler, customerHandler])
|
||||||
protected async sendReminder(req: Request, response: Response) {
|
protected async sendReminder(req: Request, response: Response) {
|
||||||
try {
|
try {
|
||||||
const uid = req.params["uid"];
|
const uid = req.params["uid"];
|
||||||
@ -228,18 +228,18 @@ export default class CustomersController extends ApiController {
|
|||||||
this.httpBadRequest(response, "No uid provided");
|
this.httpBadRequest(response, "No uid provided");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const documentsUid = req.body.documentsUid;
|
const documentsUid = req.body.documentsUid;
|
||||||
if (!documentsUid || !Array.isArray(documentsUid)) {
|
if (!documentsUid || !Array.isArray(documentsUid)) {
|
||||||
this.httpBadRequest(response, "Invalid or missing documents");
|
this.httpBadRequest(response, "Invalid or missing documents");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const documentEntities : Documents[] = [];
|
const documentEntities: Documents[] = [];
|
||||||
//For each document uid, use DocumentsService.getByUid to get the document entity and add it to the documents array
|
//For each document uid, use DocumentsService.getByUid to get the document entity and add it to the documents array
|
||||||
for (const documentUid of documentsUid) {
|
for (const documentUid of documentsUid) {
|
||||||
const documentEntity = await this.documentsService.getByUid(documentUid, { document_type : true, folder : true });
|
const documentEntity = await this.documentsService.getByUid(documentUid, { document_type: true, folder: true });
|
||||||
|
|
||||||
if (!documentEntity) {
|
if (!documentEntity) {
|
||||||
this.httpBadRequest(response, "Document not found");
|
this.httpBadRequest(response, "Document not found");
|
||||||
return;
|
return;
|
||||||
@ -247,9 +247,8 @@ export default class CustomersController extends ApiController {
|
|||||||
documentEntities.push(documentEntity);
|
documentEntities.push(documentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
const customerEntity = await this.customersService.getByUid(uid, { contact: true, office : true });
|
const customerEntity = await this.customersService.getByUid(uid, { contact: true, office: true });
|
||||||
|
|
||||||
|
|
||||||
if (!customerEntity) {
|
if (!customerEntity) {
|
||||||
this.httpNotFoundRequest(response, "customer not found");
|
this.httpNotFoundRequest(response, "customer not found");
|
||||||
return;
|
return;
|
||||||
@ -257,13 +256,10 @@ export default class CustomersController extends ApiController {
|
|||||||
|
|
||||||
//Hydrate ressource with prisma entity
|
//Hydrate ressource with prisma entity
|
||||||
const customer = Customer.hydrate<Customer>(customerEntity, { strategy: "excludeAll" });
|
const customer = Customer.hydrate<Customer>(customerEntity, { strategy: "excludeAll" });
|
||||||
|
|
||||||
|
|
||||||
// Call service to send reminder with documents
|
|
||||||
const reminder = await this.customersService.sendDocumentsReminder(customer, documentEntities);
|
|
||||||
|
|
||||||
|
// Call service to send reminder with documents
|
||||||
|
await this.customersService.sendDocumentsReminder(customer, documentEntities);
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
this.httpSuccess(response, customer);
|
this.httpSuccess(response, customer);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user