Compare commits

..

1 Commits

Author SHA1 Message Date
victorAnumudu 59ee61445b shows active resources link when env variable is set to true/1 2023-03-06 14:07:28 +01:00
6 changed files with 15 additions and 109 deletions
+3 -1
View File
@@ -17,4 +17,6 @@ REACT_APP_TRACKING="Tracking"
REACT_APP_RESOURCES="Resources"
REACT_APP_HISTORY="History"
REACT_APP_TRACKING_SHOW=1
REACT_APP_TRACKING_SHOW=1
REACT_APP_RESOURCES_SHOW=1
+2
View File
@@ -18,3 +18,5 @@ REACT_APP_RESOURCES="Resources"
REACT_APP_HISTORY="History"
REACT_APP_TRACKING_SHOW=1
REACT_APP_RESOURCES_SHOW=1
+2
View File
@@ -18,3 +18,5 @@ REACT_APP_RESOURCES="Resources"
REACT_APP_HISTORY="History"
REACT_APP_TRACKING_SHOW=0
REACT_APP_RESOURCES_SHOW=0
+7 -1
View File
@@ -191,11 +191,14 @@ export default function Sidebar({ sidebar, action, logoutModalHandler }) {
</span>
</NavLink>
</li>
{process.env.REACT_APP_RESOURCES_SHOW == 1 ?
<li className="item group">
<NavLink
to="/resources"
className={`nav-item flex items-center ${
((navData) => (navData.isActive ? "active" : ""),
(
(navData) => (navData.isActive ? "active" : ""),
sidebar ? "justify-start space-x-3.5" : "justify-center")
}`}
>
@@ -211,6 +214,9 @@ export default function Sidebar({ sidebar, action, logoutModalHandler }) {
</span>
</NavLink>
</li>
:
null
}
<li className="item group">
<NavLink
@@ -3,8 +3,6 @@
import React, { useState } from "react";
import Icons from "../../Helpers/Icons";
import PasswordSvg from "../PasswordSvg";
import { toast } from "react-toastify";
import usersService from "../../../services/UsersService";
export default function ChangePasswordTab() {
const [oldPass, setOldPass] = useState("hide-password");
@@ -40,95 +38,6 @@ export default function ChangePasswordTab() {
}
}
};
// Reset Password
const reset_profilePass = new usersService()
const [loading, setLoading] = useState(false)
const [validation, setValidation] = useState("")
// state for password values
const [passwordDetails, setPasswordDetails] = useState({
prev_pass: '',
new_pass: '',
confirm_pass: ''
})
// tracks password changes
const handlePasswordChange = ({target:{name, value}}) => {
setPasswordDetails(prev => ({...prev, [name]:value}))
}
const handleResetPassword = async(e) => {
setValidation("")
setLoading(true)
let resetPassword = {...passwordDetails}
let {prev_pass, new_pass, confirm_pass} = resetPassword
// Check empty fields
if(!prev_pass || !new_pass || !confirm_pass) {
setLoading(false)
setValidation("Please fill the empty fields")
return
}
// Checking to see the password has
if(!/^[A-Za-z]\w{6,14}$/.test(new_pass)) {
setLoading(false)
setValidation("it must be a more 7 alphanumeric characters")
return
}
// matching new passwords with confirm_password
if(new_pass != confirm_pass){
setLoading(false)
setValidation("new password does not match")
return
}
// matching new passwords with old passwords
if(prev_pass === new_pass){
setLoading(false)
setValidation("you can't use old passwords")
return
}
// assigning new values to resetPassword
resetPassword.member_id = localStorage.getItem("member_id")
resetPassword.session_token = localStorage.getItem("session_token")
resetPassword.member_uuid = localStorage.getItem("member_uuid")
// removed confirm password from the payload
delete resetPassword.confirm_pass
try {
const res = await reset_profilePass.resetProfilePassword(resetPassword)
console.log(res)
if(res.status != 200){
setLoading(false)
setValidation("An error occurred")
return
}
if(res.status == 200){
// if status is okay but can't success not granted
if(res.data.status < 0 ) {
setLoading(false)
setValidation("sorry, error updating password")
} else {
setLoading(false)
// setValidation("password updated successfully")
toast.success("password updated successfully")
// setPasswordDetails(prev => ({...prev, e.target.name: ''}))
}
}
} catch (error) {
setLoading(false)
setValidation("something went wrong, try again later")
}
}
return (
<div className="changePasswordTab w-full">
<div className="w-full flex xl:flex-row flex-col-reverse space-x-5 xl:items-center">
@@ -149,9 +58,6 @@ export default function ChangePasswordTab() {
className="input-field placeholder:text-base text-bese px-12 text-dark-gray dark:text-white w-full h-full bg-[#FAFAFA] dark:bg-[#11131F] focus:ring-0 focus:outline-none"
type="password"
id="old_password"
name='prev_pass'
value={passwordDetails.prev_pass}
onChange={handlePasswordChange}
/>
<div
className="absolute right-6 bottom-[17px] z-10 cursor-pointer"
@@ -177,9 +83,6 @@ export default function ChangePasswordTab() {
className="input-field placeholder:text-base text-bese px-12 text-dark-gray dark:text-white w-full h-full bg-[#FAFAFA] dark:bg-[#11131F] focus:ring-0 focus:outline-none"
type="password"
id="new_password"
name="new_pass"
value={passwordDetails.new_pass}
onChange={handlePasswordChange}
/>
<div
className="absolute right-6 bottom-[17px] z-10 cursor-pointer"
@@ -205,9 +108,6 @@ export default function ChangePasswordTab() {
className="input-field placeholder:text-base text-bese px-12 text-dark-gray dark:text-white w-full h-full bg-[#FAFAFA] dark:bg-[#11131F] focus:ring-0 focus:outline-none"
type="password"
id="confirm_password"
name="confirm_pass"
value={passwordDetails.confirm_pass}
onChange={handlePasswordChange}
/>
<div
className="absolute right-6 bottom-[17px] z-10 cursor-pointer"
@@ -217,7 +117,6 @@ export default function ChangePasswordTab() {
</div>
</div>
</div>
{validation && <p className={`my-5 text-center font-light italic text-sm subpixel-antialiased tracking-wide ${validation == 'Password updated' ? 'text-green-600' : 'text-red-500'} `}>{validation}</p>}
<div className="flex justify-center space-x-4 items-center">
<button
type="button"
@@ -228,10 +127,9 @@ export default function ChangePasswordTab() {
<button
type="button"
className="btn-gradient tracking-wide rounded-full w-[173px] h-[46px] flex justify-center items-center"
onClick={handleResetPassword}
>
<span className="font-thin text-18 tracking-wide antialiased text-white">
{loading ? <div className="signup btn-loader"></div> : <span>Change Password</span>}
Change Password
</span>
</button>
</div>
-4
View File
@@ -10,10 +10,6 @@ class usersService {
return this.postAuxEnd('/resetpass', reqData);
}
resetProfilePassword(reqData){
return this.postAuxEnd('/resetpass-profile', reqData);
}
logInUser(reqData) {
localStorage.setItem("session_token", ``);
return this.postAuxEnd("/login", reqData);