Skip to content

Commit

Permalink
error management
Browse files Browse the repository at this point in the history
  • Loading branch information
ncomont committed Oct 30, 2023
1 parent 9aeceb0 commit 16cd40c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions clients/banking/src/components/DynamicFormBuilder.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { LakeAlert } from "@swan-io/lake/src/components/LakeAlert";
import { LakeLabel } from "@swan-io/lake/src/components/LakeLabel";
import { LakeSelect } from "@swan-io/lake/src/components/LakeSelect";
import { LakeText } from "@swan-io/lake/src/components/LakeText";
import { LakeTextInput } from "@swan-io/lake/src/components/LakeTextInput";
import { RadioGroup } from "@swan-io/lake/src/components/RadioGroup";
import { Space } from "@swan-io/lake/src/components/Space";
import { colors } from "@swan-io/lake/src/constants/design";
import { isNotNullishOrEmpty } from "@swan-io/lake/src/utils/nullish";
import { ReactNode, RefObject, forwardRef, useEffect, useImperativeHandle, useMemo } from "react";
import { FormConfig, combineValidators, useForm } from "react-ux-form";
Expand Down Expand Up @@ -122,15 +124,16 @@ const BeneficiaryDynamicForm = forwardRef(
fields.map(({ refreshDynamicFieldsOnChange: dynamic, example, ...field }) => (
<LakeLabel
key={field.key}
label={field.name}
label={field.name}
render={id =>
match(field)
.with({ __typename: "SelectField" }, ({ allowedValues }) => (
<Field name={field.key}>
{({ onChange, value, ref }) => (
{({ onChange, value, ref, error }) => (
<LakeSelect
id={id}
ref={ref}
error={error}
items={allowedValues.map(({ name, key: value }) => ({ name, value }))}
value={String(value)}
onValueChange={onChange}
Expand Down Expand Up @@ -164,9 +167,8 @@ const BeneficiaryDynamicForm = forwardRef(
value={String(value)}
onValueChange={onChange}
/>
{ isNotNullishOrEmpty(error) && (error) }

<Space height={24} />

<LakeText color={colors.negative[400]}>{error ?? " "}</LakeText>
</>
)}
</Field>
Expand Down

0 comments on commit 16cd40c

Please sign in to comment.