Skip to content

Commit

Permalink
Add API call to frontend to add group to user
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspalsingh-aot committed Apr 4, 2024
1 parent ec8aecb commit 9d9a4fb
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions frontend/src/app/features/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import "./Dashboard.css";
import { SdmDashboard } from "./sdmDashboard/SdmDashboard";
import { ReviewerDashoard } from "./reviewerDashboard/ReviewerDashoard";
import { getSDMUserRole } from "../../helpers/envManager";
import { getAxiosInstance } from "../../helpers/utility";
import { USERS } from "../../helpers/endpoints";

const Dashboard = () => {
const dispatch = useDispatch<AppDispatch>();

const userIsProfileVerifiedValue = useSelector(isProfileVerified);

const navigate = useNavigate();

// const lastVisitedURL = useSelector(getLastVisitedURL);
Expand All @@ -28,8 +28,9 @@ const Dashboard = () => {
// }
// },[lastVisitedURL])

const BCeID = "bceid";
const BCSC = "bcsc";
const auth = useAuth();

useEffect(() => {
if (
auth.user?.profile &&
Expand All @@ -49,9 +50,31 @@ const Dashboard = () => {
}, [userIsProfileVerifiedValue]);


useEffect( () => {
if(auth.user?.profile.identity_provider === BCeID || auth.user?.profile.identity_provider === BCSC)
{
assignGroupToUser();
}
}, []);

const assignGroupToUser = () => {
getAxiosInstance().post(USERS + '/addGroup', {
userId: auth.user?.profile.sub
})
.then(response => {
if(response.data.success)
{
console.log(response.data.message);
}
})
.catch(error => {
console.error('Error fetching data:', error);
});

}

const handleFormsflowWebRedirection = () => {
const formsFlowWebURL = process.env.REACT_APP_FORMSFLOW_WEB_URL || ((window as any)._env_ && (window as any)._env_.REACT_APP_FORMSFLOW_WEB_URL) || "";

const locationBeforeAuthRedirect = sessionStorage.getItem('locationBeforeAuthRedirect');
if(locationBeforeAuthRedirect!=="" && locationBeforeAuthRedirect !==null && locationBeforeAuthRedirect.indexOf("/fileupload")!== -1)
{
Expand Down Expand Up @@ -104,3 +127,4 @@ const Dashboard = () => {
};

export default Dashboard;

0 comments on commit 9d9a4fb

Please sign in to comment.