varun_coder

master and student

Jan 20th, 2023
1,574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useState } from 'react';
  2. import { useHistory } from 'react-router-dom';
  3.  
  4. function Signup() {
  5.   const [userType, setUserType] = useState('');
  6.   const [username, setUsername] = useState('');
  7.   const [password, setPassword] = useState('');
  8.   const history = useHistory();
  9.  
  10.   function handleSignup() {
  11.     // send a request to the server to sign up the user
  12.     // handle success or failure
  13.     history.push('/');
  14.   }
  15.  
  16.   return (
  17.     <div>
  18.       <h1>Sign Up</h1>
  19.       <label>
  20.         User Type:
  21.         <select value={userType} onChange={e => setUserType(e.target.value)}>
  22.           <option value="master">Master</option>
  23.           <option value="student">Student</option>
  24.         </select>
  25.       </label>
  26.       <br />
  27.       <label>
  28.         Username:
  29.         <input
  30.           type="text"
  31.           value={username}
  32.           onChange={e => setUsername(e.target.value)}
  33.         />
  34.       </label>
  35.       <br />
  36.       <label>
  37.         Password:
  38.         <input
  39.           type="password"
  40.           value={password}
  41.           onChange={e => setPassword(e.target.value)}
  42.         />
  43.       </label>
  44.       <br />
  45.       <button onClick={handleSignup}>Sign Up</button>
  46.     </div>
  47.   );
  48. }
  49.  
  50. function Login() {
  51.   const [username, setUsername] = useState('');
  52.   const [password, setPassword] = useState('');
  53.   const history = useHistory();
  54.  
  55.   function handleLogin() {
  56.     // send a request to the server to log in the user
  57.     // handle success or failure
  58.     history.push('/');
  59.   }
  60.  
  61.   return (
  62.     <div>
  63.       <h1>Log In</h1>
  64.       <label>
  65.         Username:
  66.         <input
  67.           type="text"
  68.           value={username}
  69.           onChange={e => setUsername(e.target.value)}
  70.         />
  71.       </label>
  72.       <br />
  73.       <label>
  74.         Password:
  75.         <input
  76.           type="password"
  77.           value={password}
  78.           onChange={e => setPassword(e.target.value)}
  79.         />
  80.       </label>
  81.       <br />
  82.       <button onClick={handleLogin}>Log In</button>
  83.     </div>
  84.   );
  85. }
  86.  
  87. function Master() {
  88.   const [input, setInput] = useState('');
  89.   const [output, setOutput] = useState('');
  90.  
  91.   function handleInputChange(e) {
  92.     setInput(e.target.value);
  93.   }
  94.  
  95.   function handleOutputChange(e) {
  96.     setOutput(e.target.value);
  97.   }
  98.  
  99.   function handleSubmit() {
  100.     // send input and output to the server
  101.     //
  102.  
Advertisement
Add Comment
Please, Sign In to add comment