From b8ab80529cd77faeb4bd4aa8eeb63dbc4b2fb2d9 Mon Sep 17 00:00:00 2001 From: Meis Date: Thu, 16 Jan 2025 16:07:14 -0700 Subject: [PATCH] task: Remove deprecated usage of defaultProps for functional components --- src/components/CommonLinks.tsx | 4 +--- src/components/FormButtonGroup.tsx | 19 +++++-------------- src/components/FormErrorHeader.tsx | 8 +------- src/components/FormWrapper.tsx | 6 +----- src/components/GovBanner.tsx | 4 ---- src/components/InputErrorMessage.tsx | 6 +----- src/components/Loading.tsx | 2 -- src/components/RadioButtonGroup.tsx | 6 ------ src/pages/Filing/FilingApp/FieldEntry.tsx | 4 ---- src/pages/Filing/FilingApp/FieldSummary.tsx | 9 ++------- .../FilingErrorsWarningsLimit.tsx | 6 +----- .../Filing/FilingApp/InstitutionCard.tsx | 9 +++------ src/pages/Filing/ProcessStep.tsx | 6 +----- src/pages/Filing/ProcessStepNumber.tsx | 7 +------ .../UpdateAffiliateInformation.tsx | 6 +----- .../AlertInstitutionApiUnreachable.tsx | 6 +----- .../ViewInstitutionProfile/DisplayField.tsx | 12 ++---------- .../FinancialInstitutionDetails.tsx | 9 ++------- .../IdentifyingInformation.tsx | 5 +---- .../FilingDetails/VoluntaryReporterStatus.tsx | 9 +-------- src/pages/FilingDetails/index.tsx | 8 ++------ .../AddFinancialInstitution.tsx | 6 +----- src/pages/Summary/Summary.tsx | 4 ---- 23 files changed, 28 insertions(+), 133 deletions(-) diff --git a/src/components/CommonLinks.tsx b/src/components/CommonLinks.tsx index a51c89652..3d58c5c92 100644 --- a/src/components/CommonLinks.tsx +++ b/src/components/CommonLinks.tsx @@ -30,7 +30,7 @@ interface UpdateInstitutionProfileProperties { } function UpdateInstitutionProfile({ - isCallToAction, + isCallToAction = false, className = 'font-normal', }: UpdateInstitutionProfileProperties): ReactElement { const { lei } = useParams(); @@ -44,8 +44,6 @@ function UpdateInstitutionProfile({ ); } -UpdateInstitutionProfile.defaultProps = { isCallToAction: false }; - interface UpdateFilingDetailsProperties { // eslint-disable-next-line react/require-default-props label?: string; diff --git a/src/components/FormButtonGroup.tsx b/src/components/FormButtonGroup.tsx index 2beb721a2..2cda967bd 100644 --- a/src/components/FormButtonGroup.tsx +++ b/src/components/FormButtonGroup.tsx @@ -7,22 +7,13 @@ interface FormButtonGroupProperties { function FormButtonGroup({ className, - isFilingStep, + isFilingStep = false, children, }: FormButtonGroupProperties & JSX.IntrinsicElements['div']): JSX.Element { - return ( -
- {children} -
- ); + const classnames = ['mt-[1.875rem]']; + classnames.push(isFilingStep ? 'gap-[1.125rem]' : 'gap-[0.625rem]'); + if (className) classnames.push(className); + return
{children}
; } -FormButtonGroup.defaultProps = { - isFilingStep: false, -}; - export default FormButtonGroup; diff --git a/src/components/FormErrorHeader.tsx b/src/components/FormErrorHeader.tsx index 2f3134798..c8744cd71 100644 --- a/src/components/FormErrorHeader.tsx +++ b/src/components/FormErrorHeader.tsx @@ -27,7 +27,7 @@ function FormErrorHeader< M extends FieldValues, T extends Record, >({ - alertHeading, + alertHeading = 'There was a problem completing your user profile', errors, id, keyLogicFunc, @@ -120,10 +120,4 @@ function FormErrorHeader< ); } -FormErrorHeader.defaultProps = { - alertHeading: 'There was a problem completing your user profile', - errors: null, - showKeyIndexNumber: false, -}; - export default FormErrorHeader; diff --git a/src/components/FormWrapper.tsx b/src/components/FormWrapper.tsx index eebcf1dd5..7479193a0 100644 --- a/src/components/FormWrapper.tsx +++ b/src/components/FormWrapper.tsx @@ -7,7 +7,7 @@ interface FormWrapperProperties { function FormWrapper({ children, - isMarginTop, + isMarginTop = true, }: FormWrapperProperties): JSX.Element { const marginTop = isMarginTop ? 'mt-[2.8125rem]' : ''; return ( @@ -19,8 +19,4 @@ function FormWrapper({ ); } -FormWrapper.defaultProps = { - isMarginTop: true, -}; - export default FormWrapper; diff --git a/src/components/GovBanner.tsx b/src/components/GovBanner.tsx index 0f8151406..7ac57accf 100644 --- a/src/components/GovBanner.tsx +++ b/src/components/GovBanner.tsx @@ -33,7 +33,3 @@ export default function GovBanner(): JSX.Element { /> ); } - -GovBanner.defaultProps = { - currentLanguage: 'en', -}; diff --git a/src/components/InputErrorMessage.tsx b/src/components/InputErrorMessage.tsx index 2ad801325..1a55c2883 100644 --- a/src/components/InputErrorMessage.tsx +++ b/src/components/InputErrorMessage.tsx @@ -9,7 +9,7 @@ interface InputErrorMessageProperties { function InputErrorMessage({ children, - status, + status = 'error', }: InputErrorMessageProperties): JSX.Element { return (
@@ -21,8 +21,4 @@ function InputErrorMessage({ ); } -InputErrorMessage.defaultProps = { - status: 'error', -}; - export default InputErrorMessage; diff --git a/src/components/Loading.tsx b/src/components/Loading.tsx index 6eb2083cf..5f6108f59 100644 --- a/src/components/Loading.tsx +++ b/src/components/Loading.tsx @@ -4,8 +4,6 @@ import { useHeaderAuthLinks } from 'utils/useHeaderAuthLinks'; import FooterCfGovWrapper from './FooterCfGovWrapper'; export interface LoadingType { - // TODO: Do we need this rule? Adding Loading.defaultProps = {...} does not fix the error. - // eslint-disable-next-line react/require-default-props message?: ReactElement | string; } diff --git a/src/components/RadioButtonGroup.tsx b/src/components/RadioButtonGroup.tsx index 424ca2499..2aeba7899 100644 --- a/src/components/RadioButtonGroup.tsx +++ b/src/components/RadioButtonGroup.tsx @@ -48,10 +48,4 @@ function RadioButtonGroup({ ); } -RadioButtonGroup.defaultProps = { - id: 'radio-button-group', - label: 'Radio Group', - onChange: undefined, -}; - export default RadioButtonGroup; diff --git a/src/pages/Filing/FilingApp/FieldEntry.tsx b/src/pages/Filing/FilingApp/FieldEntry.tsx index 1249c83cc..dac2bdaf6 100644 --- a/src/pages/Filing/FilingApp/FieldEntry.tsx +++ b/src/pages/Filing/FilingApp/FieldEntry.tsx @@ -178,8 +178,4 @@ function FieldEntry({ ); } -FieldEntry.defaultProps = { - isWarning: false, -}; - export default FieldEntry; diff --git a/src/pages/Filing/FilingApp/FieldSummary.tsx b/src/pages/Filing/FilingApp/FieldSummary.tsx index 3438d84a1..51ab30db3 100644 --- a/src/pages/Filing/FilingApp/FieldSummary.tsx +++ b/src/pages/Filing/FilingApp/FieldSummary.tsx @@ -18,14 +18,14 @@ interface FieldProperties { function FieldSummary({ heading, fieldArray, - bottomMargin, + bottomMargin = false, children, id, className = '', lei, submissionId, filingPeriod, - isWarning, + isWarning = false, }: FieldProperties & JSX.IntrinsicElements['div']): JSX.Element { return (
@@ -52,8 +52,4 @@ function FilingErrorsWarningsLimit({ ); } -FilingErrorsWarningsLimit.defaultProps = { - isWarning: false, -}; - export default FilingErrorsWarningsLimit; diff --git a/src/pages/Filing/FilingApp/InstitutionCard.tsx b/src/pages/Filing/FilingApp/InstitutionCard.tsx index 82b29cb2f..f4f482f55 100644 --- a/src/pages/Filing/FilingApp/InstitutionCard.tsx +++ b/src/pages/Filing/FilingApp/InstitutionCard.tsx @@ -182,15 +182,12 @@ function InstitutionCardDataWrapper({ */ export function InstitutionCard({ lei, + name = '', + status = '', ...others }: InstitutionDataType): JSXElement { if (!lei) return null; - return ; + return ; } -InstitutionCard.defaultProps = { - name: '', - status: '', -}; - export default InstitutionCard; diff --git a/src/pages/Filing/ProcessStep.tsx b/src/pages/Filing/ProcessStep.tsx index 1596d3d38..2260c7939 100644 --- a/src/pages/Filing/ProcessStep.tsx +++ b/src/pages/Filing/ProcessStep.tsx @@ -10,7 +10,7 @@ interface ProcessStepProperties { export default function ProcessStep({ number, - size, + size = 'h4', heading, children, }: ProcessStepNumberProperties & ProcessStepProperties): JSX.Element { @@ -24,7 +24,3 @@ export default function ProcessStep({
); } - -ProcessStep.defaultProps = { - ...ProcessStepNumber.defaultProps, -}; diff --git a/src/pages/Filing/ProcessStepNumber.tsx b/src/pages/Filing/ProcessStepNumber.tsx index a001c8b95..2328616b9 100644 --- a/src/pages/Filing/ProcessStepNumber.tsx +++ b/src/pages/Filing/ProcessStepNumber.tsx @@ -17,7 +17,7 @@ export interface ProcessStepNumberProperties { export function ProcessStepNumber({ number, withBg, - size, + size = 'h4', }: ProcessStepNumberProperties): ReactElement { const StepIcons: Record = { '1': 'one', @@ -39,8 +39,3 @@ export function ProcessStepNumber({ ); } - -ProcessStepNumber.defaultProps = { - size: 'h4', - withBg: false, -}; diff --git a/src/pages/Filing/UpdateFinancialProfile/UpdateAffiliateInformation.tsx b/src/pages/Filing/UpdateFinancialProfile/UpdateAffiliateInformation.tsx index 5707429a2..0bef0c287 100644 --- a/src/pages/Filing/UpdateFinancialProfile/UpdateAffiliateInformation.tsx +++ b/src/pages/Filing/UpdateFinancialProfile/UpdateAffiliateInformation.tsx @@ -17,7 +17,7 @@ const parentRssd = 'parent_rssd_id'; const topHolderRssd = 'top_holder_rssd_id'; function UpdateAffiliateInformation({ - heading, + heading = 'Update your financial institution affiliate information', register, formErrors, watch, @@ -121,8 +121,4 @@ function UpdateAffiliateInformation({ ); } -UpdateAffiliateInformation.defaultProps = { - heading: 'Update your financial institution affiliate information', -}; - export default UpdateAffiliateInformation; diff --git a/src/pages/Filing/ViewInstitutionProfile/AlertInstitutionApiUnreachable.tsx b/src/pages/Filing/ViewInstitutionProfile/AlertInstitutionApiUnreachable.tsx index 24fa25e22..bb56ca655 100644 --- a/src/pages/Filing/ViewInstitutionProfile/AlertInstitutionApiUnreachable.tsx +++ b/src/pages/Filing/ViewInstitutionProfile/AlertInstitutionApiUnreachable.tsx @@ -11,7 +11,7 @@ export interface InstitutionApiErrorWrapperType { // Shared page-level alert for Institution API errors export function AlertInstitutionApiUnreachable({ - isError, + isError = false, children, }: InstitutionApiErrorWrapperType): JSX.Element { if (isError) @@ -31,8 +31,4 @@ export function AlertInstitutionApiUnreachable({ return <>{children}; } -AlertInstitutionApiUnreachable.defaultProps = { - isError: false, -}; - export default AlertInstitutionApiUnreachable; diff --git a/src/pages/Filing/ViewInstitutionProfile/DisplayField.tsx b/src/pages/Filing/ViewInstitutionProfile/DisplayField.tsx index 34b57db8a..e7df4597f 100644 --- a/src/pages/Filing/ViewInstitutionProfile/DisplayField.tsx +++ b/src/pages/Filing/ViewInstitutionProfile/DisplayField.tsx @@ -59,8 +59,8 @@ export function DisplayField({ label, value, className, - fallbackValue, - alertStatus, + fallbackValue = NOT_APPLICABLE, + alertStatus = 'warning', }: DisplayFieldProperties): JSX.Element { // This is needed otherwise a falsy value will only fallback if value is null or undefined // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -83,11 +83,3 @@ export function DisplayField({
); } - -DisplayField.defaultProps = { - alertStatus: 'warning', - className: undefined, - fallbackValue: NOT_APPLICABLE, - label: undefined, - value: undefined, -}; diff --git a/src/pages/Filing/ViewInstitutionProfile/FinancialInstitutionDetails.tsx b/src/pages/Filing/ViewInstitutionProfile/FinancialInstitutionDetails.tsx index 6ed27000f..e0c336a6b 100644 --- a/src/pages/Filing/ViewInstitutionProfile/FinancialInstitutionDetails.tsx +++ b/src/pages/Filing/ViewInstitutionProfile/FinancialInstitutionDetails.tsx @@ -39,10 +39,10 @@ const defaultDescription = ( export function FinancialInstitutionDetails({ data = {} as InstitutionDetailsApiType, - heading, + heading = 'Financial institution details', isDomainsVisible = true, description = defaultDescription, - alertStatus, + alertStatus = 'warning', }: { data: InstitutionDetailsApiType | undefined; heading?: ReactNode; @@ -112,9 +112,4 @@ export function FinancialInstitutionDetails({ ); } -FinancialInstitutionDetails.defaultProps = { - alertStatus: 'warning', - heading: 'Financial institution details', -}; - export default FinancialInstitutionDetails; diff --git a/src/pages/Filing/ViewInstitutionProfile/IdentifyingInformation.tsx b/src/pages/Filing/ViewInstitutionProfile/IdentifyingInformation.tsx index 868a99e5e..54c17934c 100644 --- a/src/pages/Filing/ViewInstitutionProfile/IdentifyingInformation.tsx +++ b/src/pages/Filing/ViewInstitutionProfile/IdentifyingInformation.tsx @@ -24,7 +24,7 @@ export function IdentifyingInformation({ data = {} as InstitutionDetailsApiType, heading = 'Financial institution identifying information', description = defaultDescription, - alertStatus, + alertStatus = 'warning', }: { data: InstitutionDetailsApiType | undefined; heading?: string; @@ -94,7 +94,4 @@ export function IdentifyingInformation({ ); } -IdentifyingInformation.defaultProps = { - alertStatus: 'warning', -}; export default IdentifyingInformation; diff --git a/src/pages/FilingDetails/VoluntaryReporterStatus.tsx b/src/pages/FilingDetails/VoluntaryReporterStatus.tsx index da8a4e0ae..a14ec3467 100644 --- a/src/pages/FilingDetails/VoluntaryReporterStatus.tsx +++ b/src/pages/FilingDetails/VoluntaryReporterStatus.tsx @@ -1,8 +1,8 @@ import Links from 'components/CommonLinks'; import FieldGroup from 'components/FieldGroup'; +import InputErrorMessage from 'components/InputErrorMessage'; import SectionIntro from 'components/SectionIntro'; import { RadioButton } from 'design-system-react'; -import InputErrorMessage from 'components/InputErrorMessage'; import type { FieldErrors } from 'react-hook-form'; import type { FilingDetailsSchema } from 'types/formTypes'; import RadioButtonGroup from '../../components/RadioButtonGroup'; @@ -69,11 +69,4 @@ function VoluntaryReporterStatus({ ); } -VoluntaryReporterStatus.defaultProps = { - disabled: false, - formErrors: undefined, - onChange: undefined, - value: undefined, -}; - export default VoluntaryReporterStatus; diff --git a/src/pages/FilingDetails/index.tsx b/src/pages/FilingDetails/index.tsx index 20f7bde9a..b4c2c384b 100644 --- a/src/pages/FilingDetails/index.tsx +++ b/src/pages/FilingDetails/index.tsx @@ -26,6 +26,7 @@ import { VrsFormHeaderErrors, } from 'components/FormErrorHeader.data'; import FormMain from 'components/FormMain'; +import FormParagraph from 'components/FormParagraph'; import InputErrorMessage from 'components/InputErrorMessage'; import { Link } from 'components/Link'; import { LoadingContent } from 'components/Loading'; @@ -50,12 +51,11 @@ import useFilingStatus from 'utils/useFilingStatus'; import useInstitutionDetails from 'utils/useInstitutionDetails'; import useSubmitPointOfContact from 'utils/useSubmitPointOfContact'; import useSubmitVoluntaryReporterStatus from 'utils/useSubmitVoluntaryReporterStatus'; -import VoluntaryReporterStatus from './VoluntaryReporterStatus'; import { formatPointOfContactObject, formatVoluntaryReporterStatusObject, } from './FilingDetailsUtils'; -import FormParagraph from 'components/FormParagraph'; +import VoluntaryReporterStatus from './VoluntaryReporterStatus'; const defaultValuesPOC = { isVoluntary: undefined, @@ -485,8 +485,4 @@ function FilingDetails(): JSX.Element { ); } -FilingDetails.defaultProps = { - onSubmit: undefined, -}; - export default FilingDetails; diff --git a/src/pages/ProfileForm/CreateProfileForm/AddFinancialInstitution.tsx b/src/pages/ProfileForm/CreateProfileForm/AddFinancialInstitution.tsx index bfe68fa23..6b120e9fd 100644 --- a/src/pages/ProfileForm/CreateProfileForm/AddFinancialInstitution.tsx +++ b/src/pages/ProfileForm/CreateProfileForm/AddFinancialInstitution.tsx @@ -17,7 +17,7 @@ function AddFinancialInstitution({ index, register, formErrors, - isLast, + isLast = false, }: AddFinancialInstitutionProperties): JSX.Element { return (
@@ -50,8 +50,4 @@ function AddFinancialInstitution({ ); } -AddFinancialInstitution.defaultProps = { - isLast: false, -}; - export default AddFinancialInstitution; diff --git a/src/pages/Summary/Summary.tsx b/src/pages/Summary/Summary.tsx index 8554f65ab..008135f54 100644 --- a/src/pages/Summary/Summary.tsx +++ b/src/pages/Summary/Summary.tsx @@ -63,8 +63,4 @@ function Summary({ UserProfile }: SummaryProperties): JSX.Element | null { ); } -Summary.defaultProps = { - UserProfile: undefined, -}; - export default Summary;