node-mongo-demo

node.js and mongodb demo

git clone https://9o.is/git/node-mongo-demo.git

Input.js

(1042B)


      1 import React from "react";
      2 import { TextField, Grid, InputAdornment, IconButton } from "@mui/material";
      3 import Visibility from "@mui/icons-material/Visibility";
      4 import VisibilityOff from "@mui/icons-material/VisibilityOff";
      5 
      6 const Input = ({
      7   name,
      8   value,
      9   handleChange,
     10   label,
     11   half,
     12   autoFocus,
     13   type,
     14   handleShowPassword,
     15 }) => (
     16   <Grid item xs={12} sm={half ? 6 : 12}>
     17     <TextField
     18       name={name}
     19       onChange={handleChange}
     20       variant="outlined"
     21       required
     22       fullWidth
     23       label={label}
     24       autoFocus={autoFocus}
     25       type={type}
     26       value={value}
     27       InputProps={
     28         name === "password" || name === "oldPassword"
     29           ? {
     30             endAdornment: (
     31               <InputAdornment position="end">
     32                 <IconButton onClick={handleShowPassword}>
     33                   {type === "password" ? <Visibility /> : <VisibilityOff />}
     34                 </IconButton>
     35               </InputAdornment>
     36             ),
     37           }
     38           : null
     39       }
     40     />
     41   </Grid>
     42 );
     43 
     44 export default Input;