|
@@ -0,0 +1,78 @@
|
|
1
|
+import * as React from 'react';
|
|
2
|
+
|
|
3
|
+import { Edit as EditIcon, Send as SendIcon } from '@mui/icons-material'
|
|
4
|
+import {
|
|
5
|
+ Button, Dialog, DialogActions, DialogContent,
|
|
6
|
+ DialogContentText, DialogTitle
|
|
7
|
+} from '@mui/material'
|
|
8
|
+
|
|
9
|
+import { useQuery } from 'react-query'
|
|
10
|
+import { Service } from '../../Utils/HTTP.js'
|
|
11
|
+import useAuth from '../../Auth/useAuth.js';
|
|
12
|
+
|
|
13
|
+export function Operation(props) {
|
|
14
|
+
|
|
15
|
+ let [open, setOpen] = React.useState(false);
|
|
16
|
+ const handleOpen = (status) => setOpen(status);
|
|
17
|
+
|
|
18
|
+ return (
|
|
19
|
+ <div>
|
|
20
|
+ <div className="operation_buttons">
|
|
21
|
+ <EditIcon onClick={() => setOpen(true)} className="icon_op" />
|
|
22
|
+ <SendIcon className="icon_op" />
|
|
23
|
+ </div>
|
|
24
|
+ {
|
|
25
|
+ open ?
|
|
26
|
+ <ModalEdit
|
|
27
|
+ password={props}
|
|
28
|
+ open={open}
|
|
29
|
+ handleOpen={handleOpen}
|
|
30
|
+ />
|
|
31
|
+ : null
|
|
32
|
+ }
|
|
33
|
+ </div>
|
|
34
|
+ )
|
|
35
|
+}
|
|
36
|
+
|
|
37
|
+function ModalEdit(props) {
|
|
38
|
+
|
|
39
|
+ let { password, open, handleOpen} = props
|
|
40
|
+ let { pwd, plz } = password
|
|
41
|
+ const auth = useAuth();
|
|
42
|
+ const token = React.useRef(auth.getToken());
|
|
43
|
+ const getPassword = async () => {
|
|
44
|
+ let rest = new Service(`/contrasenia/${pwd}/${plz}`)
|
|
45
|
+ return await rest.getQuery(token.current)
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ let { data, status, } = useQuery('contra', getPassword);
|
|
49
|
+ console.log(data, status)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+ return (
|
|
53
|
+ <Dialog
|
|
54
|
+ open={open}
|
|
55
|
+ onClose={() => handleOpen(false)}
|
|
56
|
+ aria-labelledby="alert-dialog-title"
|
|
57
|
+ aria-describedby="alert-dialog-description"
|
|
58
|
+ >
|
|
59
|
+ <DialogTitle id="alert-dialog-title">
|
|
60
|
+ {pwd}
|
|
61
|
+ </DialogTitle>
|
|
62
|
+ <DialogContent>
|
|
63
|
+ <DialogContentText id="alert-dialog-description">
|
|
64
|
+ Let Google help apps determine location. This means sending anonymous
|
|
65
|
+ location data to Google, even when no apps are running.
|
|
66
|
+ </DialogContentText>
|
|
67
|
+ </DialogContent>
|
|
68
|
+ <DialogActions>
|
|
69
|
+ <Button onClick={() => handleOpen(false)}>Disagree</Button>
|
|
70
|
+ <Button onClick={() => handleOpen(false)} autoFocus>
|
|
71
|
+ Agree
|
|
72
|
+ </Button>
|
|
73
|
+ </DialogActions>
|
|
74
|
+ </Dialog>
|
|
75
|
+ )
|
|
76
|
+}
|
|
77
|
+
|
|
78
|
+
|