Compare commits

...

4 Commits

Author SHA1 Message Date
victorAnumudu ab389d6632 load profile bug fix 2024-05-03 17:57:32 +01:00
ameye dd2df0d695 Merge branch 'get-user-details' of DigiFi/digifi-www into master 2024-05-01 16:52:44 +00:00
victorAnumudu a97db9a661 added get user by ID API 2024-05-01 17:33:41 +01:00
ameye 135cbce348 Merge branch 'loan-application-submit' of DigiFi/digifi-www into master 2024-04-30 19:13:50 +00:00
4 changed files with 50 additions and 9 deletions
+10 -1
View File
@@ -1,4 +1,4 @@
import { postAuxEnd } from "./axiosCall";
import { postAuxEnd, getAuxEnd } from "./axiosCall";
// FUNCTION TO START BVN VALIDATION
export const validateBVN = (postData:any) => {
@@ -24,4 +24,13 @@ export const applyForLoan = (postData:any) => {
...postData
}
return postAuxEnd('/loan/apply', reqData)
}
// FUNCTION TO GET USER BY CUSTOMER UID
export const getUserByID = (uid:string) => {
let reqData = {
// customer_uid: localStorage.getItem('uid'),
}
return getAuxEnd(`/profile?uid=${uid}`, reqData)
}
+23
View File
@@ -56,3 +56,26 @@ export function postAuxEnd(uri: string, reqData: any): Promise<any> {
}
});
}
export function getAuxEnd(uri: string, reqData: any): Promise<any> {
const endPoint = import.meta.env.VITE_USERS_ENDPOINT + uri;
const formData = new FormData();
for (let value in reqData) {
formData.append(value, reqData[value]);
}
return axios
.get(endPoint, reqData)
.then((response: {}) => {
// if (response.data.internal_return == "-9999") {
// localStorage.clear();
// window.location.href = `/login?sessionExpired=true`;
// }
return response;
})
.catch((error: any) => {
console.log(
"ERROR3-------------------------------------------------------", error
);
});
}
+1 -1
View File
@@ -13,6 +13,6 @@ export interface User {
last_login?:string
message?:string
token?:string
uid?:string
customer_uid?:string
call_return?:string
}
+16 -7
View File
@@ -5,6 +5,7 @@ import { Outlet, useNavigate } from "react-router-dom";
import { useSelector, useDispatch } from "react-redux";
import { RouteHandler } from '../../router/routes';
import { updateUserDetails } from '../../store/UserDetails';
import { getUserByID } from '../../core/apiRequest';
import Logo from '../../assets/images/logo.png'
@@ -19,19 +20,27 @@ export default function DashboardAuth() {
useEffect(()=>{
let token = localStorage.getItem('token')
if(!token){
let uid = localStorage.getItem('uid')
if(!token || !uid){
navigate(RouteHandler.letsGetStarted, {replace:true})
return
}
const getUserByToken = () => {
let data = {firstname:'firstname', lastname:'lastname', uid:'28273737646466464'}
setTimeout(()=>{
const getUser = () => { // FUNCTION TO GET USER BY ID
// let data = {firstname:'firstname', lastname:'lastname', uid:'28273737646466464'}
getUserByID(uid).then(res=>{
if(!res.data.call_return || !Object.keys(res.data.customer).length){
navigate(RouteHandler.letsGetStarted, {replace:true})
return
}
setLoading(false)
dispatch(updateUserDetails({...data}));
},4000)
dispatch(updateUserDetails(res.data.customer));
}).catch(err=>{
navigate(RouteHandler.letsGetStarted, {replace:true})
console.log('USER ERROR', err)
})
}
if(!Object.keys(userDetails).length){
getUserByToken()
getUser()
}
},[])