Skip to content

Commit 57fa621

Browse files
Merge branch 'TCA-499_eslint' into TCA-499_eslint_fix-linting
2 parents 820dcbb + c845574 commit 57fa621

File tree

90 files changed

+2459
-2705
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2459
-2705
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ install_dependency: &install_dependency
2828
install_deploysuite: &install_deploysuite
2929
name: Installation of install_deploysuite.
3030
command: |
31-
git clone --branch v1.4.6 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
31+
git clone --branch v1.4.11 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
3232
cp ./../buildscript/master_deploy.sh .
3333
cp ./../buildscript/buildenv.sh .
3434
cp ./../buildscript/awsconfiguration.sh .

src-ts/.eslintrc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
],
6666
'complexity': [
6767
'error',
68-
7
68+
11
6969
],
7070
'import/extensions': 'off',
7171
'import/prefer-default-export': 'off',
@@ -83,6 +83,10 @@ module.exports = {
8383
'jsx-a11y/tabindex-no-positive': [
8484
'warn'
8585
],
86+
'max-len': [
87+
'error',
88+
120,
89+
],
8690
'no-extra-boolean-cast': 'off',
8791
'no-null/no-null': 'error',
8892
'no-plusplus': [

src-ts/declarations.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ declare module '*.md' {
2424
const value: string
2525
export default value
2626
}
27+
28+
declare module '*.txt' {
29+
const value: string
30+
export default value
31+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export {
22
dateLocaleShortString as textFormatDateLocaleShortString,
3+
getSafeString as textFormatGetSafeString,
34
moneyLocaleString as textFormatMoneyLocaleString,
45
} from './text-format.functions'

src-ts/lib/functions/text-format-functions/text-format.functions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export function dateLocaleShortString(date?: Date): string | undefined {
99
)
1010
}
1111

12+
export function getSafeString(param?: string): string {
13+
return param ?? ''
14+
}
15+
1216
export function moneyLocaleString(amount?: number): string | undefined {
1317
return amount?.toLocaleString('en-US', {
1418
currency: 'USD', // TODO: handle other currencies

src-ts/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export {
1919
logInfo,
2020
logInitialize,
2121
textFormatDateLocaleShortString,
22+
textFormatGetSafeString,
2223
textFormatMoneyLocaleString,
2324
xhrCreateInstance,
2425
xhrDeleteAsync,

src-ts/lib/modals/base-modal/BaseModal.module.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
@import '../../styles/includes';
22
@import '../../styles/typography';
33

4+
:global(.react-responsive-modal-root) {
5+
:global(.react-responsive-modal-overlay),
6+
:global(.react-responsive-modal-modal) {
7+
animation-fill-mode:forwards !important;
8+
}
9+
10+
}
11+
412
.modal-header {
513
padding: 5px 0 0;
614
}
@@ -14,7 +22,7 @@
1422
overflow: auto;
1523
margin: 0 -1*$space-xxxxl -1*$space-xxxxl;
1624
padding: 0 $space-xxxxl $space-xxxxl;
17-
25+
1826
display: flex;
1927
flex-direction: column;
2028

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,59 @@
1-
import { FC } from 'react'
1+
import { FC, ReactNode } from 'react'
22
import Modal, { ModalProps } from 'react-responsive-modal'
33
import classNames from 'classnames'
44

5+
import { LoadingSpinner } from '../../loading-spinner'
56
import { IconOutline } from '../../svgs'
67

8+
import { ModalContentResponse, useFetchModalContent } from './use-fetch-modal-content'
79
import styles from './BaseModal.module.scss'
810

911
export interface BaseModalProps extends ModalProps {
12+
contentClassName?: string
13+
contentUrl?: string
1014
size?: 'lg' | 'md'
1115
title: string
1216
}
1317

14-
const BaseModal: FC<BaseModalProps> = ({
15-
children,
16-
title,
17-
...props
18-
}: BaseModalProps) => (
19-
<Modal
20-
{...props}
21-
classNames={{ modal: `modal-${props.size || 'md'}` }}
22-
closeIcon={<IconOutline.XIcon width={28} height={28} />}
23-
>
24-
<div className={styles['modal-header']}>
25-
<h3>{title}</h3>
26-
</div>
27-
28-
<hr className={styles.spacer} />
29-
30-
<div className={classNames(styles['modal-body'], 'modal-body')}>
31-
{children}
32-
</div>
33-
</Modal>
34-
)
18+
const BaseModal: FC<BaseModalProps> = (props: BaseModalProps) => {
19+
20+
const { content }: ModalContentResponse = useFetchModalContent(props.contentUrl, props.open)
21+
22+
const renterContent: () => ReactNode = () => {
23+
if (props.children || !props.contentUrl) {
24+
return undefined
25+
}
26+
27+
if (!content) {
28+
return <LoadingSpinner />
29+
}
30+
31+
return (
32+
<div
33+
className={props.contentClassName}
34+
dangerouslySetInnerHTML={{ __html: content }}
35+
/>
36+
)
37+
}
38+
39+
return (
40+
<Modal
41+
{...props}
42+
classNames={{ modal: `modal-${props.size || 'md'}` }}
43+
closeIcon={<IconOutline.XIcon width={28} height={28} />}
44+
>
45+
<div className={styles['modal-header']}>
46+
<h3>{props.title}</h3>
47+
</div>
48+
49+
<hr className={styles.spacer} />
50+
51+
<div className={classNames(styles['modal-body'], 'modal-body')}>
52+
{renterContent()}
53+
{props.children}
54+
</div>
55+
</Modal>
56+
)
57+
}
3558

3659
export default BaseModal
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {Dispatch, SetStateAction, useEffect, useState} from 'react'
2+
3+
import { xhrGetAsync } from '../../functions'
4+
5+
export interface ModalContentResponse {
6+
content: string | undefined
7+
}
8+
9+
export function useFetchModalContent(contentUrl?: string, enabled?: boolean): ModalContentResponse {
10+
const [content, setContent]: [string|undefined, Dispatch<SetStateAction<string|undefined>>] = useState()
11+
12+
useEffect(() => {
13+
if (!contentUrl || !enabled) {
14+
return
15+
}
16+
17+
if (!content) {
18+
xhrGetAsync<string>(contentUrl).then(setContent)
19+
}
20+
}, [contentUrl, content, enabled])
21+
22+
return { content }
23+
}

src-ts/lib/modals/order-contract-modal/OrderContractModal.module.scss

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
p {
1414
margin-bottom: 20px;
1515

16-
&.sm {
16+
&:global(.sm) {
1717
font-size: 14px;
1818
}
1919
}
2020
}
21-
22-
.topCoderLink {
23-
text-decoration: underline;
24-
color: $link-blue-light;
25-
}

0 commit comments

Comments
 (0)