update
This commit is contained in:
		
							parent
							
								
									de847ce7cb
								
							
						
					
					
						commit
						481bab8c17
					
				
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
					@ -136,6 +136,8 @@ const chooseLocation = async (
 | 
				
			||||||
  const container = await thiefService.getElementByXPath(xpaths.container);
 | 
					  const container = await thiefService.getElementByXPath(xpaths.container);
 | 
				
			||||||
  if (!container) throw new Error("Container xpath not found");
 | 
					  if (!container) throw new Error("Container xpath not found");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  thiefService.scrollToElement(container);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Tìm phần tử con có nội dung giống value
 | 
					  // Tìm phần tử con có nội dung giống value
 | 
				
			||||||
  const matchingChild = Array.from(container.children).find((child) =>
 | 
					  const matchingChild = Array.from(container.children).find((child) =>
 | 
				
			||||||
    child.textContent
 | 
					    child.textContent
 | 
				
			||||||
| 
						 | 
					@ -216,54 +218,54 @@ const handle = async (item: IItem) => {
 | 
				
			||||||
  // B1. Upload images
 | 
					  // B1. Upload images
 | 
				
			||||||
  await uploadImages(item);
 | 
					  await uploadImages(item);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await delay(200);
 | 
					  await delay(400);
 | 
				
			||||||
  // B2. Write title
 | 
					  // B2. Write title
 | 
				
			||||||
  thiefService.writeToInput(item.title, selectors.title_input);
 | 
					  thiefService.writeToInput(item.title, selectors.title_input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await delay(200);
 | 
					  await delay(400);
 | 
				
			||||||
  // B3. Write price
 | 
					  // B3. Write price
 | 
				
			||||||
  thiefService.writeToInput(String(item.price), selectors.price_input);
 | 
					  thiefService.writeToInput(String(item.price), selectors.price_input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await delay(200);
 | 
					  await delay(400);
 | 
				
			||||||
  // B4. Select category
 | 
					  // B4. Select category
 | 
				
			||||||
  await chooseSelect(item.category, selectors.category_select);
 | 
					  await chooseSelect(item.category, selectors.category_select);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await delay(200);
 | 
					  await delay(400);
 | 
				
			||||||
  // B5. Select condition
 | 
					  // B5. Select condition
 | 
				
			||||||
  await chooseSelect(item.condition, selectors.condition_select);
 | 
					  await chooseSelect(item.condition, selectors.condition_select);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (item.brand) {
 | 
					  if (item.brand) {
 | 
				
			||||||
    await delay(200);
 | 
					    await delay(400);
 | 
				
			||||||
    // B3. Write price
 | 
					    // B3. Write price
 | 
				
			||||||
    thiefService.writeToInput(item.brand, selectors.brand_input);
 | 
					    thiefService.writeToInput(item.brand, selectors.brand_input);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await delay(200);
 | 
					  await delay(400);
 | 
				
			||||||
  // B3. Write price
 | 
					  // B3. Write price
 | 
				
			||||||
  await thiefService.writeToInput(
 | 
					  await thiefService.writeToInput(
 | 
				
			||||||
    item.description,
 | 
					    item.description,
 | 
				
			||||||
    selectors.description_input
 | 
					    selectors.description_input
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await delay(200);
 | 
					  await delay(400);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await writeTags(item.tags, selectors.tags_input);
 | 
					  await writeTags(item.tags, selectors.tags_input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await delay(200);
 | 
					  await delay(400);
 | 
				
			||||||
  // B3. Write price
 | 
					  // B3. Write price
 | 
				
			||||||
  thiefService.writeToInput(item.sku, selectors.sku_input);
 | 
					  thiefService.writeToInput(item.sku, selectors.sku_input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (item?.location) {
 | 
					  if (item?.location) {
 | 
				
			||||||
    await delay(200);
 | 
					    await delay(400);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await chooseLocation(item.location, selectors.location_select);
 | 
					    await chooseLocation(item.location, selectors.location_select);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await delay(200);
 | 
					  await delay(400);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await clickNext();
 | 
					  await clickNext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // await delay(200);
 | 
					  // await delay(400);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -107,7 +107,7 @@ export default function List() {
 | 
				
			||||||
      displayType: "custom",
 | 
					      displayType: "custom",
 | 
				
			||||||
      render: (value, row) => {
 | 
					      render: (value, row) => {
 | 
				
			||||||
        if (!row.tags.length) {
 | 
					        if (!row.tags.length) {
 | 
				
			||||||
          return <Badge variant={"secondary"}>Chưa có vai trò</Badge>;
 | 
					          return <Badge variant={"secondary"}>No tags</Badge>;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return (
 | 
					        return (
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 350 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 972 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 1.0 MiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 994 KiB  | 
| 
						 | 
					@ -10,6 +10,8 @@ export class PublistHistory extends CoreEntity {
 | 
				
			||||||
  @Column({ type: 'bool' })
 | 
					  @Column({ type: 'bool' })
 | 
				
			||||||
  published: boolean;
 | 
					  published: boolean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @ManyToOne(() => Product, (product) => product.histories)
 | 
					  @ManyToOne(() => Product, (product) => product.histories, {
 | 
				
			||||||
 | 
					    onDelete: 'CASCADE', // hoặc 'SET NULL' tùy mục đích
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
  product: Product;
 | 
					  product: Product;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -122,7 +122,6 @@ export class ProductsService extends CoreService<Product> {
 | 
				
			||||||
    // Đợi phản hồi từ client
 | 
					    // Đợi phản hồi từ client
 | 
				
			||||||
    const publistResult = await this.waitForPublistResult(plainData);
 | 
					    const publistResult = await this.waitForPublistResult(plainData);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    console.log({ publistResult });
 | 
					 | 
				
			||||||
    if (!publistResult.published) {
 | 
					    if (!publistResult.published) {
 | 
				
			||||||
      throw new BadRequestException(
 | 
					      throw new BadRequestException(
 | 
				
			||||||
        AppResponse.toResponse(null, {
 | 
					        AppResponse.toResponse(null, {
 | 
				
			||||||
| 
						 | 
					@ -169,7 +168,6 @@ export class ProductsService extends CoreService<Product> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const result = await this.historiesRepo.save({ ...data, product });
 | 
					    const result = await this.historiesRepo.save({ ...data, product });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    console.log({ result });
 | 
					 | 
				
			||||||
    this.eventService.sendEvent(
 | 
					    this.eventService.sendEvent(
 | 
				
			||||||
      `${ProductsService.EVENTS.PUBLIST_FINISH}_${plainData.id}`,
 | 
					      `${ProductsService.EVENTS.PUBLIST_FINISH}_${plainData.id}`,
 | 
				
			||||||
      plainToClass(PublistHistory, result),
 | 
					      plainToClass(PublistHistory, result),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue