Browse Source

puestos card mode

amenpunk 2 years ago
parent
commit
4198a3bf57

+ 48 - 0
src/Components/Puestos/Card.jsx

@@ -0,0 +1,48 @@
1
+import * as React from 'react';
2
+import Card from '@mui/material/Card';
3
+import CardActions from '@mui/material/CardActions';
4
+import CardContent from '@mui/material/CardContent';
5
+import CardMedia from '@mui/material/CardMedia';
6
+import Button from '@mui/material/Button';
7
+import Typography from '@mui/material/Typography';
8
+
9
+export function PuestoCard(props) {
10
+
11
+    let {nombre, id, description, data} = props.plaza
12
+    let {edit, suprime, show, set} = props.operations
13
+
14
+    return (
15
+        <Card sx={{ maxWidth: 345 }}>
16
+            <CardMedia
17
+                component="img"
18
+                alt="green iguana"
19
+                height="140"
20
+                image="https://yt3.ggpht.com/ytc/AKedOLRgmxVvijEuMGpaELK2ukM5QGGZYdnLLt065bh4=s900-c-k-c0x00ffffff-no-rj"
21
+                />
22
+            <CardContent>
23
+                <Typography gutterBottom variant="h5" component="div">
24
+                    {nombre}
25
+                </Typography>
26
+                <Typography variant="body2" color="text.secondary">
27
+                    {description}
28
+                    Lizards are a widespread group of squamate reptiles, with over 6,000
29
+                    species, ranging across all continents except Antarctica
30
+                </Typography>
31
+            </CardContent>
32
+            <CardActions>
33
+                <Button size="small" 
34
+                    onClick={() => [set,show].map(fnc => fnc(props.plaza)) }>
35
+                    Ver
36
+                </Button>
37
+                <Button size="small" 
38
+                    onClick={() => [set,edit].map(fnc => fnc(props.plaza))}>
39
+                    Editar
40
+                </Button>
41
+                <Button size="small"
42
+                    onClick={() =>[set,suprime].map(fnc => fnc(props.plaza))} >
43
+                    Eliminar
44
+                </Button>
45
+            </CardActions>
46
+        </Card>
47
+    );
48
+}

+ 17 - 71
src/Components/Puestos/GridMode.jsx

@@ -1,85 +1,31 @@
1 1
 import React from "react";
2
-import NotFound from '../../Images/not_found.png';
3
-
4
-import { 
5
-    RemoveRedEye as RemoveRedEyeIcon,
6
-    Edit as EditIcon,
7
-    HighlightOff as HighlightOffIcon,
8
-} from '@mui/icons-material';
9
-
10 2
 import { Grow } from '@mui/material';
11
-
12
-
13
-import { Row, Col } from 'react-bootstrap'
3
+import { Col } from 'react-bootstrap'
4
+import { PuestoCard } from './Card';
14 5
 
15 6
 export function GridMode(props){
16 7
 
17
-    let { setEdit, setDelete, setShow, setPuesto, data ,index, showing} = props;
8
+    let { setPuesto,setEdit, setDelete, setShow ,data, index, showing} = props;
9
+
10
+    const op ={
11
+        set :setPuesto,
12
+        edit : setEdit,
13
+        suprime : setDelete,
14
+        show : setShow,
15
+    }
18 16
 
19 17
     return(
20 18
         <React.Fragment> 
21 19
             {
22 20
                 data.length && showing === 'grid' ? 
23
-                    data[index].map( (plaza,i) => {
21
+                data[index].map( plaza => {
24 22
                         return(
25
-                        <Grow  
26
-                            in={true}
27
-                            style={{ transformOrigin: '0 0 0' }}
28
-                            timeout={500}
29
-                            key={plaza.id}
30
-                            >
31
-                            <Col  lg="4" md="6" sm="6" xs="12" >
32
-                                <div className="panel">
33
-                                    <Row>
34
-                                        <Col md="4">
35
-                                            <div className="img-container">
36
-                                                <img alt="not found" src={NotFound}/>
37
-                                            </div>
38
-                                        </Col>
39
-                                        <Col md="8">
40
-                                            <div className="info_details">
41
-                                                <p>{ plaza.nombre }</p>
42
-                                                <p>{ plaza.description.slice(0,17) + "..." }</p>
43
-                                            </div>
44
-                                            <div className="btn_interactivos">
45
-
46
-                                                <div className="botones_interactivos">
47
-                                                    <span 
48
-                                                        onClick={ () => {
49
-                                                            setPuesto(plaza)
50
-                                                            setShow(true)
51
-                                                        }} 
52
-                                                        tooltip-location="top" 
53
-                                                        tooltip="Ver plaza">
54
-                                                        <RemoveRedEyeIcon className="grid_btn"/>
55
-                                                    </span>
56
-                                                </div>
57
-                                                <div className="botones_interactivos">
58
-                                                    <span 
59
-                                                        onClick={() => {
60
-                                                            setPuesto(plaza)
61
-                                                            setEdit(true)
62
-                                                        }} 
63
-                                                        tooltip-location="top" 
64
-                                                        tooltip="Editar plaza">
65
-                                                        <EditIcon className="grid_btn"/>
66
-                                                    </span>
67
-                                                </div>
68
-                                                <div className="botones_interactivos">
69
-                                                    <span 
70
-                                                        onClick={() => {
71
-                                                            setPuesto(plaza)
72
-                                                            setDelete(true)
73
-                                                        }} 
74
-                                                        tooltip-location="top" 
75
-                                                        tooltip="Eliminar plaza">
76
-                                                        <HighlightOffIcon className="grid_btn"/>
77
-                                                    </span>
78
-                                                </div>
79
-
80
-                                            </div>
81
-                                        </Col>
82
-                                    </Row>
23
+                        <Grow in={true} style={{ transformOrigin: '0 0 0' }} timeout={500} key={plaza.id} >
24
+                            <Col lg="4" md="6" sm="6" xs="12" >
25
+                                <div style={{ padding: 15 }}>
26
+                                    <PuestoCard 
27
+                                        plaza={plaza}
28
+                                        operations={op} />
83 29
                                 </div>
84 30
                             </Col>
85 31
                         </Grow>

+ 73 - 0
src/Components/Puestos/Material.jsx

@@ -0,0 +1,73 @@
1
+export function material() {
2
+
3
+    /*
4
+
5
+    let { setEdit, setDelete, setShow, setPuesto, data ,index, showing} = props;
6
+
7
+    return(
8
+        <React.Fragment> 
9
+            {
10
+                data.length && showing === 'grid' ? 
11
+                data[index].map( plaza => {
12
+                        return(
13
+                        <Grow  in={true} style={{ transformOrigin: '0 0 0' }} timeout={500} key={plaza.id} >
14
+                            <Col  lg="4" md="6" sm="6" xs="12" >
15
+                                <div className="panel">
16
+                                    <Row>
17
+                                        <Col md="4">
18
+                                            <div className="img-container">
19
+                                                <img alt="not found" src={NotFound}/>
20
+                                            </div>
21
+                                        </Col>
22
+                                        <Col md="8">
23
+                                            <div className="info_details">
24
+                                                <p>{ plaza.nombre }</p>
25
+                                                <p>{ plaza.description.slice(0,17) + "..." }</p>
26
+                                            </div>
27
+                                            <div>
28
+                                                <div className="botones_interactivos">
29
+                                                    <span 
30
+                                                        onClick={ () => {
31
+                                                            setPuesto(plaza)
32
+                                                            setShow(true)
33
+                                                        }} 
34
+                                                        tooltip-location="top" 
35
+                                                        tooltip="Ver plaza">
36
+                                                        <RemoveRedEyeIcon className="grid_btn"/>
37
+                                                    </span>
38
+                                                </div>
39
+                                                <div className="botones_interactivos">
40
+                                                    <span 
41
+                                                        onClick={() => {
42
+                                                            setPuesto(plaza)
43
+                                                            setEdit(true)
44
+                                                        }} 
45
+                                                        tooltip-location="top" 
46
+                                                        tooltip="Editar plaza">
47
+                                                        <EditIcon className="grid_btn"/>
48
+                                                    </span>
49
+                                                </div>
50
+                                                <div className="botones_interactivos">
51
+                                                    <span 
52
+                                                        onClick={() => {
53
+                                                            setPuesto(plaza)
54
+                                                            setDelete(true)
55
+                                                        }} 
56
+                                                        tooltip-location="top" 
57
+                                                        tooltip="Eliminar plaza">
58
+                                                        <HighlightOffIcon className="grid_btn"/>
59
+                                                    </span>
60
+                                                </div>
61
+                                            </div>
62
+                                        </Col>
63
+                                    </Row>
64
+                                </div>
65
+                            </Col>
66
+                        </Grow>
67
+                        )
68
+                }) : <div></div>
69
+            }
70
+        </React.Fragment>
71
+    )
72
+        */
73
+}

+ 2 - 16
src/Css/all.css

@@ -662,21 +662,7 @@ table.dataTable tbody th, table.dataTable tbody td {
662 662
 .img-container img {
663 663
     width: 100%;
664 664
 }
665
-.btn_interactivos{
666
-    padding : 15px;
667
-    display: flex;
668
-    flex-direction: row;
669
-    flex-wrap: nowrap;
670
-    justify-content: space-evenly;
671
-    align-items: center;
672
-    align-content: space-around;
673
-}
674
-.botones_interactivos {
675
-    /* width: 33.33%; */
676
-    float: left;
677
-    text-align: left;
678
-    /* margin: 20px 0 0; */
679
-}
665
+
680 666
 .botones_interactivos i {
681 667
     color: #b9c3ce;
682 668
     transition: all 0.3s;
@@ -826,7 +812,7 @@ table.dataTable tbody th, table.dataTable tbody td {
826 812
     margin : 3px;
827 813
 }
828 814
 .btn_add_producto:hover {
829
-    border: 1px solid #2ec5d3;
815
+    border: 1px solid var(--main);
830 816
     background: transparent;
831 817
     color: #fff;
832 818
     transition: all 0.3s;

+ 6 - 16
src/Pages/Puestos.jsx

@@ -1,19 +1,18 @@
1 1
 import React, { useState, useEffect }  from 'react';
2 2
 import { Row, Col } from 'react-bootstrap'
3
+
3 4
 import toast, { Toaster } from 'react-hot-toast';
4 5
 
5 6
 import { 
6
-    ToggleButton, 
7
-    ToggleButtonGroup, 
8
-    Box,
9
-    Paper,
10
-    Pagination,
7
+    ToggleButton, ToggleButtonGroup, Box,
8
+    Paper, Pagination,
11 9
 } from '@mui/material';
12 10
 
13 11
 import { ViewList as ViewListIcon, ViewModule as ViewModuleIcon, } from '@mui/icons-material';
14 12
 
15 13
 import { default as useAuth } from '../Auth/useAuth';
16 14
 import { Service } from '../Utils/HTTP';
15
+import { Divide } from '../Utils/Paginate';
17 16
 
18 17
 import Express from '../Components/Modal/AgregarExpress';
19 18
 import Manual from '../Components/Modal/AgregarManual';
@@ -26,15 +25,6 @@ import { ListMode } from '../Components/Puestos/ListMode'
26 25
 import { GridMode } from '../Components/Puestos/GridMode'
27 26
 import { Add as AddIcon, } from '@mui/icons-material/'
28 27
 
29
-function Divide(arregloOriginal){
30
-    const LONGITUD_PEDAZOS = 9;
31
-    let arregloDeArreglos = [];
32
-    for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
33
-        let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
34
-        arregloDeArreglos.push(pedazo);
35
-    }
36
-    return arregloDeArreglos
37
-}
38 28
 
39 29
 export function Puestos() {
40 30
 
@@ -130,8 +120,8 @@ export function Puestos() {
130 120
     return (
131 121
         <div className="content-section">
132 122
             <div className="main">
133
-                <Box sx={{ width: '100%' }}>
134
-                    <Paper sx={{ width: '100%', mb: 2, padding : 2, height: '100%', minHeight:'95vh' }}>
123
+                <Box sx={{}}>
124
+                    <Paper sx={{ mb: 2, padding : 2, height: '100%', minHeight:'95vh' }}>
135 125
 
136 126
                         <Row style={{paddingBottom : 15}}>
137 127
                             <Col md="2" sm="2" xs="2">

+ 9 - 0
src/Utils/Paginate.js

@@ -0,0 +1,9 @@
1
+export function Divide(arregloOriginal){
2
+    const LONGITUD_PEDAZOS = 9;
3
+    let arregloDeArreglos = [];
4
+    for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
5
+        let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
6
+        arregloDeArreglos.push(pedazo);
7
+    }
8
+    return arregloDeArreglos
9
+}