Skip to content

Commit

Permalink
fix: get-name-fields util
Browse files Browse the repository at this point in the history
  • Loading branch information
absolemDev committed Nov 29, 2023
1 parent cfc8b6b commit 759c5c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/payment-widget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const Form = () => <Widget settings={{ storeId: 'STORE_ID' }} />

```tsx
import { AdditionalFieldsType } from '@atls/react-payment-widget'
import { ButtonWrapper } from '@atls/react-payment-widget'
import { InputWrapper } from '@atls/react-payment-widget'
import { Widget } from '@atls/react-payment-widget'
import { ButtonWrapper } from '@atls/react-payment-widget'
import { InputWrapper } from '@atls/react-payment-widget'
import { Widget } from '@atls/react-payment-widget'
export const Form = () => (
<Widget amount={5000} settings={{ storeId: '1698844342541DEMO' }}>
<InputWrapper name={AdditionalFieldsType.Email}>{(props) => <Input {...props} />}</InputWrapper>
Expand Down
10 changes: 4 additions & 6 deletions packages/payment-widget/src/utils/get-name-fields.util.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { ReactNode } from 'react'
import { isValidElement } from 'react'
import { ReactNode } from 'react'
import { isValidElement } from 'react'

import { AdditionalFieldsType } from '../enums'
import { RequiredFieldsType } from '../enums'
import { Field } from '../interfaces'
import { Field } from '../interfaces'

export const getNameFields = (customFields: ReactNode[]) =>
customFields.reduce<Field[]>((acc, field) => {
if (isValidElement(field))
acc.push({
name: AdditionalFieldsType[field.props.name] || RequiredFieldsType[field.props.name],
name: field.props.name,
})
return acc
}, [])

0 comments on commit 759c5c0

Please sign in to comment.