Skip to content

Commit

Permalink
Merge pull request #1786 from shuhaib-aot/FWF-2732
Browse files Browse the repository at this point in the history
Fixed view submission for reviewer
  • Loading branch information
shuhaib-aot authored Nov 29, 2023
2 parents 428c121 + cb223a7 commit 1ac303c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions forms-flow-web/src/components/Form/Item/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route, Switch, Redirect, useParams } from "react-router-dom";
import { Route, Switch, Redirect, useParams, useLocation } from "react-router-dom";
import React, { useEffect } from "react";
import { Formio, getForm } from "react-formio";
import { useDispatch, useSelector } from "react-redux";
Expand All @@ -22,12 +22,14 @@ import {

import Draft from "../../Draft";
import Loading from "../../../containers/Loading";
import { getClientList } from "../../../apiManager/services/authorizationService";
import { getClientList, getReviewerList } from "../../../apiManager/services/authorizationService";
import NotFound from "../../NotFound";
import { setApiCallError } from "../../../actions/ErroHandling";

const Item = React.memo(() => {
const { formId } = useParams();
const location = useLocation(); // React Router's hook to get the current location
const pathname = location.pathname;
const userRoles = useSelector((state) => state.user.roles || []);
const tenantKey = useSelector((state) => state?.tenants?.tenantId);
const redirectUrl = MULTITENANCY_ENABLED ? `/tenant/${tenantKey}/` : "/";
Expand All @@ -36,7 +38,13 @@ const Item = React.memo(() => {
const dispatch = useDispatch();

const formAuthVerify = (formId,successCallBack)=>{
getClientList(formId).then(successCallBack).catch((err)=>{
const isSubmissionRoute = pathname?.includes("/submission");
const authFunction = isSubmissionRoute
? userRoles.includes(STAFF_REVIEWER)
? getReviewerList
: getClientList
: getClientList;
authFunction(formId).then(successCallBack).catch((err)=>{
const {response} = err;
dispatch(setApiCallError({message:response?.data?.message ||
response.statusText,status:response.status}));
Expand Down

0 comments on commit 1ac303c

Please sign in to comment.