update user_id 13
This commit is contained in:
@ -26,6 +26,7 @@ const TheContent = () => {
|
||||
const [UserData, setUserData] = useState('');
|
||||
const [UserId, setUserId] = useState('');
|
||||
const [isDataFetched, setIsDataFetched] = useState(false);
|
||||
const [isPosted, setPosted] = useState(false);
|
||||
|
||||
async function fetchSession() {
|
||||
|
||||
@ -35,15 +36,17 @@ const TheContent = () => {
|
||||
console.log(result.data);
|
||||
setSsoSession(result.data);
|
||||
}
|
||||
get_token_from_storage_or_cookie();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
fetchSession()
|
||||
get_token_from_storage_or_cookie();
|
||||
}, []);
|
||||
|
||||
async function postUserData(data) {
|
||||
|
||||
setPosted(true);
|
||||
|
||||
let axiosConfig = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
@ -54,8 +57,8 @@ const TheContent = () => {
|
||||
const result = await axios.post('https://fbssso.ts.bizside.biz/csv', data, axiosConfig)
|
||||
.catch((err) => {
|
||||
console.log("AXIOS ERROR: ", err);
|
||||
setPosted(false);
|
||||
});
|
||||
|
||||
console.log("--- res ----", result);
|
||||
|
||||
if(result === "OK"){
|
||||
@ -140,7 +143,9 @@ const TheContent = () => {
|
||||
//const json_str = '[{"jsessonid": "' + UserId + '" , "name": "' + _firstname + ' ' +_lastname+ '", "mailadress":" ' + _email + '", "empcode": "' + _empcode + '"}]';
|
||||
if(_empcode !== null && _empcode !== undefined){
|
||||
if(isCSVPath()){
|
||||
postUserData(json_str);
|
||||
if(isPosted == false){
|
||||
postUserData(json_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -156,28 +161,33 @@ const TheContent = () => {
|
||||
|
||||
return (
|
||||
<main className="c-main">
|
||||
{isDataFetched ? ( // Render the component only when isDataFetched is true
|
||||
<CContainer fluid>
|
||||
<Suspense fallback={loading}>
|
||||
<Switch>
|
||||
{routes.map((route, idx) => {
|
||||
return route.component && (
|
||||
<Route
|
||||
key={idx}
|
||||
path={route.path}
|
||||
exact={route.exact}
|
||||
name={route.name}
|
||||
render={(props) =>
|
||||
<CContainer fluid>
|
||||
<Suspense fallback={loading}>
|
||||
<Switch>
|
||||
{routes.map((route, idx) => {
|
||||
return route.component && (
|
||||
<Route
|
||||
key={idx}
|
||||
path={route.path}
|
||||
exact={route.exact}
|
||||
name={route.name}
|
||||
render={(props) =>
|
||||
isDataFetched ?
|
||||
get_token_from_storage_or_cookie() !== null ? (
|
||||
<route.component {...props} userid={UserId} email={UserData.email} />
|
||||
}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
<Redirect from="/" to="/dashboard" />
|
||||
</Switch>
|
||||
</Suspense>
|
||||
</CContainer>
|
||||
) : null}
|
||||
) : (
|
||||
<Redirect to={{ pathname: "/sso" }} />
|
||||
)
|
||||
:
|
||||
null
|
||||
}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
<Redirect from="/" to="/dashboard" />
|
||||
</Switch>
|
||||
</Suspense>
|
||||
</CContainer>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user