()
| 6 | import 'react-toastify/dist/ReactToastify.css'; |
| 7 | |
| 8 | const Manager = () => { |
| 9 | const ref = useRef() |
| 10 | const passwordRef = useRef() |
| 11 | const [form, setform] = useState({ site: "", username: "", password: "" }) |
| 12 | const [passwordArray, setPasswordArray] = useState([]) |
| 13 | |
| 14 | useEffect(() => { |
| 15 | let passwords = localStorage.getItem("passwords"); |
| 16 | if (passwords) { |
| 17 | setPasswordArray(JSON.parse(passwords)) |
| 18 | } |
| 19 | }, []) |
| 20 | |
| 21 | const copyText = (text) => { |
| 22 | toast('Copied to clipboard!', { |
| 23 | position: "top-right", |
| 24 | autoClose: 5000, |
| 25 | hideProgressBar: false, |
| 26 | closeOnClick: true, |
| 27 | pauseOnHover: true, |
| 28 | draggable: true, |
| 29 | progress: undefined, |
| 30 | theme: "dark", |
| 31 | }); |
| 32 | navigator.clipboard.writeText(text) |
| 33 | } |
| 34 | |
| 35 | |
| 36 | |
| 37 | const showPassword = () => { |
| 38 | passwordRef.current.type = "text" |
| 39 | console.log(ref.current.src) |
| 40 | if (ref.current.src.includes("icons/eyecross.png")) { |
| 41 | ref.current.src = "icons/eye.png" |
| 42 | passwordRef.current.type = "password" |
| 43 | } |
| 44 | else { |
| 45 | passwordRef.current.type = "text" |
| 46 | ref.current.src = "icons/eyecross.png" |
| 47 | } |
| 48 | |
| 49 | } |
| 50 | |
| 51 | const savePassword = () => { |
| 52 | if(form.site.length >3 && form.username.length >3 &&form.password.length >3){ |
| 53 | |
| 54 | setPasswordArray([...passwordArray, {...form, id: uuidv4()}]) |
| 55 | localStorage.setItem("passwords", JSON.stringify([...passwordArray, {...form, id: uuidv4()}])) |
| 56 | console.log([...passwordArray, form]) |
| 57 | setform({ site: "", username: "", password: "" }) |
| 58 | toast('Password saved!', { |
| 59 | position: "top-right", |
| 60 | autoClose: 5000, |
| 61 | hideProgressBar: false, |
| 62 | closeOnClick: true, |
| 63 | pauseOnHover: true, |
| 64 | draggable: true, |
| 65 | progress: undefined, |
nothing calls this directly
no test coverage detected