Skip to content

Commit

Permalink
fix: Wrong key for line_2 attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
acasazza committed Mar 28, 2022
1 parent 7a5450d commit 03b84a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions src/components/BillingAddressForm.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import AddressesContext from '#context/AddressContext'
import useRapidForm from 'rapid-form'
import React, {
FunctionComponent,
ReactNode,
useContext,
useEffect,
useRef,
} from 'react'
import React, { ReactNode, useContext, useEffect, useRef } from 'react'
import BillingAddressFormContext from '#context/BillingAddressFormContext'
import { isEmpty } from 'lodash'
import { BaseError, CodeErrorType } from '#typings/errors'
Expand All @@ -26,7 +20,7 @@ type BillingAddressFormProps = {
errorClassName?: string
} & Omit<JSX.IntrinsicElements['form'], 'onSubmit'>

const BillingAddressForm: FunctionComponent<BillingAddressFormProps> = (
const BillingAddressForm: React.FunctionComponent<BillingAddressFormProps> = (
props
) => {
const {
Expand Down Expand Up @@ -92,7 +86,7 @@ const BillingAddressForm: FunctionComponent<BillingAddressFormProps> = (
isBusiness
)
if (!mandatory) delete values[name]
if (field?.value) {
if (field?.value || field?.required === false) {
values[name.replace('billing_address_', '')] = field.value
delete values[name]
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ShippingAddressForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const ShippingAddressForm: FunctionComponent<ShippingAddressFormProps> = (
isBusiness
)
if (!mandatory) delete values[name]
if (field?.value) {
if (field?.value || field?.required === false) {
values[name.replace('shipping_address_', '')] = field.value
delete values[name]
}
Expand Down

0 comments on commit 03b84a9

Please sign in to comment.