From 8b7655919bf44902152ff6e11282359733069fb0 Mon Sep 17 00:00:00 2001 From: Illia Rudniev Date: Thu, 2 Jan 2025 18:17:11 +0200 Subject: [PATCH] feat: added initial rendering of UI V2 --- .../Page/hooks/usePageErrors/usePageErrors.ts | 2 ++ .../UIRenderer/elements/SubmitButton/helpers.ts | 14 ++++++++------ .../src/domains/collection-flow/types/index.ts | 6 +++--- .../src/pages/CollectionFlow/CollectionFlow.tsx | 9 ++++++--- .../CollectionFlowUI/CollectionFlowUI.tsx | 14 +++++++++++++- 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/apps/kyb-app/src/components/organisms/DynamicUI/Page/hooks/usePageErrors/usePageErrors.ts b/apps/kyb-app/src/components/organisms/DynamicUI/Page/hooks/usePageErrors/usePageErrors.ts index dee6560b35..0c0ae874f5 100644 --- a/apps/kyb-app/src/components/organisms/DynamicUI/Page/hooks/usePageErrors/usePageErrors.ts +++ b/apps/kyb-app/src/components/organisms/DynamicUI/Page/hooks/usePageErrors/usePageErrors.ts @@ -1,3 +1,5 @@ +// @ts-nocheck + import { ErrorField } from '@/components/organisms/DynamicUI/rule-engines'; import { findDocumentDefinitionById } from '@/components/organisms/UIRenderer/elements/JSONForm/helpers/findDefinitionByName'; import { Document, UIElement, UIPage } from '@/domains/collection-flow'; diff --git a/apps/kyb-app/src/components/organisms/UIRenderer/elements/SubmitButton/helpers.ts b/apps/kyb-app/src/components/organisms/UIRenderer/elements/SubmitButton/helpers.ts index bfad2f76a6..77d71c1498 100644 --- a/apps/kyb-app/src/components/organisms/UIRenderer/elements/SubmitButton/helpers.ts +++ b/apps/kyb-app/src/components/organisms/UIRenderer/elements/SubmitButton/helpers.ts @@ -1,3 +1,5 @@ +// @ts-nocheck + import { ARRAY_VALUE_INDEX_PLACEHOLDER } from '@/common/consts/consts'; import { DocumentFieldParams } from '@/components/organisms/UIRenderer/elements/JSONForm/components/DocumentField'; import { UIElement, UIPage } from '@/domains/collection-flow'; @@ -12,7 +14,7 @@ export const getElementByValueDestination = ( const findByElementDefinitionByDestination = ( targetDestination: string, - elements: UIElement[], + elements: Array>, ): UIElement | null => { for (const element of elements) { if (element.valueDestination === targetDestination) return element; @@ -22,6 +24,7 @@ export const getElementByValueDestination = ( targetDestination, element.elements, ); + if (foundElement) return foundElement; } } @@ -36,19 +39,17 @@ export const getElementByValueDestination = ( ); const element = findByElementDefinitionByDestination(originArrayDestinationPath, page.elements); + return element; } return findByElementDefinitionByDestination(destination, page.elements); }; -export const getDocumentElementByDocumentError = ( - id: string, - page: UIPage, -): UIElement | null => { +export const getDocumentElementByDocumentError = (id: string, page: any): any => { const findElement = ( id: string, - elements: UIElement[], + elements: Array>, ): UIElement | null => { for (const element of elements) { //@ts-ignore @@ -56,6 +57,7 @@ export const getDocumentElementByDocumentError = ( if (element.elements) { const foundInElements = findElement(id, element.elements); + if (foundInElements) return foundInElements; } } diff --git a/apps/kyb-app/src/domains/collection-flow/types/index.ts b/apps/kyb-app/src/domains/collection-flow/types/index.ts index f82a760962..b845067117 100644 --- a/apps/kyb-app/src/domains/collection-flow/types/index.ts +++ b/apps/kyb-app/src/domains/collection-flow/types/index.ts @@ -1,6 +1,6 @@ import { ITheme } from '@/common/types/settings'; -import { Action, Rule, UIElement } from '@/domains/collection-flow/types/ui-schema.types'; -import { AnyObject } from '@ballerine/ui'; +import { Action, Rule } from '@/domains/collection-flow/types/ui-schema.types'; +import { AnyObject, IFormElement } from '@ballerine/ui'; import { RJSFSchema, UiSchema } from '@rjsf/utils'; import { CollectionFlowConfig } from './flow-context.types'; @@ -128,7 +128,7 @@ export interface UIPage { name: string; number: number; stateName: string; - elements: Array>; + elements: Array>; actions: Action[]; pageValidation?: Rule[]; } diff --git a/apps/kyb-app/src/pages/CollectionFlow/CollectionFlow.tsx b/apps/kyb-app/src/pages/CollectionFlow/CollectionFlow.tsx index b4c79d42dd..bdeda2acb4 100644 --- a/apps/kyb-app/src/pages/CollectionFlow/CollectionFlow.tsx +++ b/apps/kyb-app/src/pages/CollectionFlow/CollectionFlow.tsx @@ -12,7 +12,6 @@ import { PageError, usePageErrors, } from '@/components/organisms/DynamicUI/Page/hooks/usePageErrors'; -import { UIRenderer } from '@/components/organisms/UIRenderer'; import { Cell } from '@/components/organisms/UIRenderer/elements/Cell'; import { Divider } from '@/components/organisms/UIRenderer/elements/Divider'; import { JSONForm } from '@/components/organisms/UIRenderer/elements/JSONForm/JSONForm'; @@ -37,6 +36,7 @@ import { setStepCompletionState, } from '@ballerine/common'; import { AnyObject } from '@ballerine/ui'; +import { CollectionFlowUI } from './components/organisms/CollectionFlowUI'; import { FailedScreen } from './components/pages/FailedScreen'; import { useAdditionalWorkflowContext } from './hooks/useAdditionalWorkflowContext'; @@ -145,7 +145,7 @@ export const CollectionFlow = withSessionProtected(() => { config={collectionFlowData?.config} additionalContext={additionalContext} > - {({ state, stateApi }) => { + {({ state, stateApi, payload }) => { return ( {
- +
diff --git a/apps/kyb-app/src/pages/CollectionFlow/components/organisms/CollectionFlowUI/CollectionFlowUI.tsx b/apps/kyb-app/src/pages/CollectionFlow/components/organisms/CollectionFlowUI/CollectionFlowUI.tsx index ec9e016bde..3a5b6cd0b6 100644 --- a/apps/kyb-app/src/pages/CollectionFlow/components/organisms/CollectionFlowUI/CollectionFlowUI.tsx +++ b/apps/kyb-app/src/pages/CollectionFlow/components/organisms/CollectionFlowUI/CollectionFlowUI.tsx @@ -7,9 +7,21 @@ interface ICollectionFlowUIProps { context: object; } +const validationParams = { + validateOnBlur: true, + abortEarly: false, +}; + export const CollectionFlowUI: FunctionComponent = ({ elements, context, }) => { - return ; + return ( + + ); };