Skip to content

Commit 8a54b6e

Browse files
authored
Merge pull request #18 from MauricioFa/masterCopy/improveMVP/1-0-0
Master copy/improve mvp/1 0 0
2 parents 69d7f0c + d0579a2 commit 8a54b6e

12 files changed

Lines changed: 282 additions & 237 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ La descripción al avance en el proyecto se resumirá de la siguiente manera:
3333

3434
- Pantalla de Sign in / Sign up / Logout , agregar opción de registro y login con redes sociales.
3535
- _V 100%_
36-
- **_A 10% fake_**
36+
- **_A 20% fake_**
3737
- Pantalla de generación de facturas.
3838
- _V 100% extra_
3939
- _A 100% extra_
4040
- Pantalla de Gestión del inventario.
4141
- _V 100% **noAdmin**_
4242
- _A 100% **noAdmin**_
4343
- Pantalla de Reportes, administración y gestión de gastos.
44-
- **_V 20%_**
44+
- **_V 10%_**
4545
- **_A 0%_**
4646

4747
_fake_: permite el ingreso a la app con solamente disponer de un texto para el _e-mail_ y contraseña que supere las comprobaciones mínimas de html5 para estos campos.
@@ -63,8 +63,8 @@ _noAdmin_: la funcionalidad por el momento es absoluta. Al ser un MVP de plantil
6363
- _V 100% **noSearch**_
6464
- _A 100% **noSearch**_
6565
4. El sistema valida la existencia del producto en el inventario.
66-
- **_V 0%_**
67-
- **_A 0%_**
66+
- _V 100%_
67+
- _A 100%_
6868
5. Calcular el costo total de la venta.
6969
- _V 100%_
7070
- _A 100%_

src/frontend/assets/styles/ProductsListToCart.css

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/frontend/assets/styles/ShoppingCart.css

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/frontend/components/Inventory.jsx

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ import MaterialTable from 'material-table';
44
import tableIcons from './utils/tableIconsByMaterialTable';
55
import { addToInventory, removeFromInventory, updateToInventory } from '../actions/indexActions';
66

7+
const columns = [
8+
{ title: 'SKU', field: 'sku' },
9+
{ title: 'Producto', field: 'name' },
10+
{ title: 'Descripción', field: 'description', emptyValue: 'Sin descripción' },
11+
{ title: 'Categoría', field: 'categories', emptyValue: 'Sin categoría' },
12+
{ title: 'Valor compra und', field: 'buyingPrice', type: 'numeric' },
13+
{ title: 'Valor venda und', field: 'sellingPrice', type: 'numeric' },
14+
{ title: 'Inventario', field: 'inStock', type: 'numeric' },
15+
{ title: 'Alerta límite', field: 'limitInStock', type: 'numeric' },
16+
];
17+
718
const ProductsList = (props) => {
819
const { products } = props;
920

@@ -12,16 +23,6 @@ const ProductsList = (props) => {
1223
categories: item.categories[0],
1324
}));
1425

15-
const columns = [
16-
{ title: 'SKU', field: 'sku' },
17-
{ title: 'Producto', field: 'name' },
18-
{ title: 'Descripción', field: 'description', emptyValue: 'Sin descripción' },
19-
{ title: 'Categoría', field: 'categories', emptyValue: 'Sin categoría' },
20-
{ title: 'Valor compra und', field: 'buyingPrice', type: 'numeric' },
21-
{ title: 'Valor venda und', field: 'sellingPrice', type: 'numeric' },
22-
{ title: 'Inventario', field: 'inStock', type: 'numeric', emptyValue: '0' },
23-
];
24-
2526
return (
2627
<MaterialTable
2728
title='Productos'
@@ -78,27 +79,35 @@ const ProductsList = (props) => {
7879
categories: [newData.categories],
7980
buyingPrice: Number(newData.buyingPrice),
8081
sellingPrice: Number(newData.sellingPrice),
81-
inStock: newData.inStock ? Number(newData.inStock) : 0,
82+
inStock: Number(newData.inStock),
83+
limitInStock: Number(newData.limitInStock),
8284
})
8385
);
8486
}
8587
}),
8688
onRowUpdate: (updateData, oldData) =>
87-
new Promise((resolve) => {
88-
const ary = products.filter((item) => item.sku === updateData.sku)[0].categories;
89-
ary[0] = updateData.categories;
90-
resolve(
91-
props.updateToInventory({
92-
updateData: {
93-
...updateData,
94-
categories: ary,
95-
buyingPrice: Number(updateData.buyingPrice),
96-
sellingPrice: Number(updateData.sellingPrice),
97-
inStock: Number(updateData.inStock),
98-
},
99-
oldData,
100-
})
101-
);
89+
new Promise((resolve, reject) => {
90+
if (updateData.sku === '' || updateData.name === '') {
91+
reject(alert('Debe agregar un SKU y nombre de Producto validos'));
92+
} else if (updateData.buyingPrice === '' || updateData.sellingPrice === '') {
93+
reject(alert('Debe agregar Precios de compra y venta validos'));
94+
} else {
95+
const ary = products.filter((item) => item.sku === updateData.sku)[0].categories;
96+
ary[0] = updateData.categories;
97+
resolve(
98+
props.updateToInventory({
99+
updateData: {
100+
...updateData,
101+
categories: ary,
102+
buyingPrice: Number(updateData.buyingPrice),
103+
sellingPrice: Number(updateData.sellingPrice),
104+
inStock: Number(updateData.inStock),
105+
limitInStock: Number(updateData.limitInStock),
106+
},
107+
oldData,
108+
})
109+
);
110+
}
102111
}),
103112
onRowDelete: (deleteData) =>
104113
new Promise((resolve) => {

src/frontend/components/Layout.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const routesForHeader = [
9292
{ route: '/products', title: 'Productos' },
9393
{ route: '/config', title: 'Configuración Cuenta' },
9494
{ route: '/logUp', title: 'Crear cuenta' },
95-
{ route: '/', title: 'Dashboard' },
95+
{ route: '/', title: 'Resumen' },
9696
{ route: '/newpassword', title: 'Nueva clave' },
9797
];
9898

@@ -107,9 +107,9 @@ const Layout = (props) => {
107107
setOpen(false);
108108
let title = routesForHeader.filter((item) => item.route === history.location.pathname);
109109
title = title[0] ? title[0].title : 'Not Found';
110-
title = !isAuthenticated && title === 'Dashboard' ? 'Ingresar' : title;
110+
title = !isAuthenticated && title === 'Resumen' ? 'Ingresar' : title;
111111
setTitleHeader(title);
112-
}, [history.location.pathname]);
112+
}, [history.location.pathname, isAuthenticated]);
113113

114114
const handleDrawerOpen = () => {
115115
setOpen(true);

src/frontend/components/MainItemsList.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const MainItemsList = (
2323
<ListItemIcon>
2424
<DashboardIcon color='primary' />
2525
</ListItemIcon>
26-
<ListItemText primary='Informes' />
26+
<ListItemText primary='Resumen' />
2727
</ListItem>
2828
</Link>
2929
<Link to='/ordersfull'>

src/frontend/components/ProductsListToCart.jsx

Lines changed: 101 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,117 @@
11
import React from 'react';
22
import { connect } from 'react-redux';
3+
import { makeStyles } from '@material-ui/core/styles';
4+
import { Button } from '@material-ui/core';
35
import { addToCart } from '../actions/indexActions';
4-
import '../assets/styles/ProductsListToCart.css';
6+
7+
const useStyles = makeStyles((theme) => ({
8+
productsItems: {
9+
display: 'grid',
10+
gridTemplateColumns: 'repeat(3, 1fr)',
11+
gridGap: '1.5rem',
12+
[theme.breakpoints.down('719')]: {
13+
gridTemplateColumns: 'repeat(2, 1fr)',
14+
},
15+
[theme.breakpoints.down('419')]: {
16+
gridTemplateColumns: 'repeat(1, 1fr)',
17+
},
18+
},
19+
productItem: {
20+
textDecoration: 'none',
21+
boxShadow: '8px 14px 38px rgba(39, 44, 49, .3), 1px 3px 8px rgba(39, 44, 49, .1)',
22+
borderRadius: '10px',
23+
margin: '0 0 20px 0',
24+
position: 'relative',
25+
display: 'flex',
26+
flexDirection: 'column',
27+
justifyContent: 'space-between',
28+
alignItems: 'center',
29+
},
30+
productItemImg: {
31+
width: '150px',
32+
height: '150px',
33+
'& img': {
34+
height: '100%',
35+
width: '100%',
36+
padding: '4px',
37+
borderRadius: '10%',
38+
objectfit: 'contain',
39+
},
40+
},
41+
productItemInfo: {
42+
padding: '8px 12px',
43+
height: '140px',
44+
width: '100%',
45+
display: 'flex',
46+
flexDirection: 'column',
47+
justifyContent: 'space-between',
48+
alignItems: 'flex-end',
49+
margin: '0',
50+
'& div': {
51+
width: '100%',
52+
'& h2': {
53+
fontSize: '1.2em',
54+
fontWeight: 'bold',
55+
margin: '4px',
56+
},
57+
'& p': {
58+
margin: '4px',
59+
},
60+
},
61+
'& h3': {
62+
color: '#d71f1fde',
63+
fontSize: '1.4em',
64+
textAlign: 'right',
65+
margin: '0',
66+
},
67+
},
68+
button: {
69+
textTransform: 'capitalize',
70+
fontSize: '1.2em',
71+
fontWeight: 'lighter',
72+
fontFamily: 'sans',
73+
display: 'flex',
74+
justifyContent: 'space-around',
75+
},
76+
}));
577

678
const ProductsListToCart = (props) => {
79+
const classes = useStyles();
780
const { productsList, addToCart } = props;
881

982
const handleAddToCart = (productToAdd) => {
10-
addToCart(productToAdd);
83+
if (productToAdd.inStock > 0) {
84+
const newProductsList = productsList.map((item) =>
85+
productToAdd.sku === item.sku ? { ...item, inStock: item.inStock - 1 } : item
86+
);
87+
addToCart({ productToAdd, newProductsList });
88+
}
1189
};
1290

1391
return (
14-
<div className='Products'>
15-
<div className='Products-items'>
92+
<div className={classes.products}>
93+
<div className={classes.productsItems}>
1694
{productsList.map((product) => (
17-
<div className='Products-item' key={product.sku}>
18-
<img src={product.image} alt={product.name} />
19-
<div className='Products-item-info'>
20-
<h2>
21-
{product.name}
22-
<span>{product.sellingPrice}</span>
23-
</h2>
24-
<p>{product.description}</p>
95+
<div className={classes.productItem} key={product.sku}>
96+
<div className={classes.productItemImg}>
97+
<img src={product.image} alt={product.name} />
98+
</div>
99+
<div className={classes.productItemInfo}>
100+
<div>
101+
<h2>{product.name}</h2>
102+
<p>{product.description}</p>
103+
</div>
104+
<h3>$ {product.sellingPrice}</h3>
25105
</div>
26-
<button type='button' onClick={() => handleAddToCart(product)}>
27-
Comprar
28-
</button>
106+
<Button
107+
fullWidth={true}
108+
color={product.inStock ? 'primary' : 'secondary'}
109+
variant={product.inStock ? 'contained' : 'outlined'}
110+
className={classes.button}
111+
onClick={() => handleAddToCart(product)}
112+
>
113+
<span>{product.inStock ? 'Agregar' : 'Agotado'}</span> <span>[{product.inStock}]</span>
114+
</Button>
29115
</div>
30116
))}
31117
</div>

0 commit comments

Comments
 (0)