|
@@ -26,8 +26,7 @@ import { ListMode } from '../Components/Puestos/ListMode'
|
26
|
26
|
import { GridMode } from '../Components/Puestos/GridMode'
|
27
|
27
|
import { Add as AddIcon, } from '@mui/icons-material/'
|
28
|
28
|
|
29
|
|
-import { Loading } from '../Components/Generics/loading'
|
30
|
|
-import { ErrorMessage } from '../Components/Generics/Error'
|
|
29
|
+import { Centred as Loading } from '../Components/Generics/loading'
|
31
|
30
|
import { useSelector } from 'react-redux';
|
32
|
31
|
|
33
|
32
|
import { useQuery } from 'react-query';
|
|
@@ -43,7 +42,14 @@ export function Puestos() {
|
43
|
42
|
return response;
|
44
|
43
|
}
|
45
|
44
|
|
46
|
|
- const { isLoading, error, data: result } = useQuery('puestos', getAll);
|
|
45
|
+ const { isLoading, error, data: result } = useQuery('puestos', getAll,{
|
|
46
|
+ retry:false,
|
|
47
|
+ cacheTime: 0,
|
|
48
|
+ });
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+console.log(isLoading,result, error)
|
|
52
|
+
|
47
|
53
|
const changePage = useCallback((_, value) => setPage(value), []);
|
48
|
54
|
const [alignment, setAlignment] = React.useState('grid');
|
49
|
55
|
const handleChange = useCallback((_event, newAlignment) => setAlignment(newAlignment), [])
|
|
@@ -91,23 +97,7 @@ export function Puestos() {
|
91
|
97
|
}
|
92
|
98
|
}, [del, show])
|
93
|
99
|
|
94
|
|
-
|
95
|
|
- if (isLoading) {
|
96
|
|
- return (
|
97
|
|
- <Loading />
|
98
|
|
- )
|
99
|
|
- }
|
100
|
|
-
|
101
|
|
- if (error) {
|
102
|
|
- return (
|
103
|
|
- <Paper sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh' }}>
|
104
|
|
- <main id="loading_or_content">
|
105
|
|
- <ErrorMessage />
|
106
|
|
- </main>
|
107
|
|
- </Paper>
|
108
|
|
- )
|
109
|
|
- }
|
110
|
|
- const total_items = Divide(filter ? filter : result.data).length
|
|
100
|
+ const total_items = Divide(filter ? filter : ( result ? result.data: [] )).length
|
111
|
101
|
|
112
|
102
|
return (
|
113
|
103
|
<div className="content-section">
|
|
@@ -140,22 +130,30 @@ export function Puestos() {
|
140
|
130
|
<div style={{ padding: 7 }}>
|
141
|
131
|
<div className={` main_grid_plazas main_productos ${alignment === 'grid' ? 'activar_vista' : 'desactivar_vista'}`} id="grid_view">
|
142
|
132
|
<Row style={{ minHeight: '57vh' }}>
|
143
|
|
- <GridMode
|
144
|
|
- toggle={toggle}
|
145
|
|
- showing={alignment}
|
146
|
|
- data={filter ? Divide(filter) : Divide(result.data)}
|
147
|
|
- index={page - 1}
|
148
|
|
- />
|
|
133
|
+ {isLoading && <Loading />}
|
|
134
|
+ { !error ?
|
|
135
|
+ <GridMode
|
|
136
|
+ toggle={toggle}
|
|
137
|
+ showing={alignment}
|
|
138
|
+ data={filter ? Divide(filter) : Divide(result ? result.data : [])}
|
|
139
|
+ index={page - 1}
|
|
140
|
+ /> : undefined
|
|
141
|
+ }
|
|
142
|
+ {!result && !isLoading && <center><h1>No tienes nigun puesto</h1></center>}
|
149
|
143
|
</Row>
|
150
|
144
|
</div>
|
151
|
145
|
<div className={`main_list_products ${alignment === 'list' ? 'activar_vista' : 'desactivar_vista'}`} id="list_view_products">
|
152
|
146
|
<Row style={{ minHeight: '57vh' }}>
|
153
|
|
- <ListMode
|
154
|
|
- toggle={toggle}
|
155
|
|
- showing={alignment}
|
156
|
|
- data={filter ? Divide(filter) : Divide(result.data)}
|
157
|
|
- index={page - 1}
|
158
|
|
- />
|
|
147
|
+ {isLoading && <Loading />}
|
|
148
|
+ { !error ?
|
|
149
|
+ <ListMode
|
|
150
|
+ toggle={toggle}
|
|
151
|
+ showing={alignment}
|
|
152
|
+ data={filter ? Divide(filter) : Divide(result ? result.data : [])}
|
|
153
|
+ index={page - 1}
|
|
154
|
+ /> : undefined
|
|
155
|
+ }
|
|
156
|
+ {!result && !isLoading && <center><h1>No tienes nigun puesto</h1></center>}
|
159
|
157
|
</Row>
|
160
|
158
|
</div>
|
161
|
159
|
|