Skip to content

Commit

Permalink
feat: secret should be required in production
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPietrusky committed May 28, 2023
1 parent 904320b commit 091fca4
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions src/components/base/secret.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
import {
IconButton,
InputAdornment,
TextField,
TextFieldProps,
} from "@mui/material";
import { IconButton, InputAdornment, TextField, TextFieldProps } from "@mui/material";
import { useState } from "react";
import { Visibility, VisibilityOff } from "@mui/icons-material";

export default function Secret(props: TextFieldProps) {
const { name = "secret", label = "Secret" } = props;
const [showSecret, setShowSecret] = useState(false);
const { name = "secret", label = "Secret", required = false } = props;
const [showSecret, setShowSecret] = useState(false);

const handleShowSecret = () => setShowSecret(!showSecret);
const handleShowSecret = () => setShowSecret(!showSecret);

return (
<TextField
variant="filled"
label={label}
name={name}
type={showSecret ? "text" : "password"}
InputProps={{
endAdornment: (
<InputAdornment position="end">
<IconButton onClick={handleShowSecret}>
{showSecret ? <Visibility /> : <VisibilityOff />}
</IconButton>
</InputAdornment>
),
}}
/>
);
return (
<TextField
variant="filled"
label={label}
name={name}
type={showSecret ? "text" : "password"}
required
InputProps={{
endAdornment: (
<InputAdornment position="end">
<IconButton onClick={handleShowSecret}>
{showSecret ? <Visibility /> : <VisibilityOff />}
</IconButton>
</InputAdornment>
),
}}
/>
);
}

0 comments on commit 091fca4

Please sign in to comment.