Skip to content

Commit

Permalink
fix: imports, interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
absolemDev committed Nov 20, 2023
1 parent 9f9f1d8 commit c3e7e80
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 26 deletions.
7 changes: 4 additions & 3 deletions packages/payment-widget/src/hooks/use-fields-render.hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { Layout } from '@atls-ui-parts/layout'
import React from 'react'
import { useIntl } from 'react-intl'

import { CustomInputProps } from '../interfaces'
import { Field } from '../interfaces'
import { HandleBlurField } from '../interfaces'
import { FieldState } from '../interfaces'
import { HandleChangeField } from '../interfaces'
import { FieldsErrors } from '../interfaces'
import { CustomInput } from '../interfaces/custom-elements.interfaces'
import { CustomInput } from '../interfaces'
import { MemoizedInput } from '../ui'
import { translate } from '../utils/translate.util'

Expand All @@ -20,15 +21,15 @@ export const useFieldsRenderer = (
handleChange: HandleChangeField,
handleBlur: HandleBlurField,
inputGaps: number,
customInput: CustomInput | undefined
customInput?: CustomInput
) => {
const intl = useIntl()

return fields.map((field, index, currentFields) => {
const translatePlaceholder = translate(intl, field.placeholder, field.placeholder)
const translateError = translate(intl, errors[field.name], errors[field.name])
const isNotLastField = index !== currentFields.length - 1
const inputProps = {
const inputProps: CustomInputProps = {
type: field.type ?? 'text',
name: field.name,
placeholder: translatePlaceholder,
Expand Down
7 changes: 7 additions & 0 deletions packages/payment-widget/src/interfaces/button.interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

export interface CustomButtonProps {
type: string
disabled: boolean
children?: React.ReactNode
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
import React from 'react'
import { FC } from 'react'

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

interface CustomInputProps {
type: string
name: string
placeholder: string
required: boolean
value: string
errorText: string
onChangeNative: HandleChangeField
onBlur: HandleBlurField
}

export interface CustomButtonProps {
type: string
disabled: boolean
children?: React.ReactNode
}
import { CustomButtonProps } from './button.interfaces'
import { CustomInputProps } from './input.interfaces'

export type CustomInput = FC<CustomInputProps>
export type CustomButton = FC<CustomButtonProps>
Expand Down
4 changes: 4 additions & 0 deletions packages/payment-widget/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ export * from './fields.interfaces'
export * from './settings.interfaces'
export * from './receipt.interfaces'
export * from './styles.interfaces'
export * from './custom-elements.interfaces'
export * from './theme.interfaces'
export * from './button.interfaces'
export * from './input.interfaces'
13 changes: 13 additions & 0 deletions packages/payment-widget/src/interfaces/input.interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { HandleBlurField } from './fields.interfaces'
import { HandleChangeField } from './fields.interfaces'

export interface CustomInputProps {
type: string
name: string
placeholder: string
required: boolean
value: string
errorText: string
onChangeNative: HandleChangeField
onBlur: HandleBlurField
}
2 changes: 1 addition & 1 deletion packages/payment-widget/src/ui/button/button.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'
import { FC } from 'react'
import { useHover } from 'react-laag'

import { CustomButtonProps } from '../../interfaces/custom-elements.interfaces'
import { CustomButtonProps } from '../../interfaces'
import { appearanceStyles } from './button.styles'
import { contentStyles } from './button.styles'
import { baseStyles } from './button.styles'
Expand Down
3 changes: 2 additions & 1 deletion packages/payment-widget/src/ui/form.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { FormEventHandler } from 'react'
import { FormattedMessage } from 'react-intl'

import { CustomButtonProps } from '../interfaces'
import { WidgetProps } from '../interfaces'
import { Button } from './button/button.component'
import { Fields } from './fields.component'
Expand Down Expand Up @@ -32,7 +33,7 @@ export const Form = ({
makePayment(event)
}
}
const buttonProps = {
const buttonProps: CustomButtonProps = {
type: 'submit',
disabled: !isLoaded || !!disabled,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ThemeProvider as EmotionThemeProvider } from '@emotion/react'
import React from 'react'
import { FC } from 'react'

import { ThemeProps } from '../../../interfaces/theme.interfaces'
import { ThemeProps } from '../../../interfaces'

export const ThemeProvider: FC<ThemeProps> = ({ useCustomTheme, children }) =>
useCustomTheme ? (
Expand Down

0 comments on commit c3e7e80

Please sign in to comment.