feat: adding enhancment for zod admin portal kyc and add customer additional fields

This commit is contained in:
Abdalhamid Alhamad
2025-03-02 10:49:58 +03:00
parent dae9cb6323
commit 54ce5b022d
11 changed files with 242 additions and 16 deletions

View File

@ -50,13 +50,26 @@ export class CustomerService {
}
if (customer.profilePicture) {
this.logger.log(`Generating pre-signed url for profile picture of customer ${id}`);
customer.profilePicture.url = await this.ociService.generatePreSignedUrl(customer.profilePicture);
}
this.logger.log(`Customer ${id} found successfully`);
return customer;
}
async findInternalCustomerById(id: string) {
this.logger.log(`Finding internal customer ${id}`);
const customer = await this.customerRepository.findOne({ id });
if (!customer) {
this.logger.error(`Internal customer ${id} not found`);
throw new BadRequestException('CUSTOMER.NOT_FOUND');
}
await this.prepareCustomerDocuments(customer);
this.logger.log(`Internal customer ${id} found successfully`);
return customer;
}
async approveKycForCustomer(customerId: string) {
const customer = await this.findCustomerById(customerId);
@ -162,4 +175,24 @@ export class CustomerService {
throw new BadRequestException('CUSTOMER.CIVIL_ID_ALREADY_EXISTS');
}
}
private async prepareCustomerDocuments(customer: Customer) {
const promises = [];
promises.push(this.ociService.generatePreSignedUrl(customer.civilIdFront));
promises.push(this.ociService.generatePreSignedUrl(customer.civilIdBack));
if (customer.profilePicture) {
promises.push(this.ociService.generatePreSignedUrl(customer.profilePicture));
}
const [civilIdFrontUrl, civilIdBackUrl, profilePictureUrl] = await Promise.all(promises);
if (customer.profilePicture) {
customer.profilePicture.url = profilePictureUrl;
}
customer.civilIdFront.url = civilIdFrontUrl;
customer.civilIdBack.url = civilIdBackUrl;
return customer;
}
}