Skip to content

Commit

Permalink
feat(enums): add ButtonType enum
Browse files Browse the repository at this point in the history
  • Loading branch information
absolemDev committed Nov 24, 2023
1 parent 9ac4775 commit 84addff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/payment-widget/src/enums/button.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable no-shadow */
export enum ButtonType {
Submit = 'submit',
}
1 change: 1 addition & 0 deletions packages/payment-widget/src/enums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './payment-method.enum'
export * from './payment-object.enum'
export * from './tax.enum'
export * from './taxation.enum'
export * from './button.enum'
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ReactElement } from 'react'

import { ButtonType } from '../enums'
import { HandleBlurField } from './fields.interfaces'
import { HandleChangeField } from './fields.interfaces'

Expand All @@ -12,7 +13,7 @@ interface ChildrenInputProps {
}

interface ChildrenButtonProps {
type: string
type: ButtonType
disabled: boolean
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { FC } from 'react'

import { ButtonType } from '../../enums'
import { ButtonWrapperProps } from '../../interfaces'
import { useForm } from '../form'

export const ButtonWrapper: FC<ButtonWrapperProps> = ({ children }) => {
const { disabled } = useForm()
if (typeof children === 'function') {
return children({ type: 'submit', disabled })
return children({ type: ButtonType.Submit, disabled })
}

return null
Expand Down

0 comments on commit 84addff

Please sign in to comment.