-
Notifications
You must be signed in to change notification settings - Fork 3
/
Engineer.js
159 lines (150 loc) · 4.74 KB
/
Engineer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import * as React from 'react';
import Avatar from '@mui/material/Avatar';
import Button from '@mui/material/Button';
import CssBaseline from '@mui/material/CssBaseline';
import TextField from '@mui/material/TextField';
import Box from '@mui/material/Box';
import FlightIcon from '@mui/icons-material/Flight';
import Typography from '@mui/material/Typography';
import Container from '@mui/material/Container';
import { createTheme,ThemeProvider } from '@mui/material/styles';
import { useNavigate } from 'react-router-dom';
//install toastify here
import { toast, Toaster } from "react-hot-toast";
import 'react-toastify/dist/ReactToastify.css';
const defaultTheme = createTheme();
function Engineer({state}){
const [fuel,setFuel] = React.useState(null);
const [engine,setEngine] = React.useState(null);
const [inspect,setInspect] = React.useState(null);
const [atc,setAtc] = React.useState(null);
const [emission,setEmission] = React.useState(null);
const [time,setTime] = React.useState(null);
const [id,setId] = React.useState(null);
const navigateTo = useNavigate();
const handleSubmit = async(event)=>{
event.preventDefault();
// const image = 'image1';
// const name = 'flight1';
// const model = 'model1';
// const transaction = await state.contract.addFlights(image,name,model,id);
// await transaction.wait();
// const details="nice flight";
// const duration = "2 hours";
// const stamp = "82hasduif123";
// console.log(details,duration,stamp);
// const transaction = await state.contract.updateFlightLogs(details,duration,stamp,1);
// await transaction.wait();
toast.success('Flight Log added');
setTimeout(()=>{
navigateTo('/')
},4000);
}
return (
<>
<ThemeProvider theme={defaultTheme}>
<Container component="main" maxWidth="xs">
<CssBaseline />
<Box
sx={{
marginTop: 15,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<Avatar sx={{ m: 1, bgcolor: 'primary.main' }}>
<FlightIcon />
</Avatar>
<Typography component="h1" variant="h5">
Enter Flight Logs
</Typography>
<Box component="form" noValidate sx={{ mt: 1 }}>
<TextField
margin="normal"
required
fullWidth
id="Id"
label="Flight Id"
name="Flight Id"
autoFocus
onChange={(e)=>setId(e.target.value)}
/>
<TextField
margin="normal"
required
fullWidth
id="fuel"
label="Fuel Capacity"
name="fuel"
autoFocus
onChange={(e)=>setFuel(e.target.value)}
/>
<TextField
margin="normal"
required
fullWidth
id="engine"
label="Engine Status"
name="engine"
autoFocus
onChange={(e)=>setEngine(e.target.value)}
/>
<TextField
margin="normal"
required
fullWidth
id="inspect"
label="Safety Inspection"
name="inspect"
autoFocus
onChange={(e)=>setInspect(e.target.value)}
/>
<TextField
margin="normal"
required
fullWidth
id="atc"
label="ATC Logs"
name="atc"
autoFocus
onChange={(e)=>setAtc(e.target.value)}
/>
<TextField
margin="normal"
required
fullWidth
id="emission"
label="Emission Records"
name="emission"
autoFocus
onChange={(e)=>setEmission(e.target.value)}
/>
<TextField
margin="normal"
required
fullWidth
id="time"
label="Sign Time"
name="time"
autoFocus
onChange={(e)=>setTime(e.target.value)}
/>
<Button
type="submit"
fullWidth
variant="contained"
sx={{ mt: 3, mb: 2 }}
onClick={handleSubmit}
>
SUBMIT
</Button>
<Toaster toastOptions={{ duration: 4000 }} />
</Box>
</Box>
</Container>
</ThemeProvider>
</>
);
}
export default Engineer;