-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewPassword.js
58 lines (51 loc) · 1.48 KB
/
NewPassword.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React,{useState} from 'react'
import {useNavigate,useParams} from 'react-router-dom'
import M from 'materialize-css'
const SignIn = ()=>{
const navigate = useNavigate()
const [password,setPasword] = useState("")
const {token} = useParams()
const PostData = ()=>{
fetch("/new-password",{
method:"post",
headers:{
"Content-Type":"application/json"
},
body:JSON.stringify({
password,
token
})
}).then(res=>res.json())
.then(data=>{
console.log(data)
if(data.error){
M.toast({html: data.error,classes:"#c62828 red darken-3"})
}
else{
M.toast({html:data.message,classes:"#43a047 green darken-1"})
navigate('/login')
}
}).catch(err=>{
console.log(err)
})
}
return (
<div className="mycard">
<div className="card auth-card input-field">
<h2>Zaayka</h2>
<input
type="password"
placeholder="enter a new password"
value={password}
onChange={(e)=>setPasword(e.target.value)}
/>
<button className="btn waves-effect waves-light #64b5f6 blue darken-1"
onClick={()=>PostData()}
>
Update password
</button>
</div>
</div>
)
}
export default SignIn