@@ -6,35 +6,50 @@ import { useMutation } from "@tanstack/react-query";
6
6
import { obterOrdersServices } from "./dashboard.service" ;
7
7
import { useEffect } from "react" ;
8
8
import { Article , Section } from "../../shared/components/Article" ;
9
+ import { useDispatch } from "react-redux" ;
10
+ import { dashboardAction } from "./dashboard.state" ;
11
+ import ModalDetalhes from "./modalDetails" ;
9
12
10
13
const Dashboard = ( ) => {
11
14
const obterOrders = useMutation ( { mutationFn : ( ) => obterOrdersServices ( ) } ) ;
15
+ const dispatch = useDispatch ( ) ;
16
+
12
17
useEffect ( ( ) => {
13
18
obterOrders . mutate ( ) ;
14
19
} , [ ] ) ;
15
20
21
+ const handleSelectOrderId = ( orderId : string ) =>
22
+ dispatch ( dashboardAction . setOrderId ( orderId ) ) ;
16
23
return (
17
- < Main >
18
- < TitleStyled > Painel</ TitleStyled >
19
- < SubTitle >
20
- Últimos pedidos{ " " }
21
- < Tooltip title = "Recarregar" >
22
- < Button
23
- onClick = { ( ) => obterOrders . mutate ( ) }
24
- type = "text"
25
- icon = { < IconReloadOutlined /> }
26
- />
27
- </ Tooltip >
28
- </ SubTitle >
29
- < Spin spinning = { obterOrders . isPending } >
30
- < Article >
31
- { obterOrders . data &&
32
- obterOrders . data . map ( ( item ) => (
33
- < Section key = { item . id } > Mesa: { item . table } </ Section >
34
- ) ) }
35
- </ Article >
36
- </ Spin >
37
- </ Main >
24
+ < >
25
+ < Main >
26
+ < TitleStyled > Painel</ TitleStyled >
27
+ < SubTitle >
28
+ Últimos pedidos{ " " }
29
+ < Tooltip title = "Recarregar" >
30
+ < Button
31
+ onClick = { ( ) => obterOrders . mutate ( ) }
32
+ type = "text"
33
+ icon = { < IconReloadOutlined /> }
34
+ />
35
+ </ Tooltip >
36
+ </ SubTitle >
37
+ < Spin spinning = { obterOrders . isPending } >
38
+ < Article >
39
+ { obterOrders . data &&
40
+ obterOrders . data . map ( ( item ) => (
41
+ < Section
42
+ onClick = { ( ) => handleSelectOrderId ( item . id ) }
43
+ key = { item . id }
44
+ >
45
+ Mesa: { item . table }
46
+ </ Section >
47
+ ) ) }
48
+ </ Article >
49
+ </ Spin >
50
+ </ Main >
51
+ < ModalDetalhes />
52
+ </ >
38
53
) ;
39
54
} ;
40
55
0 commit comments