From 802af4f8888094d215396022dc2c1bdb39422b8a Mon Sep 17 00:00:00 2001
From: meskio <meskio@sindominio.net>
Date: Mon, 1 Mar 2021 17:14:56 +0100
Subject: [PATCH] Improve inventary presentation

---
 api/db/inventary.go              | 1 +
 src/inventary/CreateInventary.js | 2 --
 src/inventary/InventaryList.js   | 3 +--
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/api/db/inventary.go b/api/db/inventary.go
index 20ec20b..34b2abd 100644
--- a/api/db/inventary.go
+++ b/api/db/inventary.go
@@ -75,6 +75,7 @@ func (d *DB) GetInventary(id int) (inventary Inventary, err error) {
 func (d *DB) ListInventary() (inventaries []Inventary, err error) {
 	err = d.db.Preload("Products.Product").
 		Preload(clause.Associations).
+		Order("date desc").
 		Find(&inventaries).
 		Error
 	return
diff --git a/src/inventary/CreateInventary.js b/src/inventary/CreateInventary.js
index bfc15c5..f69408f 100644
--- a/src/inventary/CreateInventary.js
+++ b/src/inventary/CreateInventary.js
@@ -44,8 +44,6 @@ function CreateInventary() {
     suppliers.map((s) => <option key={s.ID}>{s.name}</option>)
   );
 
-  // TODO: debug it, it doesn't send correctly
-  //  it doesnt load picks when they change...
   return (
     <Sender url="/api/inventary" body={body} onSuccess={setRedirect}>
       <Form.Group as={Row}>
diff --git a/src/inventary/InventaryList.js b/src/inventary/InventaryList.js
index 23b51ec..53a1f64 100644
--- a/src/inventary/InventaryList.js
+++ b/src/inventary/InventaryList.js
@@ -18,6 +18,7 @@ function inventaryOverlay(entry) {
 
     return (
       <div key={"I" + entry.ID + "-" + p.ID}>
+        {p.comment && <p>p.comment</p>}
         {p.product.name + ": " + stock + " " + price}
         <br />
       </div>
@@ -43,7 +44,6 @@ function InventaryList() {
           <td>{printDate(i.date)}</td>
           <td>{i.member.name}</td>
           <td>{supplier(i)}</td>
-          <td>{i.comment}</td>
         </tr>
       </LinkContainer>
     </OverlayTrigger>
@@ -58,7 +58,6 @@ function InventaryList() {
             <th>Fecha</th>
             <th>Por</th>
             <th>Proveedor</th>
-            <th>Comentario</th>
           </tr>
         </thead>
         <tbody>{entries}</tbody>
-- 
GitLab