Skip to content

Commit 7ee6dde

Browse files
author
Maria Mattlin
committed
Merge branch 'PROD-2321_bug-hunt-intake-form' into draft-links
2 parents d6189e8 + 938ce51 commit 7ee6dde

File tree

11 files changed

+78
-40
lines changed

11 files changed

+78
-40
lines changed

src-ts/lib/payment-form/PaymentForm.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {
55
} from '@stripe/react-stripe-js'
66
import { StripeCardCvcElementChangeEvent, StripeCardExpiryElementChangeEvent, StripeCardNumberElementChangeEvent } from '@stripe/stripe-js'
77
import cn from 'classnames'
8-
import React, { Dispatch, SetStateAction, useState } from 'react'
8+
import React, { Dispatch, SetStateAction, useContext, useState } from 'react'
99

10-
import { Button, OrderContractModal } from '..'
10+
import { Button, OrderContractModal, profileContext, ProfileContextData } from '..'
1111
import { InputText } from '../form/form-groups/form-input'
1212
import { InputWrapper } from '../form/form-groups/form-input/input-wrapper'
1313
import ReactSelect from '../react-select/ReactSelect'
@@ -52,6 +52,7 @@ const PaymentForm: React.FC<PaymentFormProps> = (props: PaymentFormProps) => {
5252
const [cardNumberError, setCardNumberError]: [string, Dispatch<string>] = useState<string>('')
5353
const [cardExpiryError, setCardExpiryError]: [string, Dispatch<string>] = useState<string>('')
5454
const [cardCVVError, setCardCVVError]: [string, Dispatch<string>] = useState<string>('')
55+
const { profile }: ProfileContextData = useContext<ProfileContextData>(profileContext)
5556

5657
const [formState, setFormState]: [FieldDirtyState, Dispatch<SetStateAction<FieldDirtyState>>] = useState<FieldDirtyState>({
5758
cardCvv: false,
@@ -100,7 +101,7 @@ const PaymentForm: React.FC<PaymentFormProps> = (props: PaymentFormProps) => {
100101
tabIndex={1}
101102
type='text'
102103
onChange={(event) => props.onUpdateField('email', event.target.value)}
103-
value={props.formData.email}
104+
value={profile?.email}
104105
/>
105106

106107
<div className={styles['label']}>Card Information</div>
@@ -174,7 +175,7 @@ const PaymentForm: React.FC<PaymentFormProps> = (props: PaymentFormProps) => {
174175
tabIndex={1}
175176
type='text'
176177
onChange={(event) => props.onUpdateField('name', event.target.value)}
177-
value={props.formData.name}
178+
value={`${profile?.firstName} ${profile?.lastName}`}
178179
/>
179180

180181
<InputWrapper className={styles['input-wrapper']} label='Country' tabIndex={3} type='text' disabled={false}>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"PHASE_ID_APPEALS": "1c24cfb3-5b0a-4dbd-b6bd-4b0dff5349c6",
3+
"PHASE_ID_APPEALS_RESPONSE": "797a6af7-cd3f-4436-9fca-9679f773bee9",
4+
"PHASE_ID_REGISTRATION": "a93544bc-c165-4af4-b55e-18f3593b457a",
5+
"PHASE_ID_REVIEW": "aa5a3f78-79e0-4bf7-93ff-b11e8f5b398b",
6+
"PHASE_ID_SUBMISSION": "6950164f-3c5e-4bdc-abc8-22aaf5a1bd49"
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { default as WorkStrings } from './strings.json'
2+
export { default as WorkConfigConstants } from './config.json'

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import moment from 'moment'
22

3-
import { WorkStrings } from '../../../work-constants'
3+
import { WorkConfigConstants, WorkStrings } from '../../../work-constants'
44
import {
55
Challenge,
66
ChallengeCreateBody,
@@ -10,14 +10,14 @@ import {
1010
ChallengePhase,
1111
ChallengePhaseName,
1212
ChallengeUpdateBody,
13+
PricePackageName,
1314
Work,
1415
WorkPrice,
15-
WorkPriceBreakdown,
1616
WorkPricesType,
17-
WorkPrize,
1817
WorkProgress,
1918
WorkProgressStep,
2019
WorkStatus,
20+
WorkTimelinePhase,
2121
WorkType,
2222
WorkTypeCategory,
2323
WorkTypeConfig,
@@ -157,12 +157,21 @@ export function buildUpdateBody(workTypeConfig: WorkTypeConfig, challenge: Chall
157157
}
158158
// ---- End Build Markdown string ---- //
159159

160+
// If the duration of the Submission phase depends on the package selected (i.e.: Bug Hunt),
161+
// then update the duration for that phase to the correct value
162+
const timeline: Array<WorkTimelinePhase> = workTypeConfig.timeline.map((phase) => {
163+
if (workTypeConfig.submissionPhaseDuration && phase.phaseId === WorkConfigConstants.PHASE_ID_SUBMISSION) {
164+
phase.duration = workTypeConfig.submissionPhaseDuration[formData[ChallengeMetadataName.packageType] as PricePackageName] || 0
165+
}
166+
return phase
167+
})
168+
160169
const body: ChallengeUpdateBody = {
161170
description: templateString.join(''),
162171
id: challenge.id,
163172
metadata: intakeMetadata,
164173
name: formData.projectTitle,
165-
phases: workTypeConfig.timeline,
174+
phases: timeline,
166175
prizeSets: priceConfig.getPrizeSets(priceConfig, formData.packageType),
167176
}
168177

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export * from './work-progress.model'
2020
export * from './work-progress-step.model'
2121
export * from './work-status-filter.enum'
2222
export * from './work-status.enum'
23+
export * from './work-timeline-phase.model'
2324
export {
2425
bugHuntConfig as workBugHuntConfig,
2526
WorkTypeConfigs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { WorkTimelinePhase } from './work-timeline-phase.model'
22

33
export interface WorkTimeline {
4-
[workType: string]: ReadonlyArray<WorkTimelinePhase>
4+
[workType: string]: Array<WorkTimelinePhase>
55
}
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { WorkConfigConstants } from '../../../work-constants'
2+
13
import { WorkTimeline } from './work-timeline.model'
24
import { WorkType } from './work-type.enum'
35

@@ -6,28 +8,28 @@ export const WorkTimelines: WorkTimeline = {
68
[WorkType.bugHunt]: [
79
{
810
// Registration
9-
duration: 259200, // 3 days
10-
phaseId: 'a93544bc-c165-4af4-b55e-18f3593b457a',
11+
duration: 43200, // 0.5 day
12+
phaseId: WorkConfigConstants.PHASE_ID_REGISTRATION,
1113
},
1214
{
1315
// Submission
14-
duration: 259200, // 3 days
15-
phaseId: '6950164f-3c5e-4bdc-abc8-22aaf5a1bd49',
16+
duration: 86400, // 1 day, will vary by package
17+
phaseId: WorkConfigConstants.PHASE_ID_SUBMISSION,
1618
},
1719
{
1820
// Review
19-
duration: 86400, // 1 day
20-
phaseId: 'aa5a3f78-79e0-4bf7-93ff-b11e8f5b398b',
21+
duration: 172800, // 2 days
22+
phaseId: WorkConfigConstants.PHASE_ID_REVIEW,
2123
},
2224
{
2325
// Appeals
24-
duration: 86400, // 1 day
25-
phaseId: '1c24cfb3-5b0a-4dbd-b6bd-4b0dff5349c6',
26+
duration: 43200, // 0.5 day
27+
phaseId: WorkConfigConstants.PHASE_ID_APPEALS,
2628
},
2729
{
2830
// Appeals response
29-
duration: 259200, // 3 days
30-
phaseId: '797a6af7-cd3f-4436-9fca-9679f773bee9',
31+
duration: 43200, // 0.5 day
32+
phaseId: WorkConfigConstants.PHASE_ID_APPEALS_RESPONSE,
3133
},
3234
],
3335
}

src-ts/tools/work/work-lib/work-provider/work-functions/work-store/work-type.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ export const WorkTypeConfigs: { [workType: string]: WorkTypeConfig } = {
3535
},
3636
shortDescription: 'Find bugs quickly and vigorously',
3737
startRoute: WorkIntakeFormRoutes[WorkType.bugHunt]['basicInfo'],
38+
submissionPhaseDuration: {
39+
'advanced': 172800, // 2 days
40+
'premium': 259200, // 3 days
41+
'standard': 86400, // 1 day
42+
},
3843
subtitle: `Conduct a time based testing bug hunt where Topcoder experts scramble to find bugs or issues in the system`,
3944
tags: [ChallengeTag.qa],
4045
timeline: WorkTimelines[WorkType.bugHunt],

src-ts/tools/work/work-lib/work-provider/work-functions/work-store/work-type.model.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChallengeTag } from './challenge-tag.enum'
2-
import { WorkPrice } from './work-price.model'
2+
import { PricePackageName, WorkPrice } from './work-price.model'
33
import { WorkTimelinePhase } from './work-timeline-phase.model'
44
import { WorkType } from './work-type.enum'
55

@@ -21,9 +21,12 @@ export interface WorkTypeConfig {
2121
}
2222
shortDescription: string,
2323
startRoute: string,
24+
submissionPhaseDuration?: {
25+
[key in PricePackageName]?: number
26+
},
2427
subtitle: string,
2528
tags: Array<ChallengeTag>,
26-
timeline: ReadonlyArray<WorkTimelinePhase>
29+
timeline: Array<WorkTimelinePhase>
2730
timelineTemplateId: string,
2831
title: string,
2932
trackId: string,

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

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ const Review: React.FC = () => {
7474
const intakeFormBH: any = response.metadata.find((item: ChallengeMetadata) => item.name === ChallengeMetadataName.intakeForm)
7575
const form: any = JSON.parse(intakeFormBH.value).form
7676
setFormData(JSON.parse(intakeFormBH.value).form)
77+
const { profile: userProfile }: ProfileContextData = useContext<ProfileContextData>(profileContext)
7778
setFormValues({
7879
...formFieldValues,
80+
email: userProfile?.email || '',
81+
name: `${userProfile?.firstName} ${userProfile?.lastName}`,
7982
price: `$${getPrice(form.basicInfo.packageType)}`,
8083
})
8184
}
@@ -228,6 +231,8 @@ const Review: React.FC = () => {
228231
navigate(redirectUrl)
229232
}
230233

234+
// console.log(formFieldValues, profile)
235+
231236
return (
232237
<div className={styles['review-container']}>
233238
{
@@ -267,19 +272,23 @@ const Review: React.FC = () => {
267272
}
268273
</div>
269274
<div className={styles['right']}>
270-
<div className={styles['payment-form-wrapper']}>
271-
<div className={styles['form-header']}>
272-
<h3 className={styles['price']}>{formFieldValues.price}</h3>
273-
<div className={styles['label']}>Total Payment</div>
274-
</div>
275-
<PaymentForm
276-
formData={formFieldValues}
277-
onUpdateField={onUpdateField}
278-
onPay={onPay}
279-
isFormValid={isFormValid()}
280-
error={isPaymentFailed}
281-
/>
282-
</div>
275+
{
276+
profile && (
277+
<div className={styles['payment-form-wrapper']}>
278+
<div className={styles['form-header']}>
279+
<h3 className={styles['price']}>{formFieldValues.price}</h3>
280+
<div className={styles['label']}>Total Payment</div>
281+
</div>
282+
<PaymentForm
283+
formData={formFieldValues}
284+
onUpdateField={onUpdateField}
285+
onPay={onPay}
286+
isFormValid={isFormValid()}
287+
error={isPaymentFailed}
288+
/>
289+
</div>
290+
)
291+
}
283292
{
284293
isMobile && (
285294
<InfoCard

src-ts/tools/work/work.routes.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,20 @@ export const workRoutes: Array<PlatformRoute> = [
6464
route: `bug-hunt/basic-info/:workId`,
6565
title: intakeFormsTitle,
6666
},
67-
// General
6867
{
69-
element: <WorkLoginPrompt />,
70-
route: `:workType/login-prompt`,
68+
element: <Review />,
69+
route: `bug-hunt/review`,
7170
title: intakeFormsTitle,
7271
},
7372
{
7473
element: <Review />,
75-
route: `:workType/review`,
74+
route: `bug-hunt/review/:workId`,
7675
title: intakeFormsTitle,
7776
},
77+
// General
7878
{
79-
element: <Review />,
80-
route: `:workType/review/:workId`,
79+
element: <WorkLoginPrompt />,
80+
route: `:workType/login-prompt`,
8181
title: intakeFormsTitle,
8282
},
8383
{

0 commit comments

Comments
 (0)