diff options
Diffstat (limited to 'client/src/Components/Form.js')
| -rw-r--r-- | client/src/Components/Form.js | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/client/src/Components/Form.js b/client/src/Components/Form.js deleted file mode 100644 index 979d9c9..0000000 --- a/client/src/Components/Form.js +++ /dev/null @@ -1,39 +0,0 @@ -import React, {useState} from 'react'; -import Button from './Button'; -import isURL from "validator/lib/isURL"; - -function Form(props) { - const [state, setState] = useState({value: '', valid: false}); - - const handleSubmit = () => { - if (state.valid) { - props.addRequest(state.value); - } - }; - - const handleChange = e => { - const userInput = e.target.value; - const valid = isURL('https://' + userInput); - setState({value: userInput, valid: valid}); - }; - - const handlePaste = e => { - e.preventDefault(); - const pattern = /^https?:\/\//; - setState({value: e.clipboardData.getData('Text').replace(pattern, ''), valid: false}); - }; - - return ( - <form id="form" onSubmit={(e) => e.preventDefault()}> - <div className="input-group"> - <div className="input-container"> - <span className="input-field-text">https://</span> - <input className="input-field" required value={state.value} onChange={handleChange} onPaste={handlePaste}/> - </div> - <Button valid={state.valid} submit={handleSubmit}/> - </div> - </form> - ) -} - -export default Form; \ No newline at end of file |
