Skip to content

Commit 7df13c1

Browse files
authored
Merge pull request #211 from topcoder-platform/email-not-populating
Email and name issue -> intake form
2 parents f13167b + d999947 commit 7df13c1

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
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}>

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

0 commit comments

Comments
 (0)