Skip to content

Commit

Permalink
feat: updated UI & added DynamicForm & storybook & style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chesterkmr committed Aug 3, 2023
1 parent fdeec75 commit c06f234
Show file tree
Hide file tree
Showing 69 changed files with 403 additions and 159 deletions.
6 changes: 6 additions & 0 deletions .changeset/orange-beds-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@ballerine/kyb-app': patch
'@ballerine/ui': patch
---

added DynamicForm & TextArea & css fixes

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { stateContext } from './state.context';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { AnyChildren, AnyObject } from '@ballerine/ui';
import { AnyChildren, AnyObject, InputsWarnings } from '@ballerine/ui';
import { View, ViewStateContext } from '@app/common/providers/ViewStateProvider/types';
import { ViewResolver } from '@app/common/providers/ViewStateProvider/components/ViewResolver';
import { useStepper } from '@app/common/hooks/useStepper';
Expand All @@ -9,7 +9,6 @@ import { getInitialStepIndexFromContext } from '@app/common/providers/ViewStateP
import { convertViewsToPaths } from '@app/common/providers/ViewStateProvider/utils/convertViewsToPaths';
import { ViewsData } from '@app/common/providers/ViewStateProvider/hooks/useViewsDataRepository/types';
import { useViewsDataRepository } from '@app/common/providers/ViewStateProvider/hooks/useViewsDataRepository';
import { InputsWarnings } from '@app/common/components/organisms/DynamicForm';

const { Provider } = stateContext;
interface Props<TContext extends ViewsData> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { InputsWarnings } from '@app/common/components/organisms/DynamicForm';
import { IStep, StepMetadata } from '@app/common/hooks/useStepper';
import { AnyObject } from '@ballerine/ui';
import { AnyObject, InputsWarnings } from '@ballerine/ui';

export type SchemaBase = { states: AnyObject };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { base64ToFile } from '@app/common/utils/base64-to-file';
import { parseBase64FileWithMetadata } from '@app/common/utils/parse-base64-file-with-metadata';
import { getFilesId } from '@app/components/organisms/KYBView/helpers/get-file-ids';
import { WorkflowFlowData } from '@app/domains/workflows/flow-data.type';
import { WorkflowUpdatePayload } from '@app/domains/workflows/types';
import { base64ToFile } from '@ballerine/ui';
import { v4 as uuidv4 } from 'uuid';

export const serializeWorkflowRunData = async (
Expand Down
1 change: 0 additions & 1 deletion examples/kyb-app/src/components/organisms/KYBView/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const kybViews: View[] = [
label: 'Company Activity',
key: 'companyActivity',
Component: CompanyActivityView,
active: true,
},
{
label: 'Bank Information',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DynamicForm } from '@app/common/components/organisms/DynamicForm';
import { AppShell } from '@app/components/layouts/AppShell';
import { useViewState } from '@app/common/providers/ViewStateProvider';
import { WorkflowFlowData } from '@app/domains/workflows/flow-data.type';
import { BankInformationContext } from './types';
import { bankInformationSchema } from '@app/components/organisms/KYBView/views/BankInformationView/bank-information.schema';
import { bankInformationUISchema } from '@app/components/organisms/KYBView/views/BankInformationView/bank-information.ui-schema';
import { DynamicForm } from '@ballerine/ui';

export const BankInformationView = () => {
const { context, saveAndPerformTransition } = useViewState<WorkflowFlowData>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { UiSchema } from '@rjsf/utils';

export const bankInformationUISchema: UiSchema = {
'ui:options': {
submitButtonOptions: {
submitText: 'Continue',
},
},
country: {
'ui:placeholder': 'United Kingdom',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DynamicForm } from '@app/common/components/organisms/DynamicForm';
import { useViewState } from '@app/common/providers/ViewStateProvider';
import { AppShell } from '@app/components/layouts/AppShell';
import { companyActivitySchema } from '@app/components/organisms/KYBView/views/CompanyActivityView/companyActivity.schema';
import { companyActivityUISchema } from '@app/components/organisms/KYBView/views/CompanyActivityView/companyActivity.ui-schema';
import { WorkflowFlowData } from '@app/domains/workflows/flow-data.type';
import { DynamicForm } from '@ballerine/ui';

export const CompanyActivityView = () => {
const { context, saveAndPerformTransition } = useViewState<WorkflowFlowData>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { UiSchema } from '@rjsf/utils';

export const companyActivityUISchema: UiSchema = {
'ui:options': {
submitButtonOptions: {
submitText: 'Continue',
},
},
industry: {
'ui:placeholder': 'Food & Beverages',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { DynamicForm } from '@app/common/components/organisms/DynamicForm';
import { useViewState } from '@app/common/providers/ViewStateProvider';
import { AppShell } from '@app/components/layouts/AppShell';
import { ViewHeader } from '@app/components/organisms/KYBView/components/ViewHeader';
import { companyDocumentsSchema } from '@app/components/organisms/KYBView/views/CompanyDocumentsView/company-documents.schema.';
import { companyDocumetsUISchema } from '@app/components/organisms/KYBView/views/CompanyDocumentsView/company-documents.ui-schema';
import { DocumentsContext, WorkflowFlowData } from '@app/domains/workflows/flow-data.type';
import { DynamicForm } from '@ballerine/ui';
import { useCallback } from 'react';

export const CompanyDocumentsView = () => {
const { context, state, warnings, saveAndPerformTransition } = useViewState<WorkflowFlowData>();
const { context, state, warnings, save, finish } = useViewState<WorkflowFlowData>();

const handleSubmit = useCallback(
(values: DocumentsContext) => {
void saveAndPerformTransition(values);
void save(values).then(finalContext => {
finish(finalContext);
});
},
[saveAndPerformTransition],
[save, finish],
);

return (
<AppShell.FormContainer header={<ViewHeader />}>
<DynamicForm<DocumentsContext>
Expand All @@ -25,7 +26,7 @@ export const CompanyDocumentsView = () => {
formData={context.flowData[state] as DocumentsContext}
uiSchema={companyDocumetsUISchema}
onSubmit={values => {
void handleSubmit(values);
void handleSubmit(values as DocumentsContext);
}}
warnings={warnings}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { UiSchema } from '@rjsf/utils';

export const companyDocumetsUISchema: UiSchema = {
'ui:options': {
submitButtonOptions: {
submitText: 'Continue',
},
},
registrationCertificate: {
'ui:field': 'FileInput',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DynamicForm } from '@app/common/components/organisms/DynamicForm';
import { useViewState } from '@app/common/providers/ViewStateProvider';
import { AppShell } from '@app/components/layouts/AppShell';
import { companyInformationSchema } from '@app/components/organisms/KYBView/views/CompanyInformationView/company-information.schema';
import { companyInformationUISchema } from '@app/components/organisms/KYBView/views/CompanyInformationView/company-information.ui-schema';
import { WorkflowFlowData } from '@app/domains/workflows/flow-data.type';
import { DynamicForm } from '@ballerine/ui';

export const CompanyInformationView = () => {
const { context, saveAndPerformTransition } = useViewState<WorkflowFlowData>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { UiSchema } from '@rjsf/utils';

export const companyInformationUISchema: UiSchema = {
'ui:options': {
submitButtonOptions: {
submitText: 'Continue',
},
},
registrationNumber: {
'ui:placeholder': 'CRN12345678',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DynamicForm } from '@app/common/components/organisms/DynamicForm';
import { useViewState } from '@app/common/providers/ViewStateProvider';
import { AppShell } from '@app/components/layouts/AppShell';
import { headquartersSchema } from '@app/components/organisms/KYBView/views/HeadquartersView/headquarters.schema';
import { headquartersUISchema } from '@app/components/organisms/KYBView/views/HeadquartersView/headquarters.ui-schema';
import { HeadquartersContext } from '@app/components/organisms/KYBView/views/HeadquartersView/types';
import { WorkflowFlowData } from '@app/domains/workflows/flow-data.type';
import { DynamicForm } from '@ballerine/ui';

export const HeadquartersView = () => {
const { context, saveAndPerformTransition } = useViewState<WorkflowFlowData>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { UiSchema } from '@rjsf/utils';

export const headquartersUISchema: UiSchema = {
'ui:options': {
submitButtonOptions: {
submitText: 'Continue',
},
},
address: {
'ui:placeholder': '10 Downing Street, London, UK, SW1A 2AA',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { DynamicForm } from '@app/common/components/organisms/DynamicForm';
import { useViewState } from '@app/common/providers/ViewStateProvider';
import { AppShell } from '@app/components/layouts/AppShell';
import { ViewHeader } from '@app/components/organisms/KYBView/components/ViewHeader';
Expand All @@ -9,6 +8,7 @@ import {
PersonalInformationContext,
WorkflowFlowData,
} from '@app/domains/workflows/flow-data.type';
import { DynamicForm } from '@ballerine/ui';
import { useCallback } from 'react';

export const PersonalInformationView = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import { DynamicForm } from '@app/common/components/organisms/DynamicForm';
import { useViewState } from '@app/common/providers/ViewStateProvider';
import { AppShell } from '@app/components/layouts/AppShell';
import { useCallback } from 'react';
import { shareholdersSchema } from './shareholders.schema';
import { ViewHeader } from '@app/components/organisms/KYBView/components/ViewHeader';
import { UBOSContext, WorkflowFlowData } from '@app/domains/workflows/flow-data.type';
import { FinalView } from '@app/components/organisms/KYBView/views/ShareholdersView/components/FinalView';
import { shareholdersUISchema } from '@app/components/organisms/KYBView/views/ShareholdersView/shareholders.ui-schema';
import { DynamicForm } from '@ballerine/ui';

export const ShareholdersView = () => {
const { context, state, isFinished, save, finish } = useViewState<WorkflowFlowData>();

const handleSubmit = useCallback(
(values: UBOSContext[]) => {
void save(values).then(finalContext => {
finish(finalContext);
});
},
[save, finish],
);
const { context, state, isFinished, saveAndPerformTransition } = useViewState<WorkflowFlowData>();

return !isFinished ? (
<AppShell.FormContainer header={<ViewHeader />}>
Expand All @@ -27,7 +17,7 @@ export const ShareholdersView = () => {
schema={shareholdersSchema}
uiSchema={shareholdersUISchema}
formData={(context.flowData[state] as UBOSContext[]) || []}
onSubmit={values => handleSubmit(values)}
onSubmit={values => void saveAndPerformTransition(values)}
/>
</AppShell.FormContainer>
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { UiSchema } from '@rjsf/utils';

export const shareholdersUISchema: UiSchema = {
'ui:options': {
submitButtonOptions: {
submitText: 'Continue',
},
},
shareholders: {
items: {
name: {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"@radix-ui/react-popover": "^1.0.6",
"@radix-ui/react-scroll-area": "^1.0.2",
"@radix-ui/react-slot": "^1.0.1",
"@rjsf/core": "^5.9.0",
"@rjsf/utils": "^5.9.0",
"@rjsf/validator-ajv8": "^5.9.0",
"@tanstack/react-table": "^8.9.2",
"class-variance-authority": "^0.6.0",
"clsx": "^1.2.1",
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './enums';
export * from './types';
export * from './utils';
2 changes: 2 additions & 0 deletions packages/ui/src/common/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './base64-to-file';
export * from './file-to-base64';
Loading

0 comments on commit c06f234

Please sign in to comment.