Skip to content

Commit

Permalink
Show Review and Submit when submit button is visible
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro-Vega committed Jan 7, 2025
1 parent ee090ac commit 3f848ef
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/ProgressBar/ProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import config from "../../config/SectionConfig";
import { Status, useFormContext } from "../Contexts/FormContext";
import StatusAdornment from "./StatusAdornment";
import useFormMode from "../../hooks/useFormMode";
import { useAuthContext } from "../Contexts/AuthContext";
import { CanSubmitSubmissionRequestRoles } from "../../config/AuthRoles";

type Props = {
section: string;
Expand Down Expand Up @@ -77,6 +79,8 @@ const StyledButton = styled(ListItemButton)({
* @returns {JSX.Element}
*/
const ProgressBar: FC<Props> = ({ section }) => {
const { user } = useAuthContext();

const sectionKeys = Object.keys(config);

const { data, status: formStatus } = useFormContext();
Expand Down Expand Up @@ -112,7 +116,15 @@ const ProgressBar: FC<Props> = ({ section }) => {
const reviewSection = newSections.find((s) => s.id === "review");
const reviewUnlocked = completedSections === sectionKeys.length - 1;
if (reviewSection) {
const showReviewTitle = formMode === "View Only" || formMode === "Review";
const meetsReviewCriteria = formMode === "View Only" || formMode === "Review";

const canSeeSubmitButton =
CanSubmitSubmissionRequestRoles.includes(user?.role) &&
(data?.status === "In Progress" ||
(data?.status === "Inquired" && user?.role === "Federal Lead"));

const showReviewTitle = meetsReviewCriteria && !canSeeSubmitButton;

const reviewIcon = reviewUnlocked ? "Review" : "ReviewDisabled";
reviewSection.icon =
["Approved"].includes(status) && reviewUnlocked ? "Completed" : reviewIcon;
Expand Down

0 comments on commit 3f848ef

Please sign in to comment.