Deploy to production #11
|
|
@ -1,8 +1,8 @@
|
|||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<link rel="icon" href="public/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + React + TS</title>
|
||||
</head>
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -24,11 +24,24 @@ export default function Bids() {
|
|||
const [openedBid, bidModal] = useDisclosure(false);
|
||||
|
||||
const columns: IColumn<IBid>[] = [
|
||||
{
|
||||
key: 'id',
|
||||
title: 'ID',
|
||||
typeFilter: 'number',
|
||||
},
|
||||
{
|
||||
key: 'name',
|
||||
title: 'Name',
|
||||
typeFilter: 'text',
|
||||
},
|
||||
{
|
||||
key: 'web_bid',
|
||||
title: 'Web',
|
||||
typeFilter: 'text',
|
||||
renderRow(row) {
|
||||
return <span>{row.web_bid.origin_url}</span>;
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'lot_id',
|
||||
title: 'Lot ID',
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"createdAt":1744361020595}
|
||||
{"createdAt":1744420823691}
|
||||
|
|
@ -35,6 +35,8 @@ export class ImapService {
|
|||
tls: true,
|
||||
tlsOptions: { rejectUnauthorized: false },
|
||||
});
|
||||
|
||||
console.log(this.configService.get<string>('MAIL_USER'));
|
||||
}
|
||||
|
||||
async connectIMAP() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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: [] };
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue