Skip to content

Commit 534bfd9

Browse files
committed
Lint fixes
1 parent 147b220 commit 534bfd9

File tree

4 files changed

+37
-20
lines changed

4 files changed

+37
-20
lines changed

src/apps/admin/src/lib/components/DefaultReviewersAddForm/DefaultReviewersAddForm.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ export const DefaultReviewersAddForm: FC<Props> = (props: Props) => {
148148

149149
const onSubmit = useCallback(
150150
(data: FormAddDefaultReviewer) => {
151-
const requestBody = _.pickBy(data, _.identity)
151+
const requestBody = _.omitBy(
152+
data,
153+
value => value === undefined || value === null || value === '',
154+
)
152155
if (isEdit) {
153156
doUpdateDefaultReviewer(requestBody, () => {
154157
navigate('./../..')

src/apps/review/src/pages/scorecards/EditScorecardPage/components/BasicSelect.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
import { forwardRef, SelectHTMLAttributes } from 'react'
22
import classNames from 'classnames'
33

4-
interface BasicSelectProps<T> extends SelectHTMLAttributes<T> {
5-
options: { label: string; value: string|boolean|number }[];
6-
mapValue?: (value: any) => string;
4+
interface BasicSelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
5+
options: { label: string; value: string | boolean | number }[];
6+
mapValue?: (value: string | number | boolean | '') => string;
77
placeholder?: string;
88
}
99

10-
const BasicSelect = forwardRef<HTMLSelectElement, BasicSelectProps<any>>((
11-
props,
10+
const BasicSelect = forwardRef<HTMLSelectElement, BasicSelectProps>((
11+
props: BasicSelectProps,
1212
ref,
1313
) => {
14-
const { className, options, placeholder, value, mapValue: _mapValue, ...rest } = props
14+
const {
15+
className,
16+
options,
17+
placeholder,
18+
value,
19+
mapValue,
20+
...rest
21+
}: BasicSelectProps = props
1522

16-
const normalizedValue = value === null || value === undefined ? '' : value
23+
const normalizedValue = value === null || value === undefined ? '' : String(value)
24+
const displayValue = typeof mapValue === 'function'
25+
? mapValue(normalizedValue)
26+
: normalizedValue
1727

1828
return (
1929
<select
@@ -25,7 +35,7 @@ const BasicSelect = forwardRef<HTMLSelectElement, BasicSelectProps<any>>((
2535
!normalizedValue && `${normalizedValue}` !== 'false' && 'empty',
2636
)
2737
}
28-
value={normalizedValue as any}
38+
value={displayValue}
2939
>
3040
<option
3141
key='placeholder-option'
@@ -34,10 +44,10 @@ const BasicSelect = forwardRef<HTMLSelectElement, BasicSelectProps<any>>((
3444
>
3545
{placeholder}
3646
</option>
37-
{options.map((option, index) => (
47+
{options.map(option => (
3848
<option
39-
key={`${option.value ?? option.label ?? index}-${index}`}
40-
value={`${option.value ?? ''}`}
49+
key={String(option.value ?? option.label)}
50+
value={String(option.value ?? '')}
4151
>
4252
{option.label}
4353
</option>

src/apps/review/src/pages/scorecards/EditScorecardPage/components/ScorecardInfoForm.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ const toChallengeTrackLabel = (value: string): string => (
7070
)
7171

7272
const legacyChallengeTrackMap: Record<string, string> = {
73-
DEVELOPMENT: 'DEVELOPMENT',
7473
DEVELOP: 'DEVELOPMENT',
75-
QUALITY_ASSURANCE: 'QUALITY_ASSURANCE',
74+
DEVELOPMENT: 'DEVELOPMENT',
7675
QA: 'QUALITY_ASSURANCE',
76+
QUALITY_ASSURANCE: 'QUALITY_ASSURANCE',
7777
}
7878

7979
const normalizeTrackOptionValue = (track: useFetchChallengeTracksProps['challengeTracks'][number]): string => {
@@ -140,15 +140,16 @@ const ScorecardInfoForm: FC = () => {
140140
const form = useFormContext()
141141
const { challengeTracks }: useFetchChallengeTracksProps = useFetchChallengeTracks()
142142
const { challengeTypes }: useFetchChallengeTypesProps = useFetchChallengeTypes()
143-
const { getValues, setValue } = form
143+
const { getValues, setValue }: Pick<typeof form, 'getValues' | 'setValue'> = form
144144
const normalizeValue = useCallback((
145145
value: string | number | boolean | null | undefined,
146146
): string | undefined => {
147147
if (value === null || value === undefined) {
148148
return undefined
149149
}
150150

151-
const normalized = String(value).trim()
151+
const normalized = String(value)
152+
.trim()
152153

153154
return normalized.length ? normalized : undefined
154155
}, [])

src/apps/review/src/pages/scorecards/EditScorecardPage/components/ScorecardQuestionForm.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,20 @@ const ScorecardQuestionForm: FC<ScorecardQuestionFormProps> = (props: ScorecardQ
172172
<BasicSelect
173173
options={scorecardScaleOptions}
174174
{...{
175-
mapValue: (value: string) => (
176-
`${value?.toLowerCase()}${
177-
value === 'SCALE'
175+
mapValue: (value: string | number | boolean | '') => {
176+
const stringValue = typeof value === 'string'
177+
? value
178+
: String(value ?? '')
179+
return `${stringValue.toLowerCase()}${
180+
stringValue === 'SCALE'
178181
? `(${
179182
get(values, `${name}.${index}.scaleMin`)
180183
}-${
181184
get(values, `${name}.${index}.scaleMax`)
182185
})`
183186
: ''
184187
}`
185-
),
188+
},
186189
onChange: ((
187190
ev: ChangeEvent<HTMLInputElement>,
188191
field: any,

0 commit comments

Comments
 (0)