Skip to content

Commit

Permalink
Merge pull request #202 from Eastern-Research-Group/develop
Browse files Browse the repository at this point in the history
Merging v1.1 changes into staging
  • Loading branch information
coobr01 authored Jul 22, 2022
2 parents 34f8a7d + 4b0fbfb commit 7985389
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 29 deletions.
1 change: 0 additions & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ jobs:
PUBLIC_URL="$SERVER_URL" \
REACT_APP_SERVER_BASE_PATH="$SERVER_BASE_PATH" \
REACT_APP_CLOUD_SPACE="$CLOUD_SPACE" \
REACT_APP_CSB_ENROLLMENT_PERIOD="$CSB_ENROLLMENT_PERIOD" \
REACT_APP_FORMIO_BASE_URL="$FORMIO_BASE_URL" \
REACT_APP_FORMIO_PROJECT_NAME="$FORMIO_PROJECT_NAME" \
npm run build
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ jobs:
PUBLIC_URL="$SERVER_URL" \
REACT_APP_SERVER_BASE_PATH="$SERVER_BASE_PATH" \
REACT_APP_CLOUD_SPACE="$CLOUD_SPACE" \
REACT_APP_CSB_ENROLLMENT_PERIOD="$CSB_ENROLLMENT_PERIOD" \
REACT_APP_FORMIO_BASE_URL="$FORMIO_BASE_URL" \
REACT_APP_FORMIO_PROJECT_NAME="$FORMIO_PROJECT_NAME" \
npm run build
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ jobs:
PUBLIC_URL="$SERVER_URL" \
REACT_APP_SERVER_BASE_PATH="$SERVER_BASE_PATH" \
REACT_APP_CLOUD_SPACE="$CLOUD_SPACE" \
REACT_APP_CSB_ENROLLMENT_PERIOD="$CSB_ENROLLMENT_PERIOD" \
REACT_APP_FORMIO_BASE_URL="$FORMIO_BASE_URL" \
REACT_APP_FORMIO_PROJECT_NAME="$FORMIO_PROJECT_NAME" \
npm run build
Expand Down
10 changes: 4 additions & 6 deletions app/client/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# NOTE: For local development, set `REACT_APP_CSB_ENROLLMENT_PERIOD`,
# `REACT_APP_FORMIO_BASE_URL`, and `REACT_APP_FORMIO_PROJECT_NAME` to the same
# values used in the server app's `CSB_ENROLLMENT_PERIOD`, `FORMIO_BASE_URL`,
# and `FORMIO_PROJECT_NAME` env variables. When deployed, a GitHub Actions
# Workflow does this in the "build" npm script.
REACT_APP_CSB_ENROLLMENT_PERIOD=
# NOTE: For local development, set `REACT_APP_FORMIO_BASE_URL` and
# `REACT_APP_FORMIO_PROJECT_NAME` to the same values used in the server app's
# `FORMIO_BASE_URL` and `FORMIO_PROJECT_NAME` env variables. When deployed, a
# GitHub Actions Workflow does this in the "build" npm script.
REACT_APP_FORMIO_BASE_URL=
REACT_APP_FORMIO_PROJECT_NAME=
5 changes: 3 additions & 2 deletions app/client/src/components/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import icons from "uswds/img/sprite.svg";
import {
serverUrl,
serverUrlForLinks,
enrollmentClosed,
formioBaseUrl,
formioProjectUrl,
fetchData,
Expand Down Expand Up @@ -190,7 +189,9 @@ export default function Dashboard() {
</Link>
)}

{pathname.startsWith("/rebate") || enrollmentClosed ? (
{pathname.startsWith("/rebate") ||
(epaUserData.status === "success" &&
epaUserData.data?.enrollmentClosed) ? (
<button
className="margin-bottom-1 usa-button font-sans-2xs"
disabled
Expand Down
11 changes: 1 addition & 10 deletions app/client/src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@ const {
NODE_ENV,
REACT_APP_SERVER_BASE_PATH,
REACT_APP_CLOUD_SPACE,
REACT_APP_CSB_ENROLLMENT_PERIOD,
REACT_APP_FORMIO_BASE_URL,
REACT_APP_FORMIO_PROJECT_NAME,
} = process.env;

if (!REACT_APP_CSB_ENROLLMENT_PERIOD) {
throw new Error(
"Required REACT_APP_CSB_ENROLLMENT_PERIOD environment variable not found."
);
}

if (!REACT_APP_FORMIO_BASE_URL) {
throw new Error(
"Required REACT_APP_FORMIO_BASE_URL environment variable not found."
Expand Down Expand Up @@ -52,8 +45,6 @@ export const serverUrlForLinks =
export const cloudSpace =
NODE_ENV === "development" ? "dev" : REACT_APP_CLOUD_SPACE || "";

export const enrollmentClosed = REACT_APP_CSB_ENROLLMENT_PERIOD === "closed";

export const formioBaseUrl = REACT_APP_FORMIO_BASE_URL;

const formioProjectName = REACT_APP_FORMIO_PROJECT_NAME;
Expand All @@ -75,7 +66,7 @@ export const messages = {
timeout:
"For security reasons, you have been logged out due to 15 minutes of inactivity.",
logout: "You have successfully logged out.",
csbEnrollmentClosed: "The CSB enrollment period is closed.",
enrollmentClosed: "The CSB enrollment period is closed.",
};

/**
Expand Down
1 change: 1 addition & 0 deletions app/client/src/contexts/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Props = {
};

type EpaUserData = {
enrollmentClosed: boolean;
mail: string;
memberof: string;
exp: number;
Expand Down
8 changes: 5 additions & 3 deletions app/client/src/routes/allRebates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect } from "react";
import { Link } from "react-router-dom";
import icons from "uswds/img/sprite.svg";
// ---
import { serverUrl, enrollmentClosed, fetchData, messages } from "../config";
import { serverUrl, fetchData, messages } from "../config";
import Loading from "components/loading";
import Message from "components/message";
import MarkdownContent from "components/markdownContent";
Expand All @@ -13,7 +13,7 @@ import { useFormsState, useFormsDispatch } from "contexts/forms";

export default function AllRebates() {
const { content } = useContentState();
const { samUserData } = useUserState();
const { epaUserData, samUserData } = useUserState();
const { rebateFormSubmissions } = useFormsState();
const dispatch = useFormsDispatch();

Expand Down Expand Up @@ -138,7 +138,9 @@ export default function AllRebates() {
<tr
key={_id}
className={
state === "submitted" || enrollmentClosed
state === "submitted" ||
(epaUserData.status === "success" &&
epaUserData.data?.enrollmentClosed)
? "text-italic text-base-dark"
: ""
}
Expand Down
5 changes: 3 additions & 2 deletions app/client/src/routes/existingRebate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useNavigate, useParams } from "react-router-dom";
import { Formio, Form } from "@formio/react";
import { cloneDeep, isEqual } from "lodash";
// ---
import { serverUrl, enrollmentClosed, fetchData } from "../config";
import { serverUrl, fetchData } from "../config";
import { getUserInfo } from "../utilities";
import Loading from "components/loading";
import Message from "components/message";
Expand Down Expand Up @@ -393,7 +393,8 @@ function ExistingRebateContent() {
}}
options={{
readOnly:
submissionData.state === "submitted" || enrollmentClosed
submissionData.state === "submitted" ||
epaUserData.data.enrollmentClosed
? true
: false,
noAlerts: true,
Expand Down
6 changes: 3 additions & 3 deletions app/client/src/routes/newRebate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useNavigate } from "react-router-dom";
import { DialogOverlay, DialogContent } from "@reach/dialog";
import icons from "uswds/img/sprite.svg";
// ---
import { serverUrl, enrollmentClosed, messages, fetchData } from "../config";
import { serverUrl, messages, fetchData } from "../config";
import { getUserInfo } from "../utilities";
import Loading from "components/loading";
import Message from "components/message";
Expand Down Expand Up @@ -73,8 +73,8 @@ export default function NewRebate() {
>
<div className="usa-modal__content">
<div className="usa-modal__main">
{enrollmentClosed ? (
<Message type="info" text={messages.csbEnrollmentClosed} />
{epaUserData.data.enrollmentClosed ? (
<Message type="info" text={messages.enrollmentClosed} />
) : activeSamRecords.length <= 0 ? (
<Message type="info" text={messages.samNoResults} />
) : (
Expand Down
1 change: 1 addition & 0 deletions app/server/app/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ router.get("/helpdesk-access", ensureHelpdesk, (req, res) => {
router.get("/epa-data", (req, res) => {
// Explicitly return only required attributes from user info
res.json({
enrollmentClosed: process.env.CSB_ENROLLMENT_PERIOD === "closed",
mail: req.user.mail,
memberof: req.user.memberof,
exp: req.user.exp,
Expand Down

0 comments on commit 7985389

Please sign in to comment.