Skip to content

Email and name issue -> intake form #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src-ts/lib/payment-form/PaymentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
} from '@stripe/react-stripe-js'
import { StripeCardCvcElementChangeEvent, StripeCardExpiryElementChangeEvent, StripeCardNumberElementChangeEvent } from '@stripe/stripe-js'
import cn from 'classnames'
import React, { Dispatch, SetStateAction, useState } from 'react'
import React, { Dispatch, SetStateAction, useContext, useState } from 'react'

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

const [formState, setFormState]: [FieldDirtyState, Dispatch<SetStateAction<FieldDirtyState>>] = useState<FieldDirtyState>({
cardCvv: false,
Expand Down Expand Up @@ -100,7 +101,7 @@ const PaymentForm: React.FC<PaymentFormProps> = (props: PaymentFormProps) => {
tabIndex={1}
type='text'
onChange={(event) => props.onUpdateField('email', event.target.value)}
value={props.formData.email}
value={profile?.email}
/>

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

<InputWrapper className={styles['input-wrapper']} label='Country' tabIndex={3} type='text' disabled={false}>
Expand Down
35 changes: 22 additions & 13 deletions src-ts/tools/work/work-self-service/intake-forms/review/Review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ const Review: React.FC = () => {
const intakeFormBH: any = response.metadata.find((item: ChallengeMetadata) => item.name === ChallengeMetadataName.intakeForm)
const form: any = JSON.parse(intakeFormBH.value).form
setFormData(JSON.parse(intakeFormBH.value).form)
const { profile: userProfile }: ProfileContextData = useContext<ProfileContextData>(profileContext)
setFormValues({
...formFieldValues,
email: userProfile?.email || '',
name: `${userProfile?.firstName} ${userProfile?.lastName}`,
price: `$${getPrice(form.basicInfo.packageType)}`,
})
}
Expand Down Expand Up @@ -228,6 +231,8 @@ const Review: React.FC = () => {
navigate(redirectUrl)
}

// console.log(formFieldValues, profile)

return (
<div className={styles['review-container']}>
{
Expand Down Expand Up @@ -267,19 +272,23 @@ const Review: React.FC = () => {
}
</div>
<div className={styles['right']}>
<div className={styles['payment-form-wrapper']}>
<div className={styles['form-header']}>
<h3 className={styles['price']}>{formFieldValues.price}</h3>
<div className={styles['label']}>Total Payment</div>
</div>
<PaymentForm
formData={formFieldValues}
onUpdateField={onUpdateField}
onPay={onPay}
isFormValid={isFormValid()}
error={isPaymentFailed}
/>
</div>
{
profile && (
<div className={styles['payment-form-wrapper']}>
<div className={styles['form-header']}>
<h3 className={styles['price']}>{formFieldValues.price}</h3>
<div className={styles['label']}>Total Payment</div>
</div>
<PaymentForm
formData={formFieldValues}
onUpdateField={onUpdateField}
onPay={onPay}
isFormValid={isFormValid()}
error={isPaymentFailed}
/>
</div>
)
}
{
isMobile && (
<InfoCard
Expand Down