Deploy to production #11
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -1,13 +1,13 @@
 | 
			
		|||
<!doctype html>
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="en">
 | 
			
		||||
  <head>
 | 
			
		||||
    <meta charset="UTF-8" />
 | 
			
		||||
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 | 
			
		||||
    <title>Vite + React + TS</title>
 | 
			
		||||
  </head>
 | 
			
		||||
  <body>
 | 
			
		||||
    <div id="root"></div>
 | 
			
		||||
    <script type="module" src="/src/main.tsx"></script>
 | 
			
		||||
  </body>
 | 
			
		||||
    <head>
 | 
			
		||||
        <meta charset="UTF-8" />
 | 
			
		||||
        <link rel="icon" href="public/favicon.ico" />
 | 
			
		||||
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 | 
			
		||||
        <title>Vite + React + TS</title>
 | 
			
		||||
    </head>
 | 
			
		||||
    <body>
 | 
			
		||||
        <div id="root"></div>
 | 
			
		||||
        <script type="module" src="/src/main.tsx"></script>
 | 
			
		||||
    </body>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 15 KiB  | 
| 
						 | 
				
			
			@ -34,6 +34,14 @@ export default function Bids() {
 | 
			
		|||
            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',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ export class LangtonsProductBid extends ProductBid {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -343,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;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -364,7 +370,7 @@ export class LangtonsProductBid extends ProductBid {
 | 
			
		|||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (lotData.myBid && this.max_price && this.max_price != lotData.myBid) {
 | 
			
		||||
                        this.handlePlaceBid();
 | 
			
		||||
                        // this.handlePlaceBid();
 | 
			
		||||
                    }
 | 
			
		||||
                } catch (error) {
 | 
			
		||||
                    console.error(`🚨 [${this.id}] Error parsing API response:`, error);
 | 
			
		||||
| 
						 | 
				
			
			@ -393,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