diff --git a/auto-bid-admin/index.html b/auto-bid-admin/index.html
index e4b78ea..8ac7b8f 100644
--- a/auto-bid-admin/index.html
+++ b/auto-bid-admin/index.html
@@ -1,13 +1,13 @@
-
+
-
-
-
-
- Vite + React + TS
-
-
-
-
-
+
+
+
+
+ Vite + React + TS
+
+
+
+
+
diff --git a/auto-bid-admin/public/favicon.ico b/auto-bid-admin/public/favicon.ico
new file mode 100644
index 0000000..06b3a14
Binary files /dev/null and b/auto-bid-admin/public/favicon.ico differ
diff --git a/auto-bid-admin/src/pages/bids.tsx b/auto-bid-admin/src/pages/bids.tsx
index a07fc15..0f1d06f 100644
--- a/auto-bid-admin/src/pages/bids.tsx
+++ b/auto-bid-admin/src/pages/bids.tsx
@@ -24,11 +24,24 @@ export default function Bids() {
const [openedBid, bidModal] = useDisclosure(false);
const columns: IColumn[] = [
+ {
+ key: 'id',
+ title: 'ID',
+ typeFilter: 'number',
+ },
{
key: 'name',
title: 'Name',
typeFilter: 'text',
},
+ {
+ key: 'web_bid',
+ title: 'Web',
+ typeFilter: 'text',
+ renderRow(row) {
+ return {row.web_bid.origin_url};
+ },
+ },
{
key: 'lot_id',
title: 'Lot ID',
diff --git a/auto-bid-server/bot-data/metadata.json b/auto-bid-server/bot-data/metadata.json
index e49ae4f..3dedfb9 100644
--- a/auto-bid-server/bot-data/metadata.json
+++ b/auto-bid-server/bot-data/metadata.json
@@ -1 +1 @@
-{"createdAt":1744361020595}
\ No newline at end of file
+{"createdAt":1744420823691}
\ No newline at end of file
diff --git a/auto-bid-server/src/modules/bids/services/mail/imap.service.ts b/auto-bid-server/src/modules/bids/services/mail/imap.service.ts
index bca5581..555f628 100644
--- a/auto-bid-server/src/modules/bids/services/mail/imap.service.ts
+++ b/auto-bid-server/src/modules/bids/services/mail/imap.service.ts
@@ -35,6 +35,8 @@ export class ImapService {
tls: true,
tlsOptions: { rejectUnauthorized: false },
});
+
+ console.log(this.configService.get('MAIL_USER'));
}
async connectIMAP() {
diff --git a/auto-bid-tool/models/langtons.com.au/langtons-api-bid.js b/auto-bid-tool/models/langtons.com.au/langtons-api-bid.js
index b1b7d4a..713ff05 100644
--- a/auto-bid-tool/models/langtons.com.au/langtons-api-bid.js
+++ b/auto-bid-tool/models/langtons.com.au/langtons-api-bid.js
@@ -17,7 +17,7 @@ export class LangtonsApiBid extends ApiBid {
const timeout = setTimeout(() => {
global.socket.off(`verify-code.${this.origin_url}`); // Xóa listener tránh rò rỉ bộ nhớ
rej(new Error(`[${this.id}] Timeout: No verification code received within 1 minute.`));
- }, 60 * 1000); // 60 giây
+ }, 120 * 1000); // 120 giây
global.socket.on(`verify-code.${this.origin_url}`, async (data) => {
console.log(`📢 [${this.id}] VERIFY CODE:`, data);
@@ -113,13 +113,15 @@ export class LangtonsApiBid extends ApiBid {
// ⏳ Wait for navigation after verification
console.log(`⏳ [${this.id}] Waiting for navigation after verification...`);
- await page.waitForNavigation({ timeout: 8000, waitUntil: 'domcontentloaded' });
+ await page.waitForNavigation({ timeout: 15000, waitUntil: 'domcontentloaded' });
+
+ await page.goto(this.url, { waitUntil: 'networkidle2' });
// 📂 Save session context to avoid re-login
await this.saveContext();
console.log(`✅ [${this.id}] Login successful!`);
- await page.goto(this.url);
+ // await page.goto(this.url);
console.log(`✅ [${this.id}] Navigation successful!`);
} catch (error) {
console.error(`❌ [${this.id}] Error during login process:`, error.message);
@@ -220,6 +222,6 @@ export class LangtonsApiBid extends ApiBid {
} catch (error) {
console.error(`🚨 [${this.id}] Error reloading page:`, error.message);
}
- }, 60000);
+ }, 60000); // 1p reload
};
}
diff --git a/auto-bid-tool/models/langtons.com.au/langtons-product-bid.js b/auto-bid-tool/models/langtons.com.au/langtons-product-bid.js
index 2c1cc55..17d2789 100644
--- a/auto-bid-tool/models/langtons.com.au/langtons-product-bid.js
+++ b/auto-bid-tool/models/langtons.com.au/langtons-product-bid.js
@@ -4,7 +4,7 @@ import { sendMessage } from '../../system/apis/notification.js';
import { createOutBidLog } from '../../system/apis/out-bid-log.js';
import configs from '../../system/config.js';
import CONSTANTS from '../../system/constants.js';
-import { convertAETtoUTC, removeFalsyValues, takeSnapshot } from '../../system/utils.js';
+import { convertAETtoUTC, isTimeReached, removeFalsyValues, takeSnapshot } from '../../system/utils.js';
import { ProductBid } from '../product-bid.js';
export class LangtonsProductBid extends ProductBid {
@@ -26,14 +26,14 @@ export class LangtonsProductBid extends ProductBid {
return time ? convertAETtoUTC(time) : null;
- // return new Date(Date.now() + 2 * 60 * 1000).toUTCString();
+ // return new Date(Date.now() + 6 * 60 * 1000).toUTCString();
} catch (error) {
// Nếu có lỗi xảy ra trong quá trình lấy thời gian, trả về null
return null;
}
}
- async waitForApiResponse(timeout = 10000) {
+ async waitForApiResponse(timeout = 15000) {
if (!this.page_context) {
console.error(`❌ [${this.id}] Error: page_context is undefined.`);
return null;
@@ -57,9 +57,13 @@ export class LangtonsProductBid extends ProductBid {
}
};
- const timer = setTimeout(() => {
- console.log(`⏳ [${this.id}] Timeout: No response received within 10s`);
+ const timer = setTimeout(async () => {
+ console.log(`⏳ [${this.id}] Timeout: No response received within ${timeout / 1000}s`);
this.page_context.off('response', onResponse); // Gỡ bỏ listener khi timeout
+
+ await this.page_context.reload({ waitUntil: 'networkidle0' }); // reload page
+
+ console.log(`🔁 [${this.id}] Reload page in waitForApiResponse`);
resolve(null);
}, timeout);
@@ -184,6 +188,12 @@ export class LangtonsProductBid extends ProductBid {
return; // Dừng hàm nếu giá đã vượt qua giới hạn
}
+ // Kiểm tra thời gian bid
+ if (this.start_bid_time && !isTimeReached(this.start_bid_time)) {
+ console.log(`⏳ [${this.id}] Not yet time to bid. Skipping Product: ${this.name || 'None'}`);
+ return;
+ }
+
// Đợi phản hồi từ API
const response = await this.waitForApiResponse();
@@ -337,6 +347,8 @@ export class LangtonsProductBid extends ProductBid {
if (!lotData || lotData.lotId !== this.lot_id) {
console.log(`⚠️ [${this.id}] Ignored response for lotId: ${lotData?.lotId}`);
+ await this.page_context.reload({ waitUntil: 'networkidle0' });
+ console.log(`🔁 [${this.id}] Reload page in gotoLink`);
return;
}
@@ -357,8 +369,8 @@ export class LangtonsProductBid extends ProductBid {
}
}
- if (lotData.myBid && this.max_price != lotData.myBid) {
- this.handlePlaceBid();
+ if (lotData.myBid && this.max_price && this.max_price != lotData.myBid) {
+ // this.handlePlaceBid();
}
} catch (error) {
console.error(`🚨 [${this.id}] Error parsing API response:`, error);
@@ -387,7 +399,7 @@ export class LangtonsProductBid extends ProductBid {
await this.gotoLink();
}
- await this.handlePlaceBid();
+ // await this.handlePlaceBid();
} catch (error) {
console.error(`🚨 [${this.id}] Error navigating the page: ${error}`);
}
diff --git a/auto-bid-tool/service/app-service.js b/auto-bid-tool/service/app-service.js
index 747f004..ba9b9f8 100644
--- a/auto-bid-tool/service/app-service.js
+++ b/auto-bid-tool/service/app-service.js
@@ -51,7 +51,8 @@ export const createApiBid = (web) => {
};
export const deleteProfile = (data) => {
- const filePath = path.join(CONSTANTS.PROFILE_PATH, sanitizeFileName(data.origin_url) + '.json');
+ if (!data?.origin_url) return false;
+ const filePath = path.join(CONSTANTS.PROFILE_PATH, sanitizeFileName(data?.origin_url) + '.json');
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
diff --git a/auto-bid-tool/system/apis/bid.js b/auto-bid-tool/system/apis/bid.js
index cf829ce..92aced5 100644
--- a/auto-bid-tool/system/apis/bid.js
+++ b/auto-bid-tool/system/apis/bid.js
@@ -34,7 +34,7 @@ export const updateBid = async (id, values) => {
return data.data;
} catch (error) {
- console.log('❌ ERROR IN SERVER: (UPDATE BID) ', error);
+ console.log('❌ ERROR IN SERVER: (UPDATE BID) ', error.response);
return null;
}
};
@@ -73,7 +73,7 @@ export const pushPrice = async (values) => {
return { status: true, data: data.data };
} catch (error) {
- console.log('❌ ERROR IN SERVER (PUSH PRICE): ', error.response.data);
+ console.log('❌ ERROR IN SERVER (PUSH PRICE): ', error?.response);
return { status: false, data: [] };
}
};