Compare commits

..

18 Commits

Author SHA1 Message Date
victorAnumudu 9b6c5b72ad changed cancel btn style 2023-10-22 05:52:47 +01:00
ameye afc5e25cfc Merge branch 'login-captcha' of WrenchBoard/Users-Wrench into master 2023-10-17 17:40:06 +00:00
victorAnumudu 58fe5eb82c captcha added in login page 2023-10-17 18:26:46 +01:00
CHIEFSOFT\ameye 2f3fdc0695 google captach settings 2023-10-17 07:01:05 -04:00
ameye 0a465fceb0 Merge branch 'btn-height-adjustment' of WrenchBoard/Users-Wrench into master 2023-10-16 20:26:23 +00:00
victorAnumudu 5e968db2f5 adjusted btn height 2023-10-16 21:08:06 +01:00
ameye 1916bc1a65 Merge branch 'btn-rename' of WrenchBoard/Users-Wrench into master 2023-10-16 18:41:55 +00:00
ameye 1103127cae Merge branch 'btn-customized' of WrenchBoard/Users-Wrench into master 2023-10-16 18:41:47 +00:00
ameye 751369071c Merge branch 'family-task-reload' of WrenchBoard/Users-Wrench into master 2023-10-16 18:41:39 +00:00
ameye 4cc8f27c14 Merge branch 'profile-upload-revert' of WrenchBoard/Users-Wrench into master 2023-10-16 18:41:07 +00:00
ameye aab455c2c3 Merge branch 'Changed-Naira-Wallet-Country-Display' of WrenchBoard/Users-Wrench into master 2023-10-16 13:52:03 +00:00
Ebube 21843c4bc7 Changed Naira Wallet Country Display 2023-10-16 13:43:48 +01:00
Ebube 8702728ffa Merge branch 'master' of https://gitlab.chiefsoft.net/WrenchBoard/Users-Wrench into Recent-Activities 2023-10-16 13:12:24 +01:00
victorAnumudu a8416a8433 made family page to reload after adding a task 2023-10-10 10:17:22 +01:00
victorAnumudu 70c9d1778c renamed edit job btn to save 2023-10-10 07:02:52 +01:00
Ebube 930559c96b Family Picture 2023-10-09 13:32:07 +01:00
victorAnumudu c4af2dfcc8 changed timeout duration 2023-10-09 11:29:11 +01:00
victorAnumudu b186549b8d added profile upload API 2023-10-09 11:22:38 +01:00
19 changed files with 253 additions and 90 deletions
+2 -1
View File
@@ -90,4 +90,5 @@ REACT_APP_SHOW_OFFER_GROUP_JOB=0
REACT_APP_SHOW_UPLOAD_PROFILE_PICTURE=0 REACT_APP_SHOW_UPLOAD_PROFILE_PICTURE=0
#GOOGLE RECAPTCHA SITEKEY #GOOGLE RECAPTCHA SITEKEY
REACT_APP_GOOGLE_RECAPTCHA_SITEKEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI REACT_APP_GOOGLE_RECAPTCHA_SITEKEY=6Ld_qKooAAAAADNL1TPzRLmcBA8vlpvx__39Rj39
#6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
+2 -1
View File
@@ -58,4 +58,5 @@ REACT_APP_SHOW_OFFER_GROUP_JOB=0
REACT_APP_SHOW_UPLOAD_PROFILE_PICTURE=0 REACT_APP_SHOW_UPLOAD_PROFILE_PICTURE=0
#GOOGLE RECAPTCHA SITEKEY #GOOGLE RECAPTCHA SITEKEY
REACT_APP_GOOGLE_RECAPTCHA_SITEKEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI REACT_APP_GOOGLE_RECAPTCHA_SITEKEY=6Ld_qKooAAAAADNL1TPzRLmcBA8vlpvx__39Rj39
#6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
+2 -1
View File
@@ -64,4 +64,5 @@ REACT_APP_SHOW_OFFER_GROUP_JOB=0
REACT_APP_SHOW_UPLOAD_PROFILE_PICTURE=0 REACT_APP_SHOW_UPLOAD_PROFILE_PICTURE=0
#GOOGLE RECAPTCHA SITEKEY #GOOGLE RECAPTCHA SITEKEY
REACT_APP_GOOGLE_RECAPTCHA_SITEKEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI REACT_APP_GOOGLE_RECAPTCHA_SITEKEY=6Ld_qKooAAAAADNL1TPzRLmcBA8vlpvx__39Rj39
#6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
@@ -24,7 +24,7 @@ const ForgetPwdResponse = ({title, message, type}) => {
<button <button
type="button" type="button"
onClick={() => navigate("/login")} onClick={() => navigate("/login")}
className={`rounded-[0.475rem] mb-6 text-[15px] font-semibold text-white flex justify-center bg-[#4687ba] hover:bg-[#009ef7] transition-all duration-300 items-center py-[0.8875rem] px-[1.81rem]`} className={`h-[48px] rounded-full mb-6 text-[15px] font-semibold text-white flex justify-center bg-[#4687ba] hover:bg-[#009ef7] transition-all duration-300 items-center py-[0.8875rem] px-[1.81rem]`}
> >
<span>Home</span> <span>Home</span>
</button> </button>
@@ -176,14 +176,14 @@ export default function ForgotPassword() {
<button <button
type="button" type="button"
onClick={() => navigate("/login")} onClick={() => navigate("/login")}
className={`rounded-full mb-6 text-[15px] font-semibold text-white hover:text-white flex justify-center bg-red-500 hover:bg-red-600 transition-all duration-300 items-center py-[0.8875rem] px-[1.8125rem] `} className={`h-[48px] rounded-full mb-6 text-[15px] font-semibold text-white hover:text-white flex justify-center bg-red-500 hover:bg-red-600 transition-all duration-300 items-center py-[0.8875rem] px-[1.8125rem] `}
> >
Cancel Cancel
</button> </button>
<button <button
type="button" type="button"
onClick={resetHandler} onClick={resetHandler}
className={`rounded-full mb-6 text-[15px] font-semibold text-white flex justify-center bg-[#4687ba] hover:bg-[#009ef7] transition-all duration-300 items-center py-[0.8875rem] px-[1.81rem]`} className={`h-[48px] rounded-full mb-6 text-[15px] font-semibold text-white flex justify-center bg-[#4687ba] hover:bg-[#009ef7] transition-all duration-300 items-center py-[0.8875rem] px-[1.81rem]`}
> >
{resetLoading ? ( {resetLoading ? (
<div className="signup btn-loader"></div> <div className="signup btn-loader"></div>
+33
View File
@@ -14,10 +14,14 @@ import { useGoogleLogin } from "@react-oauth/google";
import { useDispatch } from "react-redux"; import { useDispatch } from "react-redux";
import { updateUserDetails } from "../../../store/UserDetails"; import { updateUserDetails } from "../../../store/UserDetails";
import ReCAPTCHA from "react-google-recaptcha";
export default function Login() { export default function Login() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { state } = useLocation(); const { state } = useLocation();
const [validCaptcha, setValidCaptcha] = useState({show: false, valid:''}); // FOR CAPTCHA
let [loginType, setLoginType] = useState(""); let [loginType, setLoginType] = useState("");
const [loginLoading, setLoginLoading] = useState(false); const [loginLoading, setLoginLoading] = useState(false);
@@ -107,6 +111,14 @@ export default function Login() {
}, Number(process.env.REACT_APP_LOGIN_ERROR_TIMEOUT)); }, Number(process.env.REACT_APP_LOGIN_ERROR_TIMEOUT));
return; return;
} }
if(name == "full" && !validCaptcha.valid && validCaptcha.show){ // RUNS AND DISPLAYS CAPTCHA, IF ERROR OCCURED DURING LOGIN FOR FULL LOGIN ALONE
setMsgError("Please Verify Captcha");
setLoginLoading(false);
setTimeout(() => {
setMsgError("");
}, Number(process.env.REACT_APP_LOGIN_ERROR_TIMEOUT));
return;
}
userApi userApi
.logInUser(postData) .logInUser(postData)
.then((res) => { .then((res) => {
@@ -120,6 +132,7 @@ export default function Login() {
// setMsgError("Wrong, email/password"); // setMsgError("Wrong, email/password");
setLoginError(true); setLoginError(true);
setLoginLoading(false); setLoginLoading(false);
setValidCaptcha(prev => ({...prev, show:true})) // DISPLAYS CAPTCHA IF ERROR
return; return;
} }
localStorage.setItem("member_id", `${res.data.member_id}`); localStorage.setItem("member_id", `${res.data.member_id}`);
@@ -135,6 +148,7 @@ export default function Login() {
.catch((error) => { .catch((error) => {
setMsgError("Unable to login, try again"); setMsgError("Unable to login, try again");
setLoginLoading(false); setLoginLoading(false);
setValidCaptcha(prev => ({...prev, show:true})) // DISPLAYS CAPTCHA IF ERROR
}) })
.finally(() => { .finally(() => {
setTimeout(() => { setTimeout(() => {
@@ -145,6 +159,14 @@ export default function Login() {
}); });
}; };
function captchaChecker(value) { // FUNCTION TO VALIDATE CAPTCHA
if(value){
setValidCaptcha({show: true, valid:value})
}else{
setValidCaptcha({show: true, valid:''})
}
}
const googleLogin = useGoogleLogin({ const googleLogin = useGoogleLogin({
flow: "auth-code", flow: "auth-code",
ux_mode: "redirect", ux_mode: "redirect",
@@ -296,6 +318,17 @@ export default function Login() {
forgotPassword forgotPassword
/> />
</div> </div>
{/* hCaptha clone for the time being */}
{validCaptcha.show &&
<div className="mb-5 flex justify-center w-full">
<ReCAPTCHA
sitekey={process.env.REACT_APP_GOOGLE_RECAPTCHA_SITEKEY}
onChange={captchaChecker}
/>
</div>
}
{loginError && ( {loginError && (
<div className="relative p-4 text-[#912741] bg-[#fcd9e2] border-[#fbc6d3] mb-4 rounded-[0.475rem] text-md font-thin leading-[19.5px] text-[13px]"> <div className="relative p-4 text-[#912741] bg-[#fcd9e2] border-[#fbc6d3] mb-4 rounded-[0.475rem] text-md font-thin leading-[19.5px] text-[13px]">
Invalid username or password- Please{" "} Invalid username or password- Please{" "}
+25 -7
View File
@@ -7,7 +7,7 @@ import React, {
useState, useState,
} from "react"; } from "react";
import { useReactToPrint } from "react-to-print"; import { useReactToPrint } from "react-to-print";
import profile from "../../assets/images/profile-info-profile.png"; import profile from "../../assets/images/icons/family.svg";
import localImgLoad from "../../lib/localImgLoad"; import localImgLoad from "../../lib/localImgLoad";
import usersService from "../../services/UsersService"; import usersService from "../../services/UsersService";
import LoadingSpinner from "../Spinners/LoadingSpinner"; import LoadingSpinner from "../Spinners/LoadingSpinner";
@@ -51,6 +51,8 @@ export default function FamilyManageTabs({
}); });
}; };
const [updatePage, setUpdatePage] = useState(false) // State to determine when to update the page
// State for family task data // State for family task data
const [familyTask, setFamilyTask] = useState({ loading: false, data: [] }); const [familyTask, setFamilyTask] = useState({ loading: false, data: [] });
@@ -82,14 +84,29 @@ export default function FamilyManageTabs({
profileImgInput.current.click(); profileImgInput.current.click();
}; };
// Function to handle changes in the profile image input /**
* Handles the change event of the profile image input field.
* Checks if the selected file exceeds the maximum file size limit and displays an alert if it does.
* If the file is within the size limit, it reads the file using the FileReader API and sets the profile image state with the result.
*/
const profileImgChangeHandler = (e) => { const profileImgChangeHandler = (e) => {
if (e.target.value !== "") { const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
const file = e.target.files[0];
if (file && file.size > MAX_FILE_SIZE) {
alert("File size exceeds the limit.");
return;
}
if (file) {
const imgReader = new FileReader(); const imgReader = new FileReader();
imgReader.onload = (event) => { imgReader.onload = () => {
setProfileImg(event.target.result); const imageDataUrl = imgReader.result;
// Set the profile image
setProfileImg(imageDataUrl);
}; };
imgReader.readAsDataURL(e.target.files[0]); imgReader.readAsDataURL(file);
} }
}; };
@@ -220,7 +237,7 @@ export default function FamilyManageTabs({
// Invoke the manageFamily function when the component mounts // Invoke the manageFamily function when the component mounts
manageFamily(); manageFamily();
}, []); }, [updatePage]);
// Effect to manage family tasks // Effect to manage family tasks
useEffect(() => { useEffect(() => {
@@ -356,6 +373,7 @@ export default function FamilyManageTabs({
setActiveTask={setActiveTask} setActiveTask={setActiveTask}
activeTask={activeTask} activeTask={activeTask}
familyDetailsData={details.familyDetails.data} familyDetailsData={details.familyDetails.data}
setUpdatePage={setUpdatePage}
/> />
)} )}
</div> </div>
@@ -15,6 +15,7 @@ const AssignTaskPopout = React.memo(
familyTask, familyTask,
activeTask, activeTask,
setActiveTask, setActiveTask,
setUpdatePage
}) => { }) => {
const apiCall = new usersService(); const apiCall = new usersService();
@@ -143,6 +144,7 @@ const AssignTaskPopout = React.memo(
status: true, status: true,
message: "action successful", message: "action successful",
}); });
setUpdatePage(prev => !prev) // Updates family task page by calling the useeffect hook
setTimeout(() => { setTimeout(() => {
setRequestStatus({ loading: false, status: false, message: "" }); setRequestStatus({ loading: false, status: false, message: "" });
action(); // FUNCTION THAT CLOSES THE MODAL BOX action(); // FUNCTION THAT CLOSES THE MODAL BOX
+10 -5
View File
@@ -1,26 +1,31 @@
import React from "react"; import React from "react";
import localImgLoad from "../../../lib/localImgLoad"; import localImgLoad from "../../../lib/localImgLoad";
export default function ProfileInfo({ export default function ProfileInfo({
profileImg, profileImg,
profileImgInput, profileImgInput,
profileImgChangHandler, profileImgChangeHandler,
browseProfileImg, browseProfileImg,
accountDetails, accountDetails,
}) { }) {
// console.log(accountDetails.banner)
return ( return (
<div className="flex flex-col items-center gap-4"> <div className="flex flex-col items-center gap-4">
<div className="flex justify-center"> <div className="flex justify-center">
<div className="w-full relative"> <div className="w-full relative">
<img <img
src={localImgLoad(`images/icons/${accountDetails.banner}`)} src={
alt="" profileImg
? profileImg
: localImgLoad(`images/icons/${accountDetails.banner}`)
}
alt="profile"
className="sm:w-[180px] sm:h-[180px] w-[120px] h-[120px] rounded-full overflow-hidden object-cover" className="sm:w-[180px] sm:h-[180px] w-[120px] h-[120px] rounded-full overflow-hidden object-cover"
/> />
<input <input
ref={profileImgInput} ref={profileImgInput}
onChange={(e) => profileImgChangHandler(e)} accept="image/*"
onChange={profileImgChangeHandler}
type="file" type="file"
className="hidden" className="hidden"
/> />
@@ -225,7 +225,7 @@ const MarketPopUp = ({ details, onClose, situation, marketInt }) => {
</div> </div>
</div> </div>
<div className="w-full md:w-[23%] h-full "> <div className="w-full md:w-[23%] h-full flex flex-col">
<div className="mx-auto bg-[#f1f8ff] dark:bg-[#C2C8D3] p-4 rounded-md md:min-h-[498px] flex flex-col justify-between"> <div className="mx-auto bg-[#f1f8ff] dark:bg-[#C2C8D3] p-4 rounded-md md:min-h-[498px] flex flex-col justify-between">
<div className="w-full flex flex-col justify-center py-4 gap-2"> <div className="w-full flex flex-col justify-center py-4 gap-2">
<p className="w-full text-slate-900 tracking-wide my-1"> <p className="w-full text-slate-900 tracking-wide my-1">
@@ -270,7 +270,7 @@ const MarketPopUp = ({ details, onClose, situation, marketInt }) => {
</div> </div>
</div> </div>
<button <button
className="self-end w-[150px] mt-2 h-[52px] rounded-md text-base bg-transparent border border-red-500 text-red-500 mx-auto" className="self-center w-[150px] mt-2 h-[48px] rounded-full text-base bg-transparent border border-red-500 text-red-500 mx-auto"
name="cancel" name="cancel"
onClick={onClose} onClick={onClose}
> >
@@ -118,7 +118,11 @@ function PastDueJobAction({jobDetails}) {
<tr> <tr>
<td> <td>
<div className="flex justify-center items-center"> <div className="flex justify-center items-center">
<button type="button" onClick={popUpHandler} className="w-[180px] h-11 flex justify-center items-center btn-gradient text-base rounded-full text-white"> <button
type="button"
onClick={popUpHandler}
className="px-4 h-[48px] flex justify-center items-center btn-gradient text-base rounded-full text-white"
>
Cancel or Extend Timeline Cancel or Extend Timeline
</button> </button>
</div> </div>
@@ -230,8 +234,12 @@ function PastDueJobAction({jobDetails}) {
{/* cancel btn */} {/* cancel btn */}
<div className='flex justify-end items-center'> <div className='flex justify-end items-center'>
<button onClick={popUpHandler} type="button" className="w-20 h-11 flex justify-center items-center border-gradient text-base rounded-full text-white"> <button onClick={popUpHandler} type="button"
<span className='text-gradient'>Cancel</span> // className="w-20 h-11 flex justify-center items-center border-gradient text-base rounded-full text-white"
className='w-[150px] mt-2 h-[48px] rounded-full text-base bg-transparent border border-red-500 text-red-500'
>
Cancel
{/* <span className='text-gradient'>Cancel</span> */}
</button> </button>
</div> </div>
</div> </div>
+44 -52
View File
@@ -12,8 +12,7 @@ function NairaWithdraw({
state, state,
setShowConfirmNairaWithdraw, setShowConfirmNairaWithdraw,
}) { }) {
let MaxNoOfBanks = process.env.REACT_APP_MAX_CREDIT_BANK_ACCOUNT; // HOLDS THE VALUE OF THE MAX NUMBER OF BANKS USER CAN ADD
let MaxNoOfBanks = process.env.REACT_APP_MAX_CREDIT_BANK_ACCOUNT // HOLDS THE VALUE OF THE MAX NUMBER OF BANKS USER CAN ADD
const apiCall = new usersService(); const apiCall = new usersService();
const [tab, setTab] = useState("previous"); const [tab, setTab] = useState("previous");
let [requestStatus, setRequestStatus] = useState(false); let [requestStatus, setRequestStatus] = useState(false);
@@ -25,7 +24,9 @@ function NairaWithdraw({
recipientID: state?.previousAccount?.recipientID || "", recipientID: state?.previousAccount?.recipientID || "",
}, },
newAccount: { newAccount: {
country: state?.newAccount?.amount || "", country: wallet.walletCountry
? wallet.walletCountry[0][0]
: wallet.country,
bank: state?.newAccount?.amount || "", bank: state?.newAccount?.amount || "",
accountNumber: state?.newAccount?.amount || "", accountNumber: state?.newAccount?.amount || "",
accountType: state?.newAccount?.amount || "", accountType: state?.newAccount?.amount || "",
@@ -67,10 +68,14 @@ function NairaWithdraw({
// Handling card change // Handling card change
const handleBankOptions = (event) => { const handleBankOptions = (event) => {
const { value } = event.target; let bankCountry = wallet.walletCountry
? wallet.walletCountry[0][0]
: wallet.country
setBankName((prev) => ({ loading: true, data: [] })); setBankName((prev) => ({ loading: true, data: [] }));
apiCall apiCall
.getCountryBank({ country: value }) .getCountryBank({
country: bankCountry
})
.then((res) => { .then((res) => {
if (res.data.internal_return < 0) { if (res.data.internal_return < 0) {
setBankName((prev) => ({ loading: false, data: [] })); setBankName((prev) => ({ loading: false, data: [] }));
@@ -140,6 +145,7 @@ function NairaWithdraw({
}; };
useEffect(() => { useEffect(() => {
handleBankOptions()
getCountry(); // TO LOAD LIST COUNTRY getCountry(); // TO LOAD LIST COUNTRY
getAccountTypes(); // TO LOAD LIST ACCOUNT TYPES getAccountTypes(); // TO LOAD LIST ACCOUNT TYPES
}, []); }, []);
@@ -226,7 +232,7 @@ function NairaWithdraw({
setShowConfirmNairaWithdraw({ show: true, state: stateData }); setShowConfirmNairaWithdraw({ show: true, state: stateData });
}, 1000); }, 1000);
} }
if (tab === "new") { if (tab === "new") {
const { accountNumber, accountType, bank, city, country, state } = const { accountNumber, accountType, bank, city, country, state } =
values?.newAccount; values?.newAccount;
@@ -281,6 +287,8 @@ function NairaWithdraw({
getRecipients(); getRecipients();
}, []); }, []);
console.log("Testing Wallet Country", wallet?.walletCountry[0][0]);
return ( return (
<ModalCom action={action} situation={situation} className="edit-popup"> <ModalCom action={action} situation={situation} className="edit-popup">
<div className="logout-modal-wrapper lw-[90%] md:w-[768px] h-full lg:h-auto bg-white dark:bg-dark-white lg:rounded-2xl"> <div className="logout-modal-wrapper lw-[90%] md:w-[768px] h-full lg:h-auto bg-white dark:bg-dark-white lg:rounded-2xl">
@@ -424,7 +432,11 @@ function NairaWithdraw({
<label <label
onClick={() => setTab("new")} onClick={() => setTab("new")}
htmlFor="new" htmlFor="new"
className={`cursor-pointer flex items-center gap-1 ${recipients.data.length >= MaxNoOfBanks ? 'pointer-events-none':''}`} className={`cursor-pointer flex items-center gap-1 ${
recipients.data.length >= MaxNoOfBanks
? "pointer-events-none"
: ""
}`}
> >
<input <input
id="new" id="new"
@@ -436,7 +448,12 @@ function NairaWithdraw({
tab == "new" ? "" : "" tab == "new" ? "" : ""
} tracking-wide transition duration-200`} } tracking-wide transition duration-200`}
/> />
New Account{" "} {recipients.data.length >= MaxNoOfBanks && <span className="text-[14px] text-red-500">Max Reached</span>} New Account{" "}
{recipients.data.length >= MaxNoOfBanks && (
<span className="text-[14px] text-red-500">
Max Reached
</span>
)}
</label> </label>
</div> </div>
</div> </div>
@@ -523,12 +540,12 @@ function NairaWithdraw({
</> </>
)} )}
{tab == "new" && ( {tab == "new" &&
recipients.loading ? (recipients.loading ? (
<div className="mt-3 flex flex-col w-full h-[188px] justify-center items-center"> <div className="mt-3 flex flex-col w-full h-[188px] justify-center items-center">
<LoadingSpinner size='10' color='sky-blue' /> <LoadingSpinner size="10" color="sky-blue" />
</div> </div>
:recipients.data.length < MaxNoOfBanks ? ) : recipients.data.length < MaxNoOfBanks ? (
<div className="w-full mt-3 rounded-md bg-slate-100"> <div className="w-full mt-3 rounded-md bg-slate-100">
<div className="relative fields w-full flex flex-col p-4"> <div className="relative fields w-full flex flex-col p-4">
<div className="flex flex-[2] min-h-[52px]"> <div className="flex flex-[2] min-h-[52px]">
@@ -541,7 +558,12 @@ function NairaWithdraw({
Country{" "} Country{" "}
<span className="text-red-500">*</span> <span className="text-red-500">*</span>
</label> </label>
<select <div className="w-full text-base p-2 text-dark-gray dark:text-white border border-slate-300 outline-0 flex-[0.6] rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding tracking-[1.5px] flex items-center pointer-events-none">
<span className="text-slate-500 text-lg italic">
{wallet.walletCountry[0][1]}
</span>
</div>
{/* <select
className="w-full text-base p-2 text-dark-gray dark:text-white border border-slate-300 outline-0 flex-[0.6] rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding tracking-[1.5px]" className="w-full text-base p-2 text-dark-gray dark:text-white border border-slate-300 outline-0 flex-[0.6] rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding tracking-[1.5px]"
name="newAccount.country" name="newAccount.country"
value={props.values.newAccount?.country} value={props.values.newAccount?.country}
@@ -552,7 +574,7 @@ function NairaWithdraw({
> >
{allCountries.loading ? ( {allCountries.loading ? (
<option <option
className="text-slate-500 text-lg" className="text-slate-500 text-lg"
value="" value=""
> >
Loading... Loading...
@@ -585,13 +607,7 @@ function NairaWithdraw({
No Options Found! No Options Found!
</option> </option>
)} )}
</select> </select> */}
{/* {props.errors.country &&
props.touched.country && (
<p className="text-sm text-red-500">
{props.errors.country}
</p>
)} */}
</div> </div>
{/* bank name */} {/* bank name */}
@@ -646,11 +662,6 @@ function NairaWithdraw({
</option> </option>
)} )}
</select> </select>
{/* {props.errors.bank && props.touched.bank && (
<p className="text-sm text-red-500">
{props.errors.bank}
</p>
)} */}
</div> </div>
</div> </div>
@@ -671,16 +682,12 @@ function NairaWithdraw({
name="newAccount.accountNumber" name="newAccount.accountNumber"
placeholder="Account No" placeholder="Account No"
maxLength={10} maxLength={10}
value={props.values.newAccount?.accountNumber} value={
props.values.newAccount?.accountNumber
}
inputHandler={props.handleChange} inputHandler={props.handleChange}
blurHandler={props.handleBlur} blurHandler={props.handleBlur}
/> />
{/* {props.errors.accountNumber &&
props.touched.accountNumber && (
<p className="text-sm text-red-500">
{props.errors.accountNumber}
</p>
)} */}
</div> </div>
{/* Account Type */} {/* Account Type */}
@@ -732,12 +739,6 @@ function NairaWithdraw({
</option> </option>
)} )}
</select> </select>
{/* {props.errors.accountType &&
props.touched.accountType && (
<p className="text-sm text-red-500">
{props.errors.accountType}
</p>
)} */}
</div> </div>
</div> </div>
@@ -748,7 +749,8 @@ function NairaWithdraw({
htmlFor="newAccount.state" htmlFor="newAccount.state"
className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex flex-[0.4]" className="input-label text-[#181c32] dark:text-white text-base font-semibold inline-flex flex-[0.4]"
> >
State <span className="text-red-500">*</span> State{" "}
<span className="text-red-500">*</span>
</label> </label>
<InputCom <InputCom
fieldClass="px-6 tracking-[1.5px]" fieldClass="px-6 tracking-[1.5px]"
@@ -760,11 +762,6 @@ function NairaWithdraw({
inputHandler={props.handleChange} inputHandler={props.handleChange}
blurHandler={props.handleBlur} blurHandler={props.handleBlur}
/> />
{/* {props.errors.state && props.touched.state && (
<p className="text-sm text-red-500">
{props.errors.state}
</p>
)} */}
</div> </div>
{/* city */} {/* city */}
@@ -785,20 +782,15 @@ function NairaWithdraw({
inputHandler={props.handleChange} inputHandler={props.handleChange}
blurHandler={props.handleBlur} blurHandler={props.handleBlur}
/> />
{/* {props.errors.city && props.touched.city && (
<p className="text-sm text-red-500">
{props.errors.city}
</p>
)} */}
</div> </div>
</div> </div>
{/* end of inputs for new accounts */} {/* end of inputs for new accounts */}
</div> </div>
</div> </div>
: ) : (
<div className="mt-3 flex w-full h-[188px] justify-center items-center"></div> <div className="mt-3 flex w-full h-[188px] justify-center items-center"></div>
)} ))}
</div> </div>
<div className="transfer-fund-btn flex justify-end items-center gap-2 py-4"> <div className="transfer-fund-btn flex justify-end items-center gap-2 py-4">
+38 -2
View File
@@ -5,7 +5,6 @@ import Layout from "../Partials/Layout";
import LoadingSpinner from "../Spinners/LoadingSpinner"; import LoadingSpinner from "../Spinners/LoadingSpinner";
const WalletBox = lazy(() => import("./WalletBox")); const WalletBox = lazy(() => import("./WalletBox"));
const WalletRoutes = () => { const WalletRoutes = () => {
const apiCall = new usersService(); const apiCall = new usersService();
const { walletDetails } = useSelector((state) => state?.walletDetails); // WALLET STORE const { walletDetails } = useSelector((state) => state?.walletDetails); // WALLET STORE
@@ -16,6 +15,12 @@ const WalletRoutes = () => {
data: [], data: [],
}); });
const [allCountries, setAllCountries] = useState({
// STATE TO HOLD LIST OF COUNTRIES
loading: true,
data: [],
});
const getPaymentHistory = () => { const getPaymentHistory = () => {
apiCall apiCall
.getPaymentHx() .getPaymentHx()
@@ -31,14 +36,45 @@ const WalletRoutes = () => {
}); });
}; };
// FUNCTION TO GET COUNTRIES
const getCountry = () => {
apiCall
.getSignupCountryData()
.then((res) => {
if (res.data.internal_return < 0) {
setAllCountries((prev) => ({ loading: false, data: [] }));
return;
}
setAllCountries((prev) => ({
loading: false,
data: res.data.signup_country,
}));
})
.catch((error) => {
setAllCountries((prev) => ({ loading: false, data: [] }));
});
};
useEffect(() => { useEffect(() => {
getCountry();
getPaymentHistory(); getPaymentHistory();
}, [walletTable]); }, [walletTable]);
console.log(
"Testing all country: ",
allCountries,
"Testing wallet: ",
walletDetails
);
return ( return (
<Layout> <Layout>
<Suspense fallback={<LoadingSpinner size="16" color="sky-blue" />}> <Suspense fallback={<LoadingSpinner size="16" color="sky-blue" />}>
<WalletBox wallet={walletDetails} payment={paymentHistory} /> <WalletBox
wallet={walletDetails}
payment={paymentHistory}
countries={allCountries.data}
/>
</Suspense> </Suspense>
</Layout> </Layout>
); );
+2 -2
View File
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from "react"; import React, { useEffect, useState } from "react";
import usersService from "../../services/UsersService"; import usersService from "../../services/UsersService";
import ConfirmNairaWithdraw from "./Popup/ConfirmNairaWithdraw"; import ConfirmNairaWithdraw from "./Popup/ConfirmNairaWithdraw";
import NairaWithdraw from "./Popup/NairaWithdraw"; import NairaWithdraw from "./Popup/NairaWithdraw";
@@ -8,7 +8,7 @@ function WalletAction({ walletItem, payment, openPopUp }) {
show: false, show: false,
state: {}, state: {},
}); // DETERMINES WHEN NAIRA WITHDRAWAL POPS UP }); // DETERMINES WHEN NAIRA WITHDRAWAL POPS UP
const [showConfirmNairaWithdraw, setShowConfirmNairaWithdraw] = useState({ const [showConfirmNairaWithdraw, setShowConfirmNairaWithdraw] = useState({
show: false, show: false,
state: {}, state: {},
+2 -2
View File
@@ -4,7 +4,7 @@ import WalletItemCard from "./WalletItemCard";
/** /**
* Renders a list of wallet items or a loading spinner depending on the state of the `wallet` object. * Renders a list of wallet items or a loading spinner depending on the state of the `wallet` object.
*/ */
export default function WalletBox({ wallet, payment }) { export default function WalletBox({ wallet, payment, countries }) {
const { loading, data } = wallet; const { loading, data } = wallet;
return ( return (
@@ -18,7 +18,7 @@ export default function WalletBox({ wallet, payment }) {
) : ( ) : (
data.length > 0 && data.map((item) => ( data.length > 0 && data.map((item) => (
<div key={item.wallet_uid} className="lg:w-full h-full mb-10 lg:mb-0"> <div key={item.wallet_uid} className="lg:w-full h-full mb-10 lg:mb-0">
<WalletItemCard walletItem={item} payment={payment} /> <WalletItemCard walletItem={item} payment={payment} countries={countries} />
</div> </div>
)) ))
)} )}
+7 -2
View File
@@ -10,7 +10,7 @@ import WalletAction from "./WalletAction";
/** /**
* Renders a card displaying information about a wallet item. * Renders a card displaying information about a wallet item.
*/ */
export default function WalletItemCard({ walletItem, payment }) { export default function WalletItemCard({ walletItem, payment, countries }) {
const { userDetails } = useSelector((state) => state.userDetails); const { userDetails } = useSelector((state) => state.userDetails);
const accountType = userDetails?.account_type === "FAMILY"; const accountType = userDetails?.account_type === "FAMILY";
const dispatch = useDispatch(); const dispatch = useDispatch();
@@ -35,10 +35,15 @@ export default function WalletItemCard({ walletItem, payment }) {
dispatch(tableReload({ type: "WALLETTABLE" })); dispatch(tableReload({ type: "WALLETTABLE" }));
}; };
const currentWalletCurrency = countries
.map((country) => country)
.filter((country) => country[0] === walletItem.country);
const image = walletItem.code const image = walletItem.code
? `${walletItem.code.toLowerCase()}.svg` ? `${walletItem.code.toLowerCase()}.svg`
: "default.png"; : "default.png";
return ( return (
<> <>
<div <div
@@ -88,7 +93,7 @@ export default function WalletItemCard({ walletItem, payment }) {
{!accountType && ( {!accountType && (
<WalletAction <WalletAction
walletItem={walletItem} walletItem={{ ...walletItem, walletCountry: currentWalletCurrency }}
payment={payment} payment={payment}
openPopUp={openPopUp} openPopUp={openPopUp}
/> />
@@ -51,6 +51,7 @@ export default function PersonalInfoTab({
coverImgInput, coverImgInput,
browseCoverImg, browseCoverImg,
coverImgChangHandler, coverImgChangHandler,
uploadStatus
}) { }) {
let { userDetails } = useSelector((state) => state.userDetails); let { userDetails } = useSelector((state) => state.userDetails);
@@ -361,7 +362,7 @@ export default function PersonalInfoTab({
{/* inputs ends here */} {/* inputs ends here */}
</div> </div>
</div> </div>
{process.env.REACT_APP_SHOW_UPLOAD_PROFILE_PICTURE != 0 && {/* {process.env.REACT_APP_SHOW_UPLOAD_PROFILE_PICTURE != 0 && */}
<div className="w-[232px] mb-10"> <div className="w-[232px] mb-10">
<div className="update-profile w-full mb-9"> <div className="update-profile w-full mb-9">
<h1 className="text-xl tracking-wide font-bold text-dark-gray dark:text-white flex items-center mb-2"> <h1 className="text-xl tracking-wide font-bold text-dark-gray dark:text-white flex items-center mb-2">
@@ -417,9 +418,11 @@ export default function PersonalInfoTab({
</div> </div>
</div> </div>
</div> </div>
{uploadStatus.message && !uploadStatus.loading && <p className={`text-center ${uploadStatus.status ? 'text-green-500':'text-red-500'}`}>{uploadStatus.message}</p>}
{uploadStatus.loading && <p className="text-center">{uploadStatus.message}</p>}
</div> </div>
</div> </div>
} {/* } */}
</div> </div>
<div className="content-footer w-full"> <div className="content-footer w-full">
+62 -4
View File
@@ -24,10 +24,12 @@ import {
import RecipientAccountTab from "./Tabs/RecipientAccountTab"; import RecipientAccountTab from "./Tabs/RecipientAccountTab";
export default function Settings({ faq }) { export default function Settings({ faq }) {
const apiCall = new usersService();
const { userDetails } = useSelector((state) => state?.userDetails); const { userDetails } = useSelector((state) => state?.userDetails);
const [profileImg, setProfileImg] = useState( const [profileImg, setProfileImg] = useState(
userDetails?.profile_pic_url ? userDetails.profile_pic_url : profile userDetails?.profile_pic_url ? userDetails.profile_pic_url : profile
); );
let [uploadStatus, setUploadStatus] = useState({loading: false, status: false, message:''}) // HOLDS STATE FOR UPLOAD PROFILE PICTURE STATUS
const [coverImg, setCoverImg] = useState(cover); const [coverImg, setCoverImg] = useState(cover);
const [reloadCardList, setReloadCardList] = useState(false); // STATE TO DETERMINE WHEN CARD LIST RELOADS. EG: WHEN USER DELETES A CARD const [reloadCardList, setReloadCardList] = useState(false); // STATE TO DETERMINE WHEN CARD LIST RELOADS. EG: WHEN USER DELETES A CARD
@@ -36,12 +38,68 @@ export default function Settings({ faq }) {
const browseProfileImg = () => { const browseProfileImg = () => {
profileImgInput.current.click(); profileImgInput.current.click();
}; };
const profileImgChangHandler = (e) => { const profileImgChangHandler = (e) => {
// if (e.target.value !== "") {
// const imgReader = new FileReader();
// imgReader.onload = (event) => {
// setProfileImg(event.target.result);
// };
// imgReader.readAsDataURL(e.target.files[0]);
// }
setUploadStatus({loading: false, status: false, message:''})
let acceptedFormat = ["jpeg", "jpg", "png", "bmp", "gif"] // ARRAY OF SUPPORTED FORMATS
let uploadedFile = e.target.files[0] //UPLOADED FILE
if(!acceptedFormat.includes(uploadedFile?.type?.split("/")[1]?.toLowerCase())){ //CHECKING FOR CORRECT UPLOAD FORMAT
let msg = 'Please select '
for(let i=0; i<=acceptedFormat.length-1; i++){
if(i == acceptedFormat.length-1){
msg+=`or ${acceptedFormat[i]}`
}else{
msg+=`${acceptedFormat[i]}, `
}
}
setUploadStatus({loading: false, status: false, message:msg})
return setTimeout(()=>{
profileImgInput.current.value = '' // clear the input
setUploadStatus({loading: false, status: false, message:''})
},5000)
}
if(uploadedFile.size > 5*1048576){ // CHECKING FOR CORRECT FILE SIZE
setUploadStatus({loading: false, status: false, message:'File must not exceed 5MB'})
return setTimeout(()=>{
profileImgInput.current.value = '' // clear the input
setUploadStatus({loading: false, status: false, message:''})
},5000)
}
if (e.target.value !== "") { if (e.target.value !== "") {
const imgReader = new FileReader(); const imgReader = new FileReader();
imgReader.onload = (event) => { imgReader.onload = (event) => {
setProfileImg(event.target.result); let reqData = { // PAYLOAD FOR API CALL
file_name: uploadedFile?.name,
file_size: uploadedFile?.size,
file_type: uploadedFile?.type?.split("/")[0]?.toLowerCase(),
file_data: event?.target?.result,
msg_type: 'FILE',
action: 'WRENCHBOARD_PICTURE_PROFILE',
// action: 11307
}
setUploadStatus({loading: true, status: false, message:'Loading...'})
apiCall.sendFiles(reqData).then(res=>{
if(res.status != 200 || res.data.internal_return < 0){
return setUploadStatus({loading: false, status: false, message: 'Something went wrong, try again'})
}
setUploadStatus({loading: false, status: true, message: 'Uploaded successfully'})
setProfileImg(event.target.result);
}).catch(error=>{
setUploadStatus({loading: false, status: false, message: 'Network error, try again'})
}).finally(()=>{
setTimeout(()=>{
setUploadStatus({loading: false, status: false, message: ''})
},5000)
})
}; };
imgReader.readAsDataURL(e.target.files[0]); imgReader.readAsDataURL(e.target.files[0]);
} }
@@ -61,7 +119,6 @@ export default function Settings({ faq }) {
} }
}; };
const apiCall = useMemo(() => new usersService(), []);
// Tabs Handling // Tabs Handling
const tabs = [ const tabs = [
{ {
@@ -113,7 +170,7 @@ export default function Settings({ faq }) {
iconName: "page-right", iconName: "page-right",
}, },
{ {
id: 8, id: 9,
name: "terms", name: "terms",
title: "Terms and Conditions", title: "Terms and Conditions",
iconName: "page-right", iconName: "page-right",
@@ -217,6 +274,7 @@ export default function Settings({ faq }) {
coverImgChangHandler={coverImgChangHandler} coverImgChangHandler={coverImgChangHandler}
browseCoverImg={browseCoverImg} browseCoverImg={browseCoverImg}
coverImgInput={coverImgInput} coverImgInput={coverImgInput}
uploadStatus={uploadStatus}
/> />
</div> </div>
)} )}
+1 -1
View File
@@ -351,7 +351,7 @@ const EditJobPopOut = ({
className="w-[120px] h-[40px] flex justify-center items-center btn-gradient text-base rounded-full text-white" className="w-[120px] h-[40px] flex justify-center items-center btn-gradient text-base rounded-full text-white"
// className='w-20 h-11 flex justify-center items-center btn-gradient text-base rounded-full text-white' // className='w-20 h-11 flex justify-center items-center btn-gradient text-base rounded-full text-white'
> >
Edit Job Save
</button> </button>
)} )}
</div> </div>