Skip to content

Commit

Permalink
Merge pull request #220 from Eastern-Research-Group/develop
Browse files Browse the repository at this point in the history
Sync staging with develop
  • Loading branch information
courtneymyers authored Aug 24, 2022
2 parents 30062b0 + fdc7c27 commit 1fe7140
Show file tree
Hide file tree
Showing 20 changed files with 1,066 additions and 516 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
# SAML_PRIVATE_KEY: ${{ secrets.SAML_PRIVATE_KEY }}
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }}
CSB_ENROLLMENT_PERIOD: open
CSB_ENROLLMENT_PERIOD: closed
FORMIO_PKG_AUTH_TOKEN: ${{ secrets.FORMIO_PKG_AUTH_TOKEN }}
FORMIO_BASE_URL: ${{ secrets.FORMIO_BASE_URL }}
FORMIO_PROJECT_NAME: ${{ secrets.FORMIO_PROJECT_NAME }}
Expand All @@ -52,7 +52,8 @@ jobs:
BAP_URL: ${{ secrets.BAP_URL }}
BAP_USER: ${{ secrets.BAP_USER }}
BAP_PASSWORD: ${{ secrets.BAP_PASSWORD }}
BAP_TABLE: ${{ secrets.BAP_TABLE }}
BAP_SAM_TABLE: ${{ secrets.BAP_SAM_TABLE }}
BAP_FORMS_TABLE: ${{ secrets.BAP_FORMS_TABLE }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_PUBLIC_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_PUBLIC_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.S3_PUBLIC_REGION }}
Expand Down Expand Up @@ -128,7 +129,8 @@ jobs:
cf set-env $APP_NAME "BAP_URL" "$BAP_URL" > /dev/null
cf set-env $APP_NAME "BAP_USER" "$BAP_USER" > /dev/null
cf set-env $APP_NAME "BAP_PASSWORD" "$BAP_PASSWORD" > /dev/null
cf set-env $APP_NAME "BAP_TABLE" "$BAP_TABLE" > /dev/null
cf set-env $APP_NAME "BAP_SAM_TABLE" "$BAP_SAM_TABLE" > /dev/null
cf set-env $APP_NAME "BAP_FORMS_TABLE" "$BAP_FORMS_TABLE" > /dev/null
cf set-env $APP_NAME "S3_PUBLIC_BUCKET" "$S3_PUBLIC_BUCKET" > /dev/null
cf set-env $APP_NAME "S3_PUBLIC_REGION" "$AWS_DEFAULT_REGION" > /dev/null
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
SAML_PUBLIC_KEY: ${{ secrets.SAML_PUBLIC_KEY }}
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }}
CSB_ENROLLMENT_PERIOD: open
CSB_ENROLLMENT_PERIOD: closed
FORMIO_PKG_AUTH_TOKEN: ${{ secrets.FORMIO_PKG_AUTH_TOKEN }}
FORMIO_BASE_URL: ${{ secrets.FORMIO_BASE_URL }}
FORMIO_PROJECT_NAME: ${{ secrets.FORMIO_PROJECT_NAME }}
Expand All @@ -51,7 +51,8 @@ jobs:
BAP_URL: ${{ secrets.BAP_URL }}
BAP_USER: ${{ secrets.BAP_USER }}
BAP_PASSWORD: ${{ secrets.BAP_PASSWORD }}
BAP_TABLE: ${{ secrets.BAP_TABLE }}
BAP_SAM_TABLE: ${{ secrets.BAP_SAM_TABLE }}
BAP_FORMS_TABLE: ${{ secrets.BAP_FORMS_TABLE }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_PUBLIC_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_PUBLIC_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.S3_PUBLIC_REGION }}
Expand Down Expand Up @@ -126,7 +127,8 @@ jobs:
cf set-env $APP_NAME "BAP_URL" "$BAP_URL" > /dev/null
cf set-env $APP_NAME "BAP_USER" "$BAP_USER" > /dev/null
cf set-env $APP_NAME "BAP_PASSWORD" "$BAP_PASSWORD" > /dev/null
cf set-env $APP_NAME "BAP_TABLE" "$BAP_TABLE" > /dev/null
cf set-env $APP_NAME "BAP_SAM_TABLE" "$BAP_SAM_TABLE" > /dev/null
cf set-env $APP_NAME "BAP_FORMS_TABLE" "$BAP_FORMS_TABLE" > /dev/null
cf set-env $APP_NAME "S3_PUBLIC_BUCKET" "$S3_PUBLIC_BUCKET" > /dev/null
cf set-env $APP_NAME "S3_PUBLIC_REGION" "$AWS_DEFAULT_REGION" > /dev/null
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
SAML_PRIVATE_KEY: ${{ secrets.SAML_PRIVATE_KEY }}
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }}
CSB_ENROLLMENT_PERIOD: open
CSB_ENROLLMENT_PERIOD: closed
FORMIO_PKG_AUTH_TOKEN: ${{ secrets.FORMIO_PKG_AUTH_TOKEN }}
FORMIO_BASE_URL: ${{ secrets.FORMIO_BASE_URL }}
FORMIO_PROJECT_NAME: ${{ secrets.FORMIO_PROJECT_NAME }}
Expand All @@ -52,7 +52,8 @@ jobs:
BAP_URL: ${{ secrets.BAP_URL }}
BAP_USER: ${{ secrets.BAP_USER }}
BAP_PASSWORD: ${{ secrets.BAP_PASSWORD }}
BAP_TABLE: ${{ secrets.BAP_TABLE }}
BAP_SAM_TABLE: ${{ secrets.BAP_SAM_TABLE }}
BAP_FORMS_TABLE: ${{ secrets.BAP_FORMS_TABLE }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_PUBLIC_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_PUBLIC_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.S3_PUBLIC_REGION }}
Expand Down Expand Up @@ -128,7 +129,8 @@ jobs:
cf set-env $APP_NAME "BAP_URL" "$BAP_URL" > /dev/null
cf set-env $APP_NAME "BAP_USER" "$BAP_USER" > /dev/null
cf set-env $APP_NAME "BAP_PASSWORD" "$BAP_PASSWORD" > /dev/null
cf set-env $APP_NAME "BAP_TABLE" "$BAP_TABLE" > /dev/null
cf set-env $APP_NAME "BAP_SAM_TABLE" "$BAP_SAM_TABLE" > /dev/null
cf set-env $APP_NAME "BAP_FORMS_TABLE" "$BAP_FORMS_TABLE" > /dev/null
cf set-env $APP_NAME "S3_PUBLIC_BUCKET" "$S3_PUBLIC_BUCKET" > /dev/null
cf set-env $APP_NAME "S3_PUBLIC_REGION" "$AWS_DEFAULT_REGION" > /dev/null
Expand Down
55 changes: 37 additions & 18 deletions app/client/src/components/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import icons from "uswds/img/sprite.svg";
// ---
import {
serverUrl,
serverUrlForLinks,
serverUrlForHrefs,
formioBaseUrl,
formioProjectUrl,
fetchData,
Expand All @@ -22,26 +22,45 @@ Formio.setProjectUrl(formioProjectUrl);
Formio.use(premium);
Formio.use(uswds);

// Custom hook to fetch SAM.gov data
function useFetchedSamData() {
// Custom hook to fetch CSP app specific data
function useFetchedCsbData() {
const dispatch = useUserDispatch();

useEffect(() => {
dispatch({ type: "FETCH_SAM_USER_DATA_REQUEST" });
fetchData(`${serverUrl}/api/sam-data`)
dispatch({ type: "FETCH_CSB_DATA_REQUEST" });
fetchData(`${serverUrl}/api/csb-data`)
.then((res) => {
if (res.results) {
dispatch({
type: "FETCH_CSB_DATA_SUCCESS",
payload: { csbData: res },
});
})
.catch((err) => {
dispatch({ type: "FETCH_CSB_DATA_FAILURE" });
});
}, [dispatch]);
}

// Custom hook to fetch BAP data
function useFetchedBapData() {
const dispatch = useUserDispatch();

useEffect(() => {
dispatch({ type: "FETCH_BAP_USER_DATA_REQUEST" });
fetchData(`${serverUrl}/api/bap-data`)
.then((res) => {
if (res.samResults) {
dispatch({
type: "FETCH_SAM_USER_DATA_SUCCESS",
payload: { samUserData: res },
type: "FETCH_BAP_USER_DATA_SUCCESS",
payload: { bapUserData: res },
});
} else {
window.location.href = `${serverUrl}/logout?RelayState=/welcome?info=sam-results`;
window.location.href = `${serverUrlForHrefs}/logout?RelayState=/welcome?info=sam-results`;
}
})
.catch((err) => {
dispatch({ type: "FETCH_SAM_USER_DATA_FAILURE" });
window.location.href = `${serverUrl}/logout?RelayState=/welcome?error=sam-fetch`;
dispatch({ type: "FETCH_BAP_USER_DATA_FAILURE" });
window.location.href = `${serverUrlForHrefs}/logout?RelayState=/welcome?error=bap-fetch`;
});
}, [dispatch]);
}
Expand Down Expand Up @@ -85,11 +104,12 @@ export default function Dashboard() {
const { pathname } = useLocation();
const navigate = useNavigate();

const { epaUserData, samUserData } = useUserState();
const { csbData, epaUserData, bapUserData } = useUserState();
const dispatch = useDialogDispatch();
const helpdeskAccess = useHelpdeskAccess();

useFetchedSamData();
useFetchedCsbData();
useFetchedBapData();

/**
* When provided a destination location to navigate to, creates an action
Expand All @@ -112,7 +132,7 @@ export default function Dashboard() {
};
}

if (samUserData.status !== "success") {
if (bapUserData.status !== "success") {
return <Loading />;
}

Expand Down Expand Up @@ -145,13 +165,13 @@ export default function Dashboard() {
<nav className="desktop:order-last mobile-lg:display-flex flex-align-center flex-justify-end">
<p className="margin-bottom-1 margin-right-1">
<span>
{epaUserData.status === "success" && epaUserData.data?.mail}
{epaUserData.status === "success" && epaUserData.data.mail}
</span>
</p>

<a
className="margin-bottom-1 usa-button font-sans-2xs margin-right-0"
href={`${serverUrlForLinks}/logout`}
href={`${serverUrlForHrefs}/logout`}
>
<IconText order="text-icon" icon="logout" text="Sign out" />
</a>
Expand Down Expand Up @@ -190,8 +210,7 @@ export default function Dashboard() {
)}

{pathname.startsWith("/rebate") ||
(epaUserData.status === "success" &&
epaUserData.data?.enrollmentClosed) ? (
(csbData.status === "success" && csbData.data.enrollmentClosed) ? (
<button
className="margin-bottom-1 usa-button font-sans-2xs"
disabled
Expand Down
6 changes: 3 additions & 3 deletions app/client/src/components/infoTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function InfoTooltip({ label }: InfoTooltipProps) {
style={{ backgroundColor: "rgba(0, 0, 0, 0.875)" }}
>
<svg
className="usa-icon margin-left-05 text-base"
className="usa-icon margin-right-05 text-base"
aria-hidden="true"
focusable="false"
role="img"
Expand All @@ -31,9 +31,9 @@ type TextWithTooltipProps = {

export function TextWithTooltip({ text, tooltip }: TextWithTooltipProps) {
return (
<span className="display-flex flex-align-center text-no-wrap">
{text}
<span className="display-inline-flex flex-align-center text-no-wrap">
<InfoTooltip label={tooltip} />
{text}
</span>
);
}
10 changes: 5 additions & 5 deletions app/client/src/components/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useEffect } from "react";
import { useSearchParams } from "react-router-dom";
import icons from "uswds/img/sprite.svg";
// ---
import { serverUrlForLinks, messages } from "../config";
import { serverUrlForHrefs, messages } from "../config";
import Message from "components/message";

export default function Welcome() {
Expand Down Expand Up @@ -35,19 +35,19 @@ export default function Welcome() {
});
}

if (searchParams.get("error") === "sam-fetch") {
if (searchParams.get("error") === "bap-fetch") {
setMessage({
displayed: true,
type: "error",
text: messages.samFetchError,
text: messages.bapFetchError,
});
}

if (searchParams.get("info") === "sam-results") {
setMessage({
displayed: true,
type: "info",
text: messages.samNoResults,
text: messages.noSamResults,
});
}

Expand Down Expand Up @@ -84,7 +84,7 @@ export default function Welcome() {

<a
className="usa-button margin-top-1 margin-right-0 font-sans-2xs"
href={`${serverUrlForLinks}/login`}
href={`${serverUrlForHrefs}/login`}
>
<span className="display-flex flex-align-center">
<span className="margin-right-1">Sign in</span>
Expand Down
14 changes: 7 additions & 7 deletions app/client/src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ export const serverBasePath =
// is needed for production.
export const serverUrl = window.location.origin + serverBasePath;

// NOTE: This local development setup unfortunately doesn't proxy GET requests
// from links though because they set an "Accept" request header to "text/html",
// so we need to use a different environment variable for when the serverUrl is
// used in the href of anchor tags (e.g. login and logout links).
export const serverUrlForLinks =
// NOTE: Create React App's local development proxy setup doesn't proxy requests
// that set an "Accept" request header to "text/html", so in those cases we need
// to explicitly use the server app's URL/port (localhost:3001)
export const serverUrlForHrefs =
NODE_ENV === "development" ? "http://localhost:3001" : serverUrl;

export const cloudSpace =
Expand All @@ -55,8 +54,9 @@ export const messages = {
genericError: "Something went wrong.",
authError: "Authentication error. Please log in again or contact support.",
samlError: "Error logging in. Please try again or contact support.",
samFetchError: "Error retrieving SAM.gov data. Please contact support.",
samNoResults:
bapFetchError:
"Error loading SAM.gov or rebate submission data. Please contact support.",
noSamResults:
"No SAM.gov records match your email. Only Government and Electronic Business SAM.gov Points of Contacts (and alternates) may edit and submit Clean School Bus Rebate Forms.",
rebateSubmissionsError: "Error loading rebate form submissions.",
newRebateApplication:
Expand Down
Loading

0 comments on commit 1fe7140

Please sign in to comment.