mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-08-25 13:49:40 +00:00
feat: adding enhancment for zod admin portal kyc and add customer additional fields
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user