diff --git a/src/Head.js b/src/Head.js index 9dfa636d813960c4957f45ea0c491e3812414b41..7ff283ac84714d2ca72fb32c0228dadae26af5ab 100644 --- a/src/Head.js +++ b/src/Head.js @@ -39,21 +39,18 @@ function Head(props) { ); if (auth.role === "admin") { productNav = ( - <NavDropdown title="Productos" id="admin"> + <NavDropdown title="Almacen" id="admin"> <LinkContainer to="/products"> <NavDropdown.Item>Productos</NavDropdown.Item> </LinkContainer> - <LinkContainer to="/product/add"> - <NavDropdown.Item>Alta codigos</NavDropdown.Item> - </LinkContainer> <LinkContainer to="/inventary"> - <NavDropdown.Item>Inventario</NavDropdown.Item> - </LinkContainer> - <LinkContainer to="/inventary/add"> - <NavDropdown.Item>Entrada</NavDropdown.Item> + <NavDropdown.Item>Entradas Almacén</NavDropdown.Item> </LinkContainer> <LinkContainer to="/supplier/add"> - <NavDropdown.Item>Añade Proveedor</NavDropdown.Item> + <NavDropdown.Item>Alta Proveedores</NavDropdown.Item> + </LinkContainer> + <LinkContainer to="/product/add"> + <NavDropdown.Item>Alta Codigos</NavDropdown.Item> </LinkContainer> </NavDropdown> ); diff --git a/src/OwnPassword.js b/src/OwnPassword.js index 3843194ab3816f806ca93437b81036b8c3265d09..9d6c8992e357b03f11488a591d74f4efad8cb863 100644 --- a/src/OwnPassword.js +++ b/src/OwnPassword.js @@ -16,7 +16,7 @@ function OwnPassword() { body={{ old_password, password }} onSuccess={() => setPasswordChanged(true)} > - <h2>Cambio de contraseña</h2> + <h2 className="text-center">Cambio de contraseña</h2> {passwordChanged && ( <Alert variant="success">La contraseña se ha cambiado con éxito.</Alert> diff --git a/src/Panel.js b/src/Panel.js index ffa697be4520759e0ff23ae691d8e0daead3416a..1fce501790f465db07dc873fa57fbbf10bb5f68a 100644 --- a/src/Panel.js +++ b/src/Panel.js @@ -7,8 +7,7 @@ import MemberList from "./member/MemberList"; import ProductList from "./product/ProductList"; import ShowProduct from "./product/ShowProduct"; import CreateProduct from "./product/CreateProduct"; -import CreateInventary from "./inventary/CreateInventary"; -import InventaryList from "./inventary/InventaryList"; +import Inventary from "./inventary/Inventary"; import ShowInventary from "./inventary/ShowInventary"; import CreateSupplier from "./inventary/CreateSupplier"; import Dashboard from "./Dashboard"; @@ -61,14 +60,11 @@ function LogedPanel(props) { <Route path="/product/:code"> <ShowProduct /> </Route> - <Route path="/inventary/add"> - <CreateInventary /> - </Route> <Route path="/inventary/:id"> <ShowInventary /> </Route> <Route path="/inventary"> - <InventaryList /> + <Inventary /> </Route> <Route path="/supplier/add"> <CreateSupplier /> diff --git a/src/inventary/CreateSupplier.js b/src/inventary/CreateSupplier.js index 037003ed90bee1373417b4ab144c12cf42568d1f..0388ca891d039c539bfebce5951382a61721cf03 100644 --- a/src/inventary/CreateSupplier.js +++ b/src/inventary/CreateSupplier.js @@ -14,29 +14,32 @@ function CreateSupplier() { const body = { name }; return ( - <Sender url="/api/supplier" body={body} onSuccess={setRedirect}> - <Form.Group as={Row}> - <Form.Label as="legend" column sm={3}> - Nombre - </Form.Label> - <Col sm={9}> - <Form.Control - placeholder="nombre" - value={name} - onChange={(e) => setName(e.target.value)} - /> - </Col> - </Form.Group> - <Form.Group as={Row}> - <Col> - <div className="text-right"> - <Button type="submit" disabled={!name}> - Añadir proveedor - </Button> - </div> - </Col> - </Form.Group> - </Sender> + <div> + <h2 className="text-center">Alta de proveedores</h2> + <Sender url="/api/supplier" body={body} onSuccess={setRedirect}> + <Form.Group as={Row}> + <Form.Label as="legend" column sm={3}> + Nombre + </Form.Label> + <Col sm={9}> + <Form.Control + placeholder="nombre" + value={name} + onChange={(e) => setName(e.target.value)} + /> + </Col> + </Form.Group> + <Form.Group as={Row}> + <Col> + <div className="text-right"> + <Button type="submit" disabled={!name}> + Añadir proveedor + </Button> + </div> + </Col> + </Form.Group> + </Sender> + </div> ); } diff --git a/src/inventary/Inventary.js b/src/inventary/Inventary.js new file mode 100644 index 0000000000000000000000000000000000000000..7c1cf3f3ce9aa9c0e809e9d4bf383599b5620397 --- /dev/null +++ b/src/inventary/Inventary.js @@ -0,0 +1,28 @@ +import React, { useState } from "react"; +import InventaryList from "./InventaryList"; +import CreateInventary from "./CreateInventary"; +import Fetcher from "../Fetcher"; + +function Inventary() { + const [inventary, setInventary] = useState([]); + + const setEntry = (entry) => { + let i = inventary; + i.push(entry); + setInventary(i); + }; + + return ( + <div> + <h2 className="text-center">Entradas de Almacén</h2> + <CreateInventary setEntry={setEntry} /> + + <hr /> + <Fetcher url="/api/inventary" onFetch={setInventary}> + <InventaryList inventary={inventary} /> + </Fetcher> + </div> + ); +} + +export default Inventary; diff --git a/src/inventary/InventaryList.js b/src/inventary/InventaryList.js index 53a1f64435045d4742c01295f64a5f8a2f92c545..80011f3d2f5b5738df4abdadcc888cb8261156d9 100644 --- a/src/inventary/InventaryList.js +++ b/src/inventary/InventaryList.js @@ -1,7 +1,6 @@ import React, { useState } from "react"; import { Table, OverlayTrigger, Popover } from "react-bootstrap"; import { LinkContainer } from "react-router-bootstrap"; -import Fetcher from "../Fetcher"; import { printDate, printMoney, printInventaryID } from "../util"; function supplier(entry) { @@ -15,11 +14,12 @@ function inventaryOverlay(entry) { const content = entry.products.map((p) => { const stock = p.stock ? p.stock : ""; const price = p.price !== null ? printMoney(p.price) : ""; + const name = p.product !== null ? p.product.name : p.code; return ( <div key={"I" + entry.ID + "-" + p.ID}> {p.comment && <p>p.comment</p>} - {p.product.name + ": " + stock + " " + price} + {name + ": " + stock + " " + price} <br /> </div> ); @@ -33,10 +33,8 @@ function inventaryOverlay(entry) { ); } -function InventaryList() { - const [inventary, setInventary] = useState([]); - - const entries = inventary.map((i) => ( +function InventaryList(props) { + const entries = props.inventary.map((i) => ( <OverlayTrigger key={i.ID} overlay={inventaryOverlay(i)}> <LinkContainer to={"/inventary/" + i.ID}> <tr> @@ -50,19 +48,17 @@ function InventaryList() { )); return ( - <Fetcher url="/api/inventary" onFetch={setInventary}> - <Table className="text-center" responsive> - <thead> - <tr> - <th>ID</th> - <th>Fecha</th> - <th>Por</th> - <th>Proveedor</th> - </tr> - </thead> - <tbody>{entries}</tbody> - </Table> - </Fetcher> + <Table className="text-center" responsive> + <thead> + <tr> + <th>ID</th> + <th>Fecha</th> + <th>Por</th> + <th>Proveedor</th> + </tr> + </thead> + <tbody>{entries}</tbody> + </Table> ); } diff --git a/src/inventary/ShowInventary.js b/src/inventary/ShowInventary.js index 0e650f092c1108fec84366a6b6a55ab2fc6a4ec2..600fc715753717be3b596572e2258bf73458163b 100644 --- a/src/inventary/ShowInventary.js +++ b/src/inventary/ShowInventary.js @@ -10,7 +10,7 @@ function ShowInventary() { const products = entry.products.map((p) => ( <tr> - <td>{p.product.name}</td> + <td>{p.product !== null ? p.product.name : p.code}</td> <td>{p.stock}</td> <td>{p.price !== null ? printMoney(p.price) : ""}</td> </tr> @@ -32,9 +32,9 @@ function ShowInventary() { <Table striped bordered hover responsive> <thead> <tr> - <th>producto</th> - <th>stock</th> - <th>precio</th> + <th>Producto</th> + <th>Stock</th> + <th>Precio</th> </tr> </thead> <tbody>{products}</tbody> diff --git a/src/product/CreateProduct.js b/src/product/CreateProduct.js index 79c0a4f271d71be84d032cff394a91d36bb90f6d..1590b4c7018d3648c8e52b10a36a4a2e5a710dbf 100644 --- a/src/product/CreateProduct.js +++ b/src/product/CreateProduct.js @@ -28,7 +28,7 @@ function CreateProduct() { return ( <div> - <h2>Crear un nuevo código de producto</h2> + <h2 className="text-center">Crear un nuevo código de producto</h2> <Sender url="/api/product" body={body} onSuccess={setRedirect}> <Form.Row> <Form.Group as={Col}> diff --git a/src/product/ProductList.js b/src/product/ProductList.js index 62e2f511b6d5f8b2dfa24feac3a8128ebbe06960..cf1b6382e57322695f41bc9cac47af381600512c 100644 --- a/src/product/ProductList.js +++ b/src/product/ProductList.js @@ -21,19 +21,22 @@ function ProductList() { }); return ( - <Fetcher url="/api/product" onFetch={setProducts}> - <Table striped bordered hover responsive> - <thead> - <tr> - <th>codigo</th> - <th>Nombre</th> - <th>Precio</th> - <th>Existencias</th> - </tr> - </thead> - <tbody>{entries}</tbody> - </Table> - </Fetcher> + <div> + <h2 className="text-center">Productos en almacén</h2> + <Fetcher url="/api/product" onFetch={setProducts}> + <Table striped bordered hover responsive> + <thead> + <tr> + <th>Código</th> + <th>Producto</th> + <th>Precio</th> + <th>Existencias</th> + </tr> + </thead> + <tbody>{entries}</tbody> + </Table> + </Fetcher> + </div> ); }