Skip to content

TCA-645 Auto-fix Lint Issues -> TCA-499_eslint #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src-ts/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ import { Logo } from './logo'
import { ToolSelectors } from './tool-selectors'
import { UtilitySelectors } from './utility-selectors'

const Header: FC<{}> = () => {
return (
<div className={styles['header-wrap']}>
<header className={styles.header}>
<ToolSelectors isWide={false} />
<Logo />
<ToolSelectors isWide={true} />
<UtilitySelectors />
</header>
<div id='page-subheader-portal-el' className={styles.subheader}></div>
</div>
)
}
const Header: FC<{}> = () => (
<div className={styles['header-wrap']}>
<header className={styles.header}>
<ToolSelectors isWide={false} />
<Logo />
<ToolSelectors isWide />
<UtilitySelectors />
</header>
<div id='page-subheader-portal-el' className={styles.subheader} />
</div>
)

export default Header
4 changes: 1 addition & 3 deletions src-ts/header/tool-selectors/ToolSelectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ interface ToolSelectorsProps {
isWide: boolean
}

const ToolSelectors: FC<ToolSelectorsProps> = (props: ToolSelectorsProps) => {
return props.isWide ? <ToolSelectorsWide /> : <ToolSelectorsNarrow />
}
const ToolSelectors: FC<ToolSelectorsProps> = (props: ToolSelectorsProps) => props.isWide ? <ToolSelectorsWide /> : <ToolSelectorsNarrow />

export default ToolSelectors
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ToolSelectorWide: FC<ToolSelectorWideProps> = (props: ToolSelectorWideProp
>
{toolRoute.title}
</Link>
<div className={styles['active-indicator']}></div>
<div className={styles['active-indicator']} />
</div>
)
}
Expand Down
14 changes: 6 additions & 8 deletions src-ts/header/utility-selectors/UtilitySelectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import { FC } from 'react'
import ProfileSelector from './UtilitySelector/ProfileSelector/ProfileSelector'
import styles from './UtilitySelectors.module.scss'

const UtilitySelectors: FC<{}> = () => {
return (
<div className={styles['utility-selectors']}>
{/* TODO: make this configurable */}
<ProfileSelector />
</div>
)
}
const UtilitySelectors: FC<{}> = () => (
<div className={styles['utility-selectors']}>
{/* TODO: make this configurable */}
<ProfileSelector />
</div>
)

export default UtilitySelectors
32 changes: 16 additions & 16 deletions src-ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
export { default as AppNextGen } from './App'
export { EnvironmentConfig } from './config'
export {
Analytics,
Breadcrumb,
ContactSupportModal,
logInitialize,
OrderContractModal,
PageFooter,
PrivacyPolicyModal,
profileContext,
ProfileProvider,
RouteProvider,
TabsNavbar,
TermsModal,
xhrGetAsync,
xhrGetBlobAsync,
xhrPatchAsync,
xhrPostAsync,
Analytics,
Breadcrumb,
ContactSupportModal,
logInitialize,
OrderContractModal,
PageFooter,
PrivacyPolicyModal,
profileContext,
ProfileProvider,
RouteProvider,
TabsNavbar,
TermsModal,
xhrGetAsync,
xhrGetBlobAsync,
xhrPatchAsync,
xhrPostAsync,
} from './lib'
export * from './tools'
export * from './utils'
Expand Down
15 changes: 6 additions & 9 deletions src-ts/lib/analytics/Analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { FC } from 'react'
import { GoogleTagManager } from './google-tag-manater'
import { SegmentAnalytics } from './segment-analytics'

const Analytics: FC<{}> = () => {

return (
<>
<GoogleTagManager />
<SegmentAnalytics />
</>
)
}
const Analytics: FC<{}> = () => (
<>
<GoogleTagManager />
<SegmentAnalytics />
</>
)

export default Analytics
18 changes: 8 additions & 10 deletions src-ts/lib/breadcrumb/breadcrumb-item/BreadcrumbItem.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { FC } from 'react'
import { Link } from 'react-router-dom'

import styles from './../Breadcrumb.module.scss'
import styles from "../Breadcrumb.module.scss"
import { BreadcrumbItemModel } from './breadcrumb-item.model'

interface BreadcrumbItemProps {
index: number
item: BreadcrumbItemModel
}

const BreadcrumbItem: FC<BreadcrumbItemProps> = (props: BreadcrumbItemProps) => {
return (
<li key={props.index} onClick={() => props.item.onClick?.(props.item)}>
<Link className={props.item.isElipsis && styles['elipsis']} to={props.item.url}>
{props.item.name}
</Link>
</li>
)
}
const BreadcrumbItem: FC<BreadcrumbItemProps> = (props: BreadcrumbItemProps) => (
<li key={props.index} onClick={() => props.item.onClick?.(props.item)}>
<Link className={props.item.isElipsis && styles.elipsis} to={props.item.url}>
{props.item.name}
</Link>
</li>
)

export default BreadcrumbItem
8 changes: 4 additions & 4 deletions src-ts/lib/contact-support-form/ContactSupportForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const ContactSupportForm: FC<ContactSupportFormProps> = (props: ContactSupportFo
const [saveOnSuccess, setSaveOnSuccess]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)

useEffect(() => {
if (!loading && saveOnSuccess) {
props.onSave()
}
if (!loading && saveOnSuccess) {
props.onSave()
}
}, [loading, saveOnSuccess])

function generateRequest(inputs: ReadonlyArray<FormInputModel>): ContactSupportRequest {
Expand All @@ -47,7 +47,7 @@ const ContactSupportForm: FC<ContactSupportFormProps> = (props: ContactSupportFo
setLoading(true)
return contactSupportSubmitRequestAsync(request)
.then(() => {
setSaveOnSuccess(true)
setSaveOnSuccess(true)
}).finally(() => setLoading(false))
}

Expand Down
50 changes: 24 additions & 26 deletions src-ts/lib/content-layout/ContentLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,40 @@ export interface ContentLayoutProps {
titleClass?: string
}

const ContentLayout: FC<ContentLayoutProps> = (props: ContentLayoutProps) => {
return (
<div className={classNames(styles.content, props.contentClass)}>
const ContentLayout: FC<ContentLayoutProps> = (props: ContentLayoutProps) => (
<div className={classNames(styles.content, props.contentClass)}>

<div className={classNames(styles['content-outer'], props.outerClass)}>
<div className={classNames(styles['content-outer'], props.outerClass)}>

<div className={classNames(styles['content-inner'], props.innerClass)}>
<div className={classNames(styles['content-inner'], props.innerClass)}>

{!!props.title && (
<div className={classNames(styles['page-header'], props.titleClass)}>
{!!props.title && (
<div className={classNames(styles['page-header'], props.titleClass)}>

<h1>
{props.title}
</h1>
<h1>
{props.title}
</h1>

{!!props.buttonConfig && (
<div>
<Button
{...props.buttonConfig}
buttonStyle='primary'
size='lg'
/>
</div>
)}
{!!props.buttonConfig && (
<div>
<Button
{...props.buttonConfig}
buttonStyle='primary'
size='lg'
/>
</div>
)}

</div>
)}
</div>
)}

{props.children}

</div>
{props.children}

</div>

</div>
)
}

</div>
)

export default ContentLayout
58 changes: 27 additions & 31 deletions src-ts/lib/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ const Form: <ValueType extends any, RequestType extends any>(props: FormProps<Va
inputs,
])

useEffect(() => {
return () => {
if (props.resetFormOnUnmount) {
onReset()
}
useEffect(() => () => {
if (props.resetFormOnUnmount) {
onReset()
}
}, [])

Expand Down Expand Up @@ -148,34 +146,32 @@ const Form: <ValueType extends any, RequestType extends any>(props: FormProps<Va
formInitializeValues(inputs, props.formValues)

const setOnClickOnReset: (button: FormButton) => FormButton = (button) => {
// if this is a reset button, set its onclick to reset
if (!!button.isReset) {
button = {
...button,
onClick: onReset,
}
}

return button
}
// if this is a reset button, set its onclick to reset
if (!!button.isReset) {
button = {
...button,
onClick: onReset,
}
}

const createButtonGroup: (groups: ReadonlyArray<FormButton>, isPrimaryGroup: boolean) => Array<JSX.Element> = (groups, isPrimaryGroup) => {
return groups.map((button, index) => {
button = setOnClickOnReset(button)

const disabled: boolean = (button.isSubmit && isFormInvalid) || !!props.shouldDisableButton?.(isPrimaryGroup, index)

return (
<Button
{...button}
key={button.label || `button-${index}`}
disable={disabled}
tabIndex={button.notTabble ? -1 : index + (inputs ? inputs.length : 0) + (formDef.tabIndexStart || 0)}
/>
)
})
return button
}

const createButtonGroup: (groups: ReadonlyArray<FormButton>, isPrimaryGroup: boolean) => Array<JSX.Element> = (groups, isPrimaryGroup) => groups.map((button, index) => {
button = setOnClickOnReset(button)

const disabled: boolean = (button.isSubmit && isFormInvalid) || !!props.shouldDisableButton?.(isPrimaryGroup, index)

return (
<Button
{...button}
key={button.label || `button-${index}`}
disable={disabled}
tabIndex={button.notTabble ? -1 : index + (inputs ? inputs.length : 0) + (formDef.tabIndexStart || 0)}
/>
)
})

const secondaryGroupButtons: Array<JSX.Element> = createButtonGroup(formDef.buttons.secondaryGroup || [], false)

const primaryGroupButtons: Array<JSX.Element> = createButtonGroup(formDef.buttons.primaryGroup, true)
Expand All @@ -197,7 +193,7 @@ const Form: <ValueType extends any, RequestType extends any>(props: FormProps<Va

return (
<form
action={''}
action=""
className={styles.form}
key={formKey}
onSubmit={onSubmitAsync}
Expand Down
6 changes: 3 additions & 3 deletions src-ts/lib/form/form-functions/form.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ export async function onSubmitAsync<T>(
toast.success(safeSuccessMessage)
onSuccess?.()
})
.catch(error => {
return Promise.reject(error.response?.data?.result?.content || error.message || error)
})
.catch(error => Promise.reject(error.response?.data?.result?.content || error.message || error))
}

function handleFieldEvent<T>(input: HTMLInputElement | HTMLTextAreaElement, inputs: ReadonlyArray<FormInputModel>, event: 'blur' | 'change', formValues?: T): void {
Expand All @@ -126,6 +124,7 @@ function handleFieldEvent<T>(input: HTMLInputElement | HTMLTextAreaElement, inpu
if (event === 'change') {
inputDef.dirty = input.value !== originalValue
}

inputDef.touched = true

// set the def value
Expand Down Expand Up @@ -174,6 +173,7 @@ function validateField(formInputDef: FormInputModel, formElements: HTMLFormContr
if (!nextError) {
formInputDef.error = undefined
}

return
}

Expand Down
20 changes: 9 additions & 11 deletions src-ts/lib/form/form-groups/FormGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,15 @@ const FormGroups: (props: FormGroupsProps) => JSX.Element = (props: FormGroupsPr
}

const formGroups: Array<JSX.Element | undefined> = formDef?.groups
?.map((element: FormGroup, index: number) => {
return (
<FormGroupItem
key={`element-${index}`}
group={element}
renderFormInput={renderInputField}
totalGroupCount={formDef.groups?.length || 0}
renderDividers={props.formDef.groupsOptions?.renderGroupDividers}
/>
)
})
?.map((element: FormGroup, index: number) => (
<FormGroupItem
key={`element-${index}`}
group={element}
renderFormInput={renderInputField}
totalGroupCount={formDef.groups?.length || 0}
renderDividers={props.formDef.groupsOptions?.renderGroupDividers}
/>
))
|| []

return (
Expand Down
Loading