bid-tool/auto-bid-tool/models/bid.js

30 lines
936 B
JavaScript

import CONSTANTS from '../system/constants.js';
import { takeSnapshot } from '../system/utils.js';
import _ from 'lodash';
export class Bid {
type;
puppeteer_connect;
url;
action;
page_context;
constructor(type, url, puppeteer_connect) {
this.type = type;
this.url = url;
this.puppeteer_connect = puppeteer_connect;
}
handleTakeWorkSnapshot = _.debounce(async () => {
if (!this.page_context) return;
try {
await this.page_context.waitForSelector('#pageContainer', { timeout: 10000 });
console.log(`✅ Page fully loaded. Taking snapshot for Product ID: ${this.id}`);
takeSnapshot(this.page_context, this, 'working', CONSTANTS.TYPE_IMAGE.WORK);
} catch (error) {
console.error(`❌ Error taking snapshot for Product ID: ${this.id}:`, error.message);
}
}, 1000);
}