|
1 | | -import React from 'react'; |
| 1 | +import React, { useState } from 'react'; |
2 | 2 | import ParentModal from './ParentModal'; |
3 | 3 | import { actionType as T } from '../../reducer'; |
4 | 4 | import './optionsModal.css'; |
5 | 5 |
|
6 | 6 | const OptionsModal = ({ superState, dispatcher }) => { |
| 7 | + const [unlock, setUnlock] = useState(false); |
| 8 | + const [docker, setDocker] = useState(false); |
| 9 | + const [param, setParam] = useState(''); |
| 10 | + const [maxT, setmaxT] = useState(''); |
7 | 11 | const close = () => { |
8 | 12 | dispatcher({ type: T.SET_OPTIONS_MODAL, payload: false }); |
| 13 | + dispatcher( |
| 14 | + { |
| 15 | + type: T.SET_OPTIONS, |
| 16 | + payload: { |
| 17 | + unlock, |
| 18 | + docker, |
| 19 | + maxT, |
| 20 | + param, |
| 21 | + }, |
| 22 | + }, |
| 23 | + ); |
9 | 24 | }; |
| 25 | + |
| 26 | + const handleDockerChange = () => { |
| 27 | + setDocker(!docker); |
| 28 | + }; |
| 29 | + |
| 30 | + const handleUnlockChange = () => { |
| 31 | + setUnlock(!unlock); |
| 32 | + }; |
| 33 | + const handleParamsChange = (e) => { |
| 34 | + setParam(e.target.value); |
| 35 | + }; |
| 36 | + const handleMaxtimeChange = (e) => { |
| 37 | + setmaxT(e.target.value); |
| 38 | + }; |
| 39 | + |
10 | 40 | const Options = 'Options'; |
11 | 41 | return ( |
12 | 42 | <ParentModal closeModal={close} ModelOpen={superState.optionsModal} title={Options}> |
13 | 43 | <div className="main-div"> |
14 | 44 | <label htmlFor="Docker"> |
15 | 45 | Docker |
16 | | - <input type="checkbox" /> |
| 46 | + <input type="checkbox" checked={docker} onChange={handleDockerChange} /> |
17 | 47 | </label> |
18 | 48 | <label htmlFor="Unlock" className="main-div-comp"> |
19 | 49 | Unlock |
20 | | - <input type="checkbox" /> |
| 50 | + <input type="checkbox" checked={unlock} onChange={handleUnlockChange} /> |
21 | 51 | </label> |
22 | 52 | <label htmlFor="Maxtime" className="main-div-comp"> |
23 | 53 | Max Time |
24 | | - <input type="text" /> |
| 54 | + <input |
| 55 | + type="text" |
| 56 | + value={maxT} |
| 57 | + placeholder="Enter Maximum Time" |
| 58 | + onChange={(e) => { |
| 59 | + handleMaxtimeChange(e); |
| 60 | + }} |
| 61 | + /> |
25 | 62 | </label> |
26 | 63 | <br /> |
27 | 64 | <br /> |
28 | 65 | <br /> |
29 | 66 | <span>Params:</span> |
30 | 67 | <br /> |
31 | | - <textarea name="" id="" cols="80" rows="10" /> |
| 68 | + <textarea |
| 69 | + cols="80" |
| 70 | + rows="10" |
| 71 | + value={param} |
| 72 | + placeholder="//Write Script" |
| 73 | + onChange={(e) => { |
| 74 | + handleParamsChange(e); |
| 75 | + }} |
| 76 | + /> |
32 | 77 | </div> |
33 | 78 | </ParentModal> |
34 | 79 | ); |
|
0 commit comments