From 06f78d2b1042f23a2f5e9cc305e8ff706d1fb524 Mon Sep 17 00:00:00 2001 From: Courtney Myers Date: Mon, 29 Jan 2024 12:50:23 -0500 Subject: [PATCH 1/3] Update importing of types to include type keyword inside named import block --- app/client/src/components/errorBoundary.tsx | 3 +-- app/client/src/components/providers.tsx | 3 +-- app/client/src/contexts/dialog.tsx | 9 +++++-- app/client/src/contexts/notifications.tsx | 9 +++++-- app/client/src/contexts/rebateYear.tsx | 9 +++++-- app/client/src/routes/crf2022.tsx | 2 +- app/client/src/routes/frf2022.tsx | 2 +- app/client/src/routes/frf2023.tsx | 2 +- app/client/src/routes/frfNew.tsx | 8 +++---- app/client/src/routes/helpdesk.tsx | 14 +++++------ app/client/src/routes/prf2022.tsx | 2 +- app/client/src/routes/prf2023.tsx | 2 +- app/client/src/routes/submissions.tsx | 26 +++++++++++---------- 13 files changed, 51 insertions(+), 40 deletions(-) diff --git a/app/client/src/components/errorBoundary.tsx b/app/client/src/components/errorBoundary.tsx index d3cb91e8..211f7af2 100644 --- a/app/client/src/components/errorBoundary.tsx +++ b/app/client/src/components/errorBoundary.tsx @@ -1,5 +1,4 @@ -import type { ReactNode } from "react"; -import { Component, ErrorInfo } from "react"; +import { type ReactNode, Component, ErrorInfo } from "react"; // --- import { messages } from "@/config"; import { Message } from "@/components/message"; diff --git a/app/client/src/components/providers.tsx b/app/client/src/components/providers.tsx index 02d078ca..b3b2ef76 100644 --- a/app/client/src/components/providers.tsx +++ b/app/client/src/components/providers.tsx @@ -1,5 +1,4 @@ -import type { ReactNode } from "react"; -import { Suspense, lazy, useState, useEffect } from "react"; +import { type ReactNode, Suspense, lazy, useState, useEffect } from "react"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; // --- import { DialogProvider } from "@/contexts/dialog"; diff --git a/app/client/src/contexts/dialog.tsx b/app/client/src/contexts/dialog.tsx index 5cd25cb0..fd9b8117 100644 --- a/app/client/src/contexts/dialog.tsx +++ b/app/client/src/contexts/dialog.tsx @@ -1,7 +1,12 @@ /* eslint-disable react-refresh/only-export-components */ -import type { Dispatch, ReactNode } from "react"; -import { createContext, useContext, useReducer } from "react"; +import { + type Dispatch, + type ReactNode, + createContext, + useContext, + useReducer, +} from "react"; type Props = { children: ReactNode; diff --git a/app/client/src/contexts/notifications.tsx b/app/client/src/contexts/notifications.tsx index 6fc70863..3600b919 100644 --- a/app/client/src/contexts/notifications.tsx +++ b/app/client/src/contexts/notifications.tsx @@ -1,7 +1,12 @@ /* eslint-disable react-refresh/only-export-components */ -import type { Dispatch, ReactNode } from "react"; -import { createContext, useContext, useReducer } from "react"; +import { + type Dispatch, + type ReactNode, + createContext, + useContext, + useReducer, +} from "react"; type Props = { children: ReactNode; diff --git a/app/client/src/contexts/rebateYear.tsx b/app/client/src/contexts/rebateYear.tsx index 13f01636..9823eb38 100644 --- a/app/client/src/contexts/rebateYear.tsx +++ b/app/client/src/contexts/rebateYear.tsx @@ -1,7 +1,12 @@ /* eslint-disable react-refresh/only-export-components */ -import type { Dispatch, ReactNode } from "react"; -import { createContext, useContext, useReducer } from "react"; +import { + type Dispatch, + type ReactNode, + createContext, + useContext, + useReducer, +} from "react"; type Props = { children: ReactNode; diff --git a/app/client/src/routes/crf2022.tsx b/app/client/src/routes/crf2022.tsx index f3572e11..c7e9f97f 100644 --- a/app/client/src/routes/crf2022.tsx +++ b/app/client/src/routes/crf2022.tsx @@ -9,6 +9,7 @@ import icons from "uswds/img/sprite.svg"; // --- import { serverUrl, messages } from "@/config"; import { + type FormioCRF2022Submission, getData, postData, useContentData, @@ -24,7 +25,6 @@ import { Message } from "@/components/message"; import { MarkdownContent } from "@/components/markdownContent"; import { useNotificationsActions } from "@/contexts/notifications"; import { useRebateYearState } from "@/contexts/rebateYear"; -import type { FormioCRF2022Submission } from "@/utilities"; type ServerResponse = | { diff --git a/app/client/src/routes/frf2022.tsx b/app/client/src/routes/frf2022.tsx index 30bc90bc..f918d519 100644 --- a/app/client/src/routes/frf2022.tsx +++ b/app/client/src/routes/frf2022.tsx @@ -9,6 +9,7 @@ import icons from "uswds/img/sprite.svg"; // --- import { serverUrl, messages } from "@/config"; import { + type FormioFRF2022Submission, getData, postData, useContentData, @@ -25,7 +26,6 @@ import { MarkdownContent } from "@/components/markdownContent"; import { useDialogActions } from "@/contexts/dialog"; import { useNotificationsActions } from "@/contexts/notifications"; import { useRebateYearState } from "@/contexts/rebateYear"; -import type { FormioFRF2022Submission } from "@/utilities"; type ServerResponse = | { diff --git a/app/client/src/routes/frf2023.tsx b/app/client/src/routes/frf2023.tsx index a7f7c2c6..58407d9b 100644 --- a/app/client/src/routes/frf2023.tsx +++ b/app/client/src/routes/frf2023.tsx @@ -9,6 +9,7 @@ import icons from "uswds/img/sprite.svg"; // --- import { serverUrl, messages } from "@/config"; import { + type FormioFRF2023Submission, getData, postData, useContentData, @@ -25,7 +26,6 @@ import { MarkdownContent } from "@/components/markdownContent"; import { useDialogActions } from "@/contexts/dialog"; import { useNotificationsActions } from "@/contexts/notifications"; import { useRebateYearState } from "@/contexts/rebateYear"; -import type { FormioFRF2023Submission } from "@/utilities"; type ServerResponse = | { diff --git a/app/client/src/routes/frfNew.tsx b/app/client/src/routes/frfNew.tsx index 622682ce..e3319674 100644 --- a/app/client/src/routes/frfNew.tsx +++ b/app/client/src/routes/frfNew.tsx @@ -6,6 +6,9 @@ import icons from "uswds/img/sprite.svg"; // --- import { serverUrl, messages } from "@/config"; import { + type BapSamEntity, + type FormioFRF2022Submission, + type FormioFRF2023Submission, postData, useContentData, useConfigData, @@ -17,11 +20,6 @@ import { Message } from "@/components/message"; import { MarkdownContent } from "@/components/markdownContent"; import { TextWithTooltip } from "@/components/tooltip"; import { useRebateYearState } from "@/contexts/rebateYear"; -import type { - BapSamEntity, - FormioFRF2022Submission, - FormioFRF2023Submission, -} from "@/utilities"; /** * Creates the initial FRF submission data for a given rebate year diff --git a/app/client/src/routes/helpdesk.tsx b/app/client/src/routes/helpdesk.tsx index d86dde6a..4bdfdc1c 100644 --- a/app/client/src/routes/helpdesk.tsx +++ b/app/client/src/routes/helpdesk.tsx @@ -14,6 +14,11 @@ import { bapCRFStatusMap, } from "@/config"; import { + type FormioFRF2022Submission, + type FormioPRF2022Submission, + type FormioCRF2022Submission, + type FormioFRF2023Submission, + type BapSubmission, getData, postData, useContentData, @@ -25,17 +30,10 @@ import { Message } from "@/components/message"; import { MarkdownContent } from "@/components/markdownContent"; import { TextWithTooltip } from "@/components/tooltip"; import { + type RebateYear, useRebateYearState, useRebateYearActions, } from "@/contexts/rebateYear"; -import type { RebateYear } from "@/contexts/rebateYear"; -import type { - FormioFRF2022Submission, - FormioPRF2022Submission, - FormioCRF2022Submission, - FormioFRF2023Submission, - BapSubmission, -} from "@/utilities"; type FormType = "frf" | "prf" | "crf"; diff --git a/app/client/src/routes/prf2022.tsx b/app/client/src/routes/prf2022.tsx index e6f171eb..9d7ccf31 100644 --- a/app/client/src/routes/prf2022.tsx +++ b/app/client/src/routes/prf2022.tsx @@ -9,6 +9,7 @@ import icons from "uswds/img/sprite.svg"; // --- import { serverUrl, messages } from "@/config"; import { + type FormioPRF2022Submission, getData, postData, useContentData, @@ -24,7 +25,6 @@ import { Message } from "@/components/message"; import { MarkdownContent } from "@/components/markdownContent"; import { useNotificationsActions } from "@/contexts/notifications"; import { useRebateYearState } from "@/contexts/rebateYear"; -import type { FormioPRF2022Submission } from "@/utilities"; type ServerResponse = | { diff --git a/app/client/src/routes/prf2023.tsx b/app/client/src/routes/prf2023.tsx index 6b20889d..4c5416a8 100644 --- a/app/client/src/routes/prf2023.tsx +++ b/app/client/src/routes/prf2023.tsx @@ -9,6 +9,7 @@ import icons from "uswds/img/sprite.svg"; // --- import { serverUrl, messages } from "@/config"; import { + type FormioPRF2023Submission, getData, postData, useContentData, @@ -24,7 +25,6 @@ import { Message } from "@/components/message"; import { MarkdownContent } from "@/components/markdownContent"; import { useNotificationsActions } from "@/contexts/notifications"; import { useRebateYearState } from "@/contexts/rebateYear"; -import type { FormioPRF2023Submission } from "@/utilities"; type ServerResponse = | { diff --git a/app/client/src/routes/submissions.tsx b/app/client/src/routes/submissions.tsx index 508a7195..09600605 100644 --- a/app/client/src/routes/submissions.tsx +++ b/app/client/src/routes/submissions.tsx @@ -1,10 +1,21 @@ import { Fragment, useState } from "react"; -import type { LinkProps } from "react-router-dom"; -import { Link, useNavigate, useOutletContext } from "react-router-dom"; +import { + type LinkProps, + Link, + useNavigate, + useOutletContext, +} from "react-router-dom"; import icons from "uswds/img/sprite.svg"; // --- import { serverUrl, messages } from "@/config"; import { + type FormioFRF2022Submission, + type FormioPRF2022Submission, + type FormioCRF2022Submission, + type FormioFRF2023Submission, + type FormioPRF2023Submission, + // type FormioCRF2023Submission, + type Rebate, postData, useContentData, useConfigData, @@ -20,19 +31,10 @@ import { MarkdownContent } from "@/components/markdownContent"; import { TextWithTooltip } from "@/components/tooltip"; import { useNotificationsActions } from "@/contexts/notifications"; import { + type RebateYear, useRebateYearState, useRebateYearActions, } from "@/contexts/rebateYear"; -import type { RebateYear } from "@/contexts/rebateYear"; -import type { - FormioFRF2022Submission, - FormioPRF2022Submission, - FormioCRF2022Submission, - FormioFRF2023Submission, - FormioPRF2023Submission, - // FormioCRF2023Submission, - Rebate, -} from "@/utilities"; const defaultTableRowClassNames = "bg-gray-5"; const highlightedTableRowClassNames = "bg-primary-lighter"; From 4679352a0d7632bf026df82b4ec7855b065d429f Mon Sep 17 00:00:00 2001 From: Courtney Myers Date: Mon, 29 Jan 2024 14:58:49 -0500 Subject: [PATCH 2/3] Add clsx --- app/client/package-lock.json | 16 ++++++++++++++++ app/client/package.json | 1 + 2 files changed, 17 insertions(+) diff --git a/app/client/package-lock.json b/app/client/package-lock.json index ff52c07d..fb2f3878 100644 --- a/app/client/package-lock.json +++ b/app/client/package-lock.json @@ -38,6 +38,7 @@ "@typescript-eslint/parser": "6.7.4", "@vitejs/plugin-react-swc": "3.4.0", "autoprefixer": "10.4.16", + "clsx": "2.1.0", "eslint": "8.50.0", "eslint-plugin-react-hooks": "4.6.0", "eslint-plugin-react-refresh": "0.4.3", @@ -2225,6 +2226,15 @@ "node": ">=0.8" } }, + "node_modules/clsx": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz", + "integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -7758,6 +7768,12 @@ "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=" }, + "clsx": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz", + "integrity": "sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg==", + "dev": true + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", diff --git a/app/client/package.json b/app/client/package.json index 14b919aa..a164bf41 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -26,6 +26,7 @@ "@typescript-eslint/parser": "6.7.4", "@vitejs/plugin-react-swc": "3.4.0", "autoprefixer": "10.4.16", + "clsx": "2.1.0", "eslint": "8.50.0", "eslint-plugin-react-hooks": "4.6.0", "eslint-plugin-react-refresh": "0.4.3", From 07ce01ddf503e349bdada830dcecc21796f01faa Mon Sep 17 00:00:00 2001 From: Courtney Myers Date: Mon, 29 Jan 2024 15:07:49 -0500 Subject: [PATCH 3/3] Wrap use of tailwindscss classes and other conditionally assigned classnames with clsx() --- .../src/components/confirmationDialog.tsx | 77 +++++++++++----- app/client/src/components/notifications.tsx | 69 +++++++++----- app/client/src/components/tooltip.tsx | 13 +-- app/client/src/routes/crf2022.tsx | 41 +++++++-- app/client/src/routes/frf2022.tsx | 57 +++++++++--- app/client/src/routes/frf2023.tsx | 57 +++++++++--- app/client/src/routes/frfNew.tsx | 89 +++++++++++++------ app/client/src/routes/helpdesk.tsx | 5 +- app/client/src/routes/prf2022.tsx | 41 +++++++-- app/client/src/routes/prf2023.tsx | 41 +++++++-- app/client/src/routes/submissions.tsx | 80 +++++++++++------ 11 files changed, 414 insertions(+), 156 deletions(-) diff --git a/app/client/src/components/confirmationDialog.tsx b/app/client/src/components/confirmationDialog.tsx index c2b61dca..0e48390f 100644 --- a/app/client/src/components/confirmationDialog.tsx +++ b/app/client/src/components/confirmationDialog.tsx @@ -1,6 +1,7 @@ import { Fragment, useRef } from "react"; import { Dialog, Transition } from "@headlessui/react"; import { XMarkIcon } from "@heroicons/react/24/outline"; +import clsx from "clsx"; // --- import { useDialogState, useDialogActions } from "@/contexts/dialog"; @@ -23,7 +24,7 @@ export function ConfirmationDialog() { { @@ -33,42 +34,70 @@ export function ConfirmationDialog() { > -
+
-
-
+
+
- + {dismissable && dismissText && (
-
+
@@ -76,12 +105,12 @@ export function ConfirmationDialog() {
)} -
-

{heading}

+
+

{heading}

{description}
-
+
  • diff --git a/app/client/src/components/tooltip.tsx b/app/client/src/components/tooltip.tsx index 2329a501..9fea67f9 100644 --- a/app/client/src/components/tooltip.tsx +++ b/app/client/src/components/tooltip.tsx @@ -1,4 +1,5 @@ import { Root, Trigger, Portal, Content, Arrow } from "@radix-ui/react-tooltip"; +import clsx from "clsx"; import icons from "uswds/img/sprite.svg"; export function TextWithTooltip(props: { @@ -9,17 +10,17 @@ export function TextWithTooltip(props: { }) { const { text, tooltip, iconName, iconClassNames } = props; - const svgClassNames = iconClassNames - ? `usa-icon text-base ${iconClassNames}` - : `usa-icon text-base`; - return ( -
{}}> -
-
-
- +
+
+
+
@@ -460,7 +475,11 @@ function FundingRequestForm(props: { email: string }) { displaySuccessNotification({ id, body: ( -

+

{onSubmitSubmission.state === "submitted" ? ( <> Application {mongoId} submitted successfully. @@ -488,7 +507,11 @@ function FundingRequestForm(props: { email: string }) { displayErrorNotification({ id: Date.now(), body: ( -

+

{onSubmitSubmission.state === "submitted" ? ( <>Error submitting Application form. ) : ( @@ -557,7 +580,11 @@ function FundingRequestForm(props: { email: string }) { displaySuccessNotification({ id, body: ( -

+

Draft saved successfully.

), @@ -569,7 +596,11 @@ function FundingRequestForm(props: { email: string }) { displayErrorNotification({ id: Date.now(), body: ( -

+

Error saving draft.

), diff --git a/app/client/src/routes/frf2023.tsx b/app/client/src/routes/frf2023.tsx index 58407d9b..e66dd0e5 100644 --- a/app/client/src/routes/frf2023.tsx +++ b/app/client/src/routes/frf2023.tsx @@ -4,6 +4,7 @@ import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query"; import { Dialog } from "@headlessui/react"; import { Formio, Form } from "@formio/react"; import s3 from "formiojs/providers/storage/s3"; +import clsx from "clsx"; import { cloneDeep, isEqual } from "lodash"; import icons from "uswds/img/sprite.svg"; // --- @@ -250,10 +251,12 @@ function FundingRequestForm(props: { email: string }) { id: Date.now(), body: ( <> -

+

Error deleting Payment Request {rebate.rebateId}.

-

+

Please notify the helpdesk that a problem exists preventing the deletion of Payment Request form submission{" "} {rebate.rebateId}. @@ -270,7 +273,7 @@ function FundingRequestForm(props: { email: string }) { displayInfoNotification({ id: Date.now(), body: ( -

+

Deleting Payment Request {rebate.rebateId}...

), @@ -291,10 +294,14 @@ function FundingRequestForm(props: { email: string }) { id: Date.now(), body: ( <> -

+

Error deleting Payment Request {rebate.rebateId}.

-

+

Please reload the page to attempt the deletion again, or contact the helpdesk if the problem persists.

@@ -374,10 +381,18 @@ function FundingRequestForm(props: { email: string }) { {}}> -
-
-
- +
+
+
+
@@ -436,7 +451,11 @@ function FundingRequestForm(props: { email: string }) { displaySuccessNotification({ id, body: ( -

+

{onSubmitSubmission.state === "submitted" ? ( <> Application {mongoId} submitted successfully. @@ -464,7 +483,11 @@ function FundingRequestForm(props: { email: string }) { displayErrorNotification({ id: Date.now(), body: ( -

+

{onSubmitSubmission.state === "submitted" ? ( <>Error submitting Application form. ) : ( @@ -524,7 +547,11 @@ function FundingRequestForm(props: { email: string }) { displaySuccessNotification({ id, body: ( -

+

Draft saved successfully.

), @@ -536,7 +563,11 @@ function FundingRequestForm(props: { email: string }) { displayErrorNotification({ id: Date.now(), body: ( -

+

Error saving draft.

), diff --git a/app/client/src/routes/frfNew.tsx b/app/client/src/routes/frfNew.tsx index e3319674..a76e1e3e 100644 --- a/app/client/src/routes/frfNew.tsx +++ b/app/client/src/routes/frfNew.tsx @@ -2,6 +2,7 @@ import { Fragment, useState } from "react"; import { useNavigate, useOutletContext } from "react-router-dom"; import { Dialog, Transition } from "@headlessui/react"; import { XMarkIcon } from "@heroicons/react/24/outline"; +import clsx from "clsx"; import icons from "uswds/img/sprite.svg"; // --- import { serverUrl, messages } from "@/config"; @@ -132,67 +133,103 @@ export function FRFNew() { navigate("/")} > -
+
-
-
+
+
- +
-
+
-
+
{!frfSubmissionPeriodOpen ? ( -
+
) : activeSamEntities.length <= 0 ? ( -
+
) : ( <> {content && ( ( -

+

{props.children}

), diff --git a/app/client/src/routes/helpdesk.tsx b/app/client/src/routes/helpdesk.tsx index 4bdfdc1c..42bee296 100644 --- a/app/client/src/routes/helpdesk.tsx +++ b/app/client/src/routes/helpdesk.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query"; import { Form } from "@formio/react"; +import clsx from "clsx"; import icon from "uswds/img/usa-icons-bg/search--white.svg"; import icons from "uswds/img/sprite.svg"; // --- @@ -200,8 +201,10 @@ export function Helpdesk() { setRebateYear(ev.target.value as RebateYear)} defaultValue={rebateYear} >