Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/ui/page/share/dataset/shareDataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export const ShareDataset: FC = () => {
hasStoredFiles: store.hasStoredFiles
}))

const { hasTextFieldValue } = useAppStore(state => ({
hasTextFieldValue: state.shareData.hasTextFieldValue
}))

const storageServiceSelection: StepElement = {
id: 'step1',
content: <ServiceStorageSelection />,
Expand All @@ -31,7 +35,11 @@ export const ShareDataset: FC = () => {
content: <DataSelection />,
validate: () => hasStoredFiles()()
}
const metadataFilling: StepElement = { id: 'step3', content: <MetadataFilling /> }
const metadataFilling: StepElement = {
id: 'step3',
content: <MetadataFilling />,
validate: hasTextFieldValue('input-field-1')
}
const summary: StepElement = { id: 'step4', content: <Summary /> }
const completeTransaction: StepElement = { id: 'step5', content: <CompleteTransaction /> }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'
import * as O from 'fp-ts/Option'
import { flow, pipe } from 'fp-ts/lib/function'
import { formatISODateToParts, localizedDateFormatter } from '@/util/date/date'
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 Down Expand Up @@ -147,8 +147,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
22 changes: 21 additions & 1 deletion src/ui/store/slice/shareData/shareData.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { IOEither } from 'fp-ts/IOEither'
import type { IOOption } from 'fp-ts/IOOption'
import type { Eq } from 'fp-ts/lib/Eq'
import type { Show } from 'fp-ts/lib/Show'
import type IO from 'fp-ts/IO'
import * as IO from 'fp-ts/IO'
import * as A from 'fp-ts/Array'
import * as IOE from 'fp-ts/IOEither'
import * as IOO from 'fp-ts/IOOption'
Expand Down Expand Up @@ -137,6 +137,7 @@ export type ShareDataSlice = {
id: string,
value: FormItemValue
) => IOEither<ResourceNotFoundError | PayloadIsEmptyError | FormItemWrongTypeError, void>
hasTextFieldValue: (id: FormItemId) => IO.IO<boolean>
}
}
const eqFormItemId: Eq<FormItemId> = S.Eq
Expand Down Expand Up @@ -286,6 +287,8 @@ export const isDateStringRange = (formItemValue: FormItemValue): formItemValue i
'from' in formItemValue &&
'to' in formItemValue

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

const updateFormItem =
(updatedValue: FormItemValue) =>
(formItem: FormItem): E.Either<FormItemWrongTypeError, FormItem> => {
Expand Down Expand Up @@ -433,6 +436,23 @@ export const createShareDataSlice: ShareDataStateCreator =
IOO.fromIO(() => get().shareData.form),
IOO.chainOptionK(flow(A.findFirst(formItem => eqFormItem.equals(formItem, { id }))))
),
hasTextFieldValue: (id: FormItemId) =>
pipe(
IOO.fromIO(() => get().shareData.form),
IOO.chainOptionK(flow(A.findFirst(formItem => eqFormItem.equals(formItem, { id })))),
IOO.flatMap(formItem =>
IOO.fromOption(
pipe(
formItem,
O.fromPredicate(isTextField),
O.flatMap(({ value }) => value),
O.map(S.trim),
O.map(isNotEmpty)
)
)
),
IOO.getOrElse(constant(IO.of(false)))
),
setFormItemValue: (id: string, value: FormItemValue) =>
pipe(
id,
Expand Down