Created
August 28, 2021 14:41
-
-
Save pduartesilva2005/1762c8f257d2160bc3487b2baadd93a1 to your computer and use it in GitHub Desktop.
Feature de listar pedidos para criar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState, useEffect } from 'react'; | |
| const productsView = [ | |
| { | |
| internal_code: 'AP001', | |
| bar_code: '7895720035356', | |
| image: | |
| 'https://http2.mlstatic.com/D_NQ_NP_868055-MLB31128557025_062019-O.webp', | |
| unity: '1', | |
| st: '17,52', | |
| description: 'Aplicador da Argamassa Polimérica', | |
| price_per_unity: '', | |
| qtd_packages: '' | |
| }, | |
| { | |
| internal_code: 'AM001', | |
| image: | |
| 'https://http2.mlstatic.com/D_NQ_NP_865641-MLB40725283422_022020-O.jpg', | |
| bar_code: '7895720105356', | |
| unity: '30', | |
| st: '13,02', | |
| description: 'Balde de 30kg da Argamassa Polimérica', | |
| price_per_unity: '', | |
| qtd_packages: '' | |
| }, | |
| { | |
| internal_code: 'AM001', | |
| image: | |
| 'https://http2.mlstatic.com/D_NQ_NP_865641-MLB40725283422_022020-O.jpg', | |
| bar_code: '7895720105356', | |
| unity: '30', | |
| st: '13,02', | |
| description: 'Balde de 30kg da Argamassa Polimérica', | |
| price_per_unity: '', | |
| qtd_packages: '' | |
| } | |
| ]; | |
| export function CreateProduct() { | |
| const [products, setProducts] = useState([ | |
| { | |
| internal_code: '', | |
| image: '', | |
| bar_code: '', | |
| description: '', | |
| st: '', | |
| unity: '', | |
| qtd_packages: '', | |
| price_per_unity: '', | |
| } | |
| ]); | |
| function loadProductsFilled() { | |
| const productsFilled = productsView.map(product => { | |
| return { | |
| internal_code: product.internal_code, | |
| image: product.image, | |
| bar_code: product.bar_code, | |
| description: product.description, | |
| st: product.st, | |
| unity: product.unity, | |
| qtd_packages: product.qtd_packages, | |
| price_per_unity: product.price_per_unity | |
| }; | |
| }); | |
| setProducts(productsFilled); | |
| } | |
| useEffect(() => { | |
| loadProductsFilled(); | |
| }, []); | |
| return ( | |
| <div> | |
| {products.map(product => { | |
| <div> | |
| <strong>Descrição</strong> | |
| <p>{product.description}</p> | |
| <strong>Código Interno</strong> | |
| <p>{product.internal_code}</p> | |
| <strong>Código de Barras</strong> | |
| <p>{product.bar_code}</p> | |
| <strong>ST</strong> | |
| <p>{product.st}</p> | |
| <strong>UNIDADE</strong> | |
| <p>{product.unity}</p> | |
| <img src={product.image} alt={product.description} /> | |
| </div> | |
| })} | |
| </div> | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment