Skip to content

Commit 7d9ef5e

Browse files
TCA-499 auto fixes
1 parent 8fc61aa commit 7d9ef5e

File tree

11 files changed

+61
-51
lines changed

11 files changed

+61
-51
lines changed

src-ts/lib/modals/base-modal/use-fetch-modal-content.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Dispatch, SetStateAction, useEffect, useState} from 'react'
1+
import { Dispatch, SetStateAction, useEffect, useState } from 'react'
22

33
import { xhrGetAsync } from '../../functions'
44

@@ -15,7 +15,8 @@ export function useFetchModalContent(contentUrl?: string, enabled?: boolean): Mo
1515
}
1616

1717
if (!content) {
18-
xhrGetAsync<string>(contentUrl).then(setContent)
18+
xhrGetAsync<string>(contentUrl)
19+
.then(setContent)
1920
}
2021
}, [contentUrl, content, enabled])
2122

src-ts/tools/learn/learn-lib/data-providers/all-certifications-provider/all-certifications.provider.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable default-param-last */
12
import useSWR, { SWRConfiguration, SWRResponse } from 'swr'
23

34
import { learnUrlGet } from '../../functions'
@@ -11,16 +12,16 @@ interface CertificationsAllProviderOptions {
1112

1213
export function useGetAllCertifications(
1314
providerName: string = 'freeCodeCamp',
14-
options?: CertificationsAllProviderOptions
15+
options?: CertificationsAllProviderOptions,
1516
): AllCertificationsProviderData {
1617

1718
const url: string = learnUrlGet(
1819
'certifications',
19-
`?providerName=${providerName}`
20+
`?providerName=${providerName}`,
2021
)
2122
const swrCacheConfig: SWRConfiguration = useSwrCache(url)
2223

23-
const {data, error}: SWRResponse = useSWR(url, {
24+
const { data, error }: SWRResponse = useSWR(url, {
2425
...swrCacheConfig,
2526
isPaused: () => options?.enabled === false,
2627
})
@@ -36,16 +37,16 @@ export function useGetAllCertifications(
3637
export function useGetCertification(
3738
providerName: string = 'freeCodeCamp',
3839
certificationId: string,
39-
options?: CertificationsAllProviderOptions
40+
options?: CertificationsAllProviderOptions,
4041
): AllCertificationsProviderData {
4142

4243
const url: string = learnUrlGet(
4344
'certifications',
4445
certificationId,
45-
`?providerName=${providerName}`
46+
`?providerName=${providerName}`,
4647
)
4748

48-
const {data, error}: SWRResponse = useSWR(url, {
49+
const { data, error }: SWRResponse = useSWR(url, {
4950
isPaused: () => options?.enabled === false,
5051
})
5152
return {

src-ts/tools/learn/learn-lib/data-providers/courses-provider/courses.provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { LearnCourse } from './learn-course.model'
99

1010
export function useGetCourses(
1111
provider: string,
12-
certification?: string
12+
certification?: string,
1313
): CoursesProviderData {
1414

1515
const params: string = [
@@ -22,7 +22,7 @@ export function useGetCourses(
2222
const url: string = learnUrlGet('courses', `?${params}`)
2323
const swrCacheConfig: SWRConfiguration = useSwrCache(url)
2424

25-
const {data, error}: SWRResponse<ReadonlyArray<LearnCourse>> = useSWR(url, swrCacheConfig)
25+
const { data, error }: SWRResponse<ReadonlyArray<LearnCourse>> = useSWR(url, swrCacheConfig)
2626

2727
return {
2828
course: get(data, [0]),

src-ts/tools/learn/learn-lib/data-providers/lesson-provider/lesson.provider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export function useGetLesson(
2121
courseData?.key ?? course,
2222
module,
2323
lesson,
24-
].filter(Boolean).join('/')
24+
]
25+
.filter(Boolean)
26+
.join('/')
2527

2628
return {
2729
lesson: !lessonData ? undefined : {

src-ts/tools/learn/learn-lib/data-providers/resource-provider-provider/resource-provider.provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export function useGetResourceProvider(providerName?: string): ResourceProviderD
1212
const url: string = learnUrlGet('providers')
1313
const swrCacheConfig: SWRConfiguration = useSwrCache(url)
1414

15-
const {data, error}: SWRResponse<ReadonlyArray<ResourceProvider>> = useSWR(url, swrCacheConfig)
15+
const { data, error }: SWRResponse<ReadonlyArray<ResourceProvider>> = useSWR(url, swrCacheConfig)
1616

1717
return {
1818
loading: !data && !error,
19-
provider: find(data, {name: providerName}),
19+
provider: find(data, { name: providerName }),
2020
ready: !!data || !!error,
2121
}
2222
}

src-ts/tools/learn/learn-lib/data-providers/user-certifications-provider/user-certification-progress.provider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { LearnUserCertificationProgress } from './user-certifications-functions'
99
export function useGetUserCertificationProgress(
1010
userId?: number,
1111
provider?: string,
12-
certification?: string
12+
certification?: string,
1313
):
1414
UserCertificationProgressProviderData {
1515

@@ -28,10 +28,10 @@ export function useGetUserCertificationProgress(
2828
})
2929

3030
return {
31-
certificationProgress: find(data, {certification}),
31+
certificationProgress: find(data, { certification }),
3232
loading: !!userId && !data && !error,
3333
ready: !userId || data || error,
3434
refetch: () => mutate(),
35-
setCertificateProgress: (progress) => mutate([progress]),
35+
setCertificateProgress: progress => mutate([progress]),
3636
}
3737
}

src-ts/tools/learn/learn-lib/data-providers/user-certifications-provider/user-certifications.provider.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,25 @@ export function useGetUserCertifications(
2929
})
3030
const loading: boolean = !data && !error
3131

32-
const completed: ReadonlyArray<UserCertificationCompleted> = useMemo(() => data
33-
?.filter(c => c.status === UserCertificationProgressStatus.completed)
34-
.map(c => c as UserCertificationCompleted)
35-
.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()) ?? []
36-
, [data])
37-
38-
const inProgress: ReadonlyArray<UserCertificationInProgress> = useMemo(() => data
39-
?.filter(c => c.status === UserCertificationProgressStatus.inProgress)
40-
.map(c => c as UserCertificationInProgress)
41-
.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()) ?? []
42-
, [data])
32+
const completed: ReadonlyArray<UserCertificationCompleted> = useMemo(
33+
() => data
34+
?.filter(c => c.status === UserCertificationProgressStatus.completed)
35+
.map(c => c as UserCertificationCompleted)
36+
.sort((a, b) => new Date(b.updatedAt)
37+
.getTime() - new Date(a.updatedAt)
38+
.getTime()) ?? [],
39+
[data],
40+
)
41+
42+
const inProgress: ReadonlyArray<UserCertificationInProgress> = useMemo(
43+
() => data
44+
?.filter(c => c.status === UserCertificationProgressStatus.inProgress)
45+
.map(c => c as UserCertificationInProgress)
46+
.sort((a, b) => new Date(b.updatedAt)
47+
.getTime() - new Date(a.updatedAt)
48+
.getTime()) ?? [],
49+
[data],
50+
)
4351

4452
if (error) {
4553
errorHandle(error, 'There was an error getting your course progress.')

src-ts/tools/learn/learn-lib/data-providers/user-completed-certifications-provider/user-completed-certifications.provider.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ import { UserCompletedCertificationsProviderData } from './user-completed-certif
88
export function useGetUserCompletedCertifications(
99
userId?: number,
1010
provider?: string,
11-
certification?: string
11+
certification?: string,
1212
): UserCompletedCertificationsProviderData {
1313

1414
const url: string = learnUrlGet('completed-certifications', `${userId}`)
1515

16-
const {data, error}: SWRResponse<ReadonlyArray<LearnUserCompletedCertification>> = useSWR(url)
16+
const { data, error }: SWRResponse<ReadonlyArray<LearnUserCompletedCertification>> = useSWR(url)
1717

1818
let certifications: ReadonlyArray<LearnUserCompletedCertification> = data ?? []
1919

2020
if (provider || certification) {
21-
certifications = certifications.filter((c) => {
22-
return (!provider || c.provider === provider) &&
23-
(!certification || c.certification === certification)
24-
})
21+
certifications = certifications
22+
.filter(c => (!provider || c.provider === provider)
23+
&& (!certification || c.certification === certification))
2524
}
2625

2726
return {

src-ts/tools/learn/learn-lib/learn-swr/LearnSwr.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@ interface LearnSwrProps {
77
children: ReactNode
88
}
99

10-
const LearnSwr: FC<LearnSwrProps> = (props: LearnSwrProps) => {
11-
12-
return (
13-
<SWRConfig
14-
value={{
15-
fetcher: (resource) => learnXhrGetAsync(resource),
16-
refreshInterval: 0,
17-
revalidateOnFocus: false,
18-
revalidateOnMount: true,
19-
}}
20-
>
21-
{props.children}
22-
</SWRConfig>
23-
)
24-
}
10+
const LearnSwr: FC<LearnSwrProps> = (props: LearnSwrProps) => (
11+
<SWRConfig
12+
value={{
13+
fetcher: resource => learnXhrGetAsync(resource),
14+
refreshInterval: 0,
15+
revalidateOnFocus: false,
16+
revalidateOnMount: true,
17+
}}
18+
>
19+
{props.children}
20+
</SWRConfig>
21+
)
2522

2623
export default LearnSwr

src-ts/tools/learn/learn-lib/learn-swr/use-swr-cache.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ if (typeof window !== 'undefined') {
1010

1111
// parse the loaded data, and load it into swr's in-memory cache
1212
if (cacheMap) {
13-
Object.entries(cacheMap).forEach(([key, data]) => {
14-
mutate(key, data, {revalidate: false})
15-
})
13+
Object.entries(cacheMap)
14+
.forEach(([key, data]) => {
15+
mutate(key, data, { revalidate: false })
16+
})
1617
}
1718
}
1819

src-ts/tools/work/work-self-service/intake-forms/review/Review.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ const output: () => JSX.Element = () => {
283283
apiVersion: EnvironmentConfig.STRIPE.API_VERSION,
284284
})
285285
}
286+
286287
return (
287288
<Elements stripe={stripePromise as Promise<Stripe>}>
288289
<Review />

0 commit comments

Comments
 (0)