-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have a user be able to apply as a trainee
- Loading branch information
1 parent
1626be4
commit 0746a47
Showing
6 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { useState, useEffect } from "react"; | ||
import { AiOutlineCheck } from "react-icons/ai"; | ||
import { Link, useNavigate } from "react-router-dom"; | ||
import { verifyEmailAction } from "../redux/actions/verifyEmailAction"; | ||
import { Spin } from "antd"; | ||
import Button from "../components/form/Button"; | ||
|
||
const VerifyEmail = () => { | ||
const [loading, setLoading] = useState(true); | ||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
async function verify() { | ||
try { | ||
const response = await verifyEmailAction(); | ||
|
||
|
||
if (!response?.data?.data?.verifyUser?.isVerified) { | ||
navigate("/login"); | ||
} | ||
} catch (error) { | ||
console.log(error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
} | ||
|
||
verify(); | ||
}, [navigate]); | ||
|
||
|
||
if (loading) { | ||
return ( | ||
<div className="flex items-center justify-center h-screen"> | ||
<Spin size="large" /> | ||
</div> | ||
); | ||
} | ||
|
||
|
||
return <> | ||
<div className="flex items-center justify-center mx-auto bg-[#374151] h-screen"> | ||
<div className="bg-[#1F2A37] w-[30vw] flex h-[70vh] flex-col items-center justify-center rounded-sm sm:w-5/6 lg:w-[45vw]"> | ||
<div | ||
className={`rounded-full flex items-center justify-center p-4 mx-auto mb-4`} | ||
> | ||
<AiOutlineCheck className="text-white text-4xl" /> | ||
</div> | ||
<div className="text-[#afb1b4] text-lg mb-4 font-inter"> | ||
<p>Your account has been succefully verified !</p> | ||
</div> | ||
<Link to="/login" ><Button label="Continue" className="w-[80px]" /></Link> | ||
</div> | ||
</div> | ||
</> | ||
}; | ||
|
||
export default VerifyEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import jwtDecode from "jwt-decode"; | ||
import axios from "./axiosconfig"; | ||
import { toast } from "react-toastify"; | ||
|
||
export const verifyEmailAction = async() => { | ||
try { | ||
const hash = window.location.hash; | ||
|
||
const params = new URLSearchParams(hash.split('?')[1]); | ||
|
||
const token = params.get('token') as any; | ||
const decoded: any = await jwtDecode(token); | ||
const UserId = decoded.data._id | ||
const response = await axios.post("/",{ | ||
query: ` | ||
mutation Mutation($id: ID!) { | ||
verifyUser(ID: $id) { | ||
id | ||
isVerified | ||
} | ||
} | ||
`, variables: { | ||
id:`${UserId}` | ||
} | ||
}) | ||
|
||
return response; | ||
|
||
} catch (error: any) { | ||
toast.error("An error Occured during verification") | ||
return error; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters