Skip to content

Commit 5140cea

Browse files
TCA-499 more clean up
1 parent 03f2304 commit 5140cea

File tree

12 files changed

+27
-22
lines changed

12 files changed

+27
-22
lines changed

src-ts/.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ module.exports = {
9898
'error',
9999
'prefer-single'
100100
],
101+
'jsx-a11y/click-events-have-key-events': 'warn',
102+
'jsx-a11y/no-static-element-interactions': 'warn',
101103
'jsx-a11y/tabindex-no-positive': [
102104
'warn'
103105
],

src-ts/config/environments/environment.default.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-len */
12
import { EnvironmentConfigModel } from './environment-config.model'
23

34
const COMMUNITY_WEBSITE: string = 'https://www.topcoder-dev.com'

src-ts/config/environments/environment.dev.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-len */
12
import { EnvironmentConfigModel } from './environment-config.model'
23
import { EnvironmentConfigDefault } from './environment.default.config'
34

src-ts/config/environments/environment.prod.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-len */
12
import { EnvironmentConfigModel } from './environment-config.model'
23
import { EnvironmentConfigDefault } from './environment.default.config'
34

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type GenericDataObject = { [key: string]: string | GenericDataObject }

src-ts/lib/global-config.model.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ export interface GlobalConfig {
1111
}
1212
DISABLED_TOOLS?: Array<string>
1313
ENV: string
14-
GAMIFICATION: {
15-
ORG_ID: string
16-
},
1714
LOGGING: {
1815
PUBLIC_TOKEN: string
1916
SERVICE: string

src-ts/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export {
2929
xhrPostAsync,
3030
xhrPutAsync,
3131
} from './functions'
32+
export * from './generic-data-object.type'
3233
export * from './global-config.model'
3334
export * from './hooks'
3435
export * from './info-card'

src-ts/lib/profile-provider/profile.provider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import profileContext, { defaultProfileContextData } from './profile.context'
1111

1212
export const ProfileProvider: FC<{ children: ReactNode }> = ({ children }: { children: ReactNode }) => {
1313

14-
const [profileContextData, setProfileContextData]: [ProfileContextData, Dispatch<SetStateAction<ProfileContextData>>]
14+
const [profileContextData, setProfileContextData]:
15+
[ProfileContextData, Dispatch<SetStateAction<ProfileContextData>>]
1516
= useState<ProfileContextData>(defaultProfileContextData)
1617

1718
function changePassword(userId: number, request: ChangePasswordRequest): Promise<void> {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { GenericDataObject } from '../../../../../../lib'
12
import { LearnConfig } from '../../../../learn-config'
23
import { getUserCertificateUrl } from '../../../../learn.routes'
34
import { learnUrlGet, learnXhrPostAsync, learnXhrPutAsync } from '../../../functions'
@@ -7,8 +8,6 @@ import { UserCertificationUpdateProgressActions } from './user-certification-upd
78

89
const certProgressPath: string = 'certification-progresses'
910

10-
type GenericDataObject = { [key: string]: string | GenericDataObject }
11-
1211
export function completeCourse(
1312
certificationProgressId: string,
1413
certification: string,
@@ -37,7 +36,7 @@ export function startAsync(
3736
userId: number,
3837
certificationId: string,
3938
courseId: string,
40-
data: any,
39+
data: GenericDataObject,
4140
): Promise<LearnUserCertificationProgress> {
4241

4342
const url: string = learnUrlGet(certProgressPath, `${userId}`, certificationId, courseId)

src-ts/tools/work/work-lib/work-provider/work-functions/work.functions.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PaymentMethodResult, Stripe, StripeCardNumberElement } from '@stripe/stripe-js'
22

3-
import { Page, UserProfile } from '../../../../../lib'
3+
import { GenericDataObject, Page, UserProfile } from '../../../../../lib'
44

55
import { WorkByStatus } from './work-by-status.model'
66
import {
@@ -58,17 +58,14 @@ export async function createCustomerPaymentAsync(
5858

5959
// if we don't have the bare min, don't do anything
6060
if (!stripe || !cardNumber || !challenge) {
61-
return
61+
return undefined
6262
}
6363

6464
// initialize the payment method
6565
const payload: PaymentMethodResult = await stripe.createPaymentMethod({
6666
card: cardNumber,
6767
type: 'card',
6868
})
69-
if (!payload) {
70-
return
71-
}
7269

7370
// make the request to make the payment
7471
const paymentRequest: CustomerPaymentRequest = workFactoryBuildCustomerPaymentRequest(
@@ -122,8 +119,11 @@ export async function getByWorkIdAsync(workId: string): Promise<Challenge> {
122119
export function getGroupedByStatus(work: ReadonlyArray<Work>): { [status: string]: WorkByStatus } {
123120
const output: { [status: string]: WorkByStatus } = {}
124121
Object.entries(WorkStatusFilter)
125-
.forEach(([key, value]) => {
126-
const results: ReadonlyArray<Work> = workStoreGetFilteredByStatus(work, WorkStatusFilter[key as keyof typeof WorkStatusFilter])
122+
.forEach(([key]) => {
123+
const results: ReadonlyArray<Work> = workStoreGetFilteredByStatus(
124+
work,
125+
WorkStatusFilter[key as keyof typeof WorkStatusFilter],
126+
)
127127
output[key] = {
128128
count: results.length,
129129
messageCount: results.reduce((partialSum, a) => partialSum + (a.messageCount ?? 0), 0),
@@ -147,15 +147,15 @@ export function getStatusFilter(filterKey?: string): WorkStatusFilter | undefine
147147

148148
// get the filter key from the passed in key
149149
const workStatusFilter: keyof typeof WorkStatusFilter | undefined = Object.entries(WorkStatusFilter)
150-
.find(([key, value]) => key === filterKey)
150+
.find(([key]) => key === filterKey)
151151
?.[0] as keyof typeof WorkStatusFilter
152152

153153
// if the passed in key doesn't match any filter, return undefined;
154154
// otherwise, return the filter defined by the key
155155
return !workStatusFilter ? undefined : WorkStatusFilter[workStatusFilter]
156156
}
157157

158-
export async function updateAsync(type: WorkType, challenge: Challenge, intakeForm: any): Promise<void> {
158+
export async function updateAsync(type: WorkType, challenge: Challenge, intakeForm: GenericDataObject): Promise<void> {
159159
const workConfig: WorkTypeConfig = WorkTypeConfigs[type]
160160
const body: UpdateWorkRequest = workFactoryBuildUpdateRequest(workConfig, challenge, intakeForm)
161161
return workStoreUpdateAsync(body)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,10 @@ const Review: FC = () => {
275275
)
276276
}
277277

278-
let stripePromise: Promise<Stripe | null | undefined>
278+
let stripePromise: Promise<Stripe | null | undefined> | undefined
279279

280280
const output: () => JSX.Element = () => {
281+
281282
if (!stripePromise) {
282283
stripePromise = loadStripe(EnvironmentConfig.STRIPE.API_KEY, {
283284
apiVersion: EnvironmentConfig.STRIPE.API_VERSION,

src-ts/tools/work/work-self-service/intake-forms/save-after-login/SaveAfterLogin.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { FC, useEffect } from 'react'
22
import { NavigateFunction, useNavigate } from 'react-router-dom'
33

4-
import { LoadingSpinner } from '../../../../../lib'
5-
import { workCreateAsync, WorkIntakeFormRoutes, WorkType, workUpdateAsync } from '../../../work-lib'
4+
import { GenericDataObject, LoadingSpinner } from '../../../../../lib'
5+
import { Challenge, workCreateAsync, WorkIntakeFormRoutes, WorkType, workUpdateAsync } from '../../../work-lib'
66
import { selfServiceStartRoute } from '../../../work.routes'
77

88
/**
@@ -19,12 +19,12 @@ const SaveAfterLogin: FC = () => {
1919
useEffect(() => {
2020
const createAndUpdateAsync: () => Promise<void> = async () => {
2121
try {
22-
if (localStorage && localStorage.getItem('challengeInProgress') && localStorage.getItem('challengeInProgressType')) {
22+
if (localStorage.getItem('challengeInProgress') && localStorage.getItem('challengeInProgressType')) {
2323
const workType: WorkType = localStorage.getItem('challengeInProgressType') as WorkType
24-
const formData: any = JSON.parse(String(localStorage.getItem('challengeInProgress')))
24+
const formData: GenericDataObject = JSON.parse(String(localStorage.getItem('challengeInProgress')))
2525
formData.currentStep = 'review'
2626

27-
const challenge: any = await workCreateAsync(workType)
27+
const challenge: Challenge = await workCreateAsync(workType)
2828

2929
await workUpdateAsync(workType, challenge, formData)
3030

0 commit comments

Comments
 (0)