Skip to content

Commit

Permalink
fix(Ad): Do not get seller phone if no containers detected
Browse files Browse the repository at this point in the history
  • Loading branch information
bamdadfr committed Apr 17, 2024
1 parent 342d535 commit 9430b21
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/app/ad/ad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,12 @@ export class Ad {
// Phone
if (this.isAuthenticated && this.gatherPhone) {
const phone = await this.getSellerPhone();
this.pdf.printText({
text: `Tel: ${phone}`,
size: FONT_SIZES.small,
});
if (phone) {
this.pdf.printText({
text: `Tel: ${phone}`,
size: FONT_SIZES.small,
});
}
}

// SIREN
Expand All @@ -271,12 +273,17 @@ export class Ad {
}
}

private async getSellerPhone() {
private async getSellerPhone(): Promise<string | null> {
return new Promise((resolve) => {
const containers = document.querySelectorAll(
'[data-pub-id="clicknumero"]',
) as NodeListOf<HTMLDivElement>;

if (containers.length === 0) {
resolve(null);
return;
}

const container = containers[1];

observeElement(container, (mutations) => {
Expand Down

0 comments on commit 9430b21

Please sign in to comment.