Skip to content

Commit

Permalink
refactor: reuse isTextField typeguard function
Browse files Browse the repository at this point in the history
  • Loading branch information
loiclaudet committed Oct 5, 2023
1 parent f7a95e4 commit 60b2011
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FC } from 'react'
import { useTranslation } from 'react-i18next'
import * as O from 'fp-ts/Option'
import { flow, pipe } from 'fp-ts/lib/function'
import type { FormItem, TextField } from '@/ui/store/slice/shareData/shareData.slice'
import { isTextField, type TextField } from '@/ui/store/slice/shareData/shareData.slice'
import { Button } from '@/ui/component/button/button'
import { Icon } from '@/ui/component/icon/icon'
import { useAppStore } from '@/ui/store'
Expand All @@ -25,8 +25,6 @@ export const CompleteTransaction: FC = () => {
const getFieldValueForText = (item: TextField): string | undefined =>
pipe(item.value, O.toUndefined)

const isTextField = (item: FormItem): item is TextField => item.type === 'text'

const dataSetTitle = pipe(
dataSetTitleField,
O.map(flow(O.fromPredicate(isTextField), O.map(getFieldValueForText), O.toUndefined)),
Expand Down

0 comments on commit 60b2011

Please sign in to comment.