Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into bal-3619
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemLavrentii committed Feb 27, 2025
2 parents c9804c3 + 588cd2c commit 8357918
Show file tree
Hide file tree
Showing 23 changed files with 160 additions and 45 deletions.
7 changes: 7 additions & 0 deletions apps/backoffice-v2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @ballerine/backoffice-v2

## 0.7.106

### Patch Changes

- @ballerine/workflow-browser-sdk@0.6.98
- @ballerine/workflow-node-sdk@0.6.98

## 0.7.105

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions apps/backoffice-v2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ballerine/backoffice-v2",
"version": "0.7.105",
"version": "0.7.106",
"description": "Ballerine - Backoffice",
"homepage": "https://github.com/ballerine-io/ballerine",
"type": "module",
Expand Down Expand Up @@ -54,8 +54,8 @@
"dependencies": {
"@ballerine/blocks": "0.2.34",
"@ballerine/common": "0.9.77",
"@ballerine/workflow-browser-sdk": "0.6.97",
"@ballerine/workflow-node-sdk": "0.6.97",
"@ballerine/workflow-browser-sdk": "0.6.98",
"@ballerine/workflow-node-sdk": "0.6.98",
"@ballerine/react-pdf-toolkit": "^1.2.79",
"@ballerine/ui": "^0.5.79",
"@botpress/webchat": "^2.1.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,24 @@ export const columns = [
},
header: 'Report ID',
}),
columnHelper.accessor('business.correlationId', {
cell: info => {
// eslint-disable-next-line react-hooks/rules-of-hooks -- ESLint doesn't like `cell` not being `Cell`.
const { ref, styles } = useEllipsesWithTitle<HTMLSpanElement>();
const merchantId = info.getValue() ?? info.row.original.business?.id;

return (
<div className={`flex w-full max-w-[12ch] items-center space-x-2`}>
<TextWithNAFallback style={{ ...styles, width: '70%' }} ref={ref}>
{merchantId}
</TextWithNAFallback>

<CopyToClipboardButton textToCopy={merchantId ?? ''} />
</div>
);
},
header: 'Merchant ID',
}),
columnHelper.accessor('status', {
meta: {
useWrapper: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const useMerchantMonitoringTableLogic = () => {
{children}
</Link>
) : (
children
<div className={`d-full flex p-1 opacity-50`}>{children}</div>
);
};

Expand Down
7 changes: 7 additions & 0 deletions apps/kyb-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# kyb-app

## 0.3.134

### Patch Changes

- Bump
- @ballerine/workflow-browser-sdk@0.6.98

## 0.3.133

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions apps/kyb-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/kyb-app",
"private": true,
"version": "0.3.133",
"version": "0.3.134",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -18,7 +18,7 @@
"dependencies": {
"@ballerine/blocks": "0.2.34",
"@ballerine/common": "^0.9.77",
"@ballerine/workflow-browser-sdk": "0.6.97",
"@ballerine/workflow-browser-sdk": "0.6.98",
"@ballerine/ui": "0.5.79",
"@lukemorales/query-key-factory": "^1.0.3",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import dayjs from 'dayjs';
import uniqBy from 'lodash/uniqBy';
import ajvErrors from 'ajv-errors';
import { AnyObject } from '@ballerine/ui';
import Ajv, { ErrorObject } from 'ajv/dist/2019';
import ajvErrors from 'ajv-errors';
import addFormats, { FormatName } from 'ajv-formats';
import Ajv, { ErrorObject } from 'ajv/dist/2019';
import dayjs from 'dayjs';
import uniqBy from 'lodash/uniqBy';

import { Rule, UIElement } from '@/domains/collection-flow';
import {
ErrorField,
RuleEngine,
} from '@/components/organisms/DynamicUI/rule-engines/rule-engine.abstract';
import { Rule, UIElement } from '@/domains/collection-flow';

const addCustomFormats = (validator: Ajv) => {
validator.addFormat('non-past-date', {
Expand All @@ -24,6 +24,33 @@ const addCustomFormats = (validator: Ajv) => {
return inputDate.startOf('day').valueOf() >= dayjs().startOf('day').valueOf();
},
});

validator.addFormat('minAge', {
type: 'string',
validate: (dateString: string, schema?: { minAge?: number }) => {
const inputDate = dayjs(dateString);

if (!inputDate.isValid()) {
return false;
}

// Default to 18 if not specified
const requiredAge = schema?.minAge || 18;
const today = dayjs();
const birthDate = dayjs(dateString);

// Calculate age
let age = today.year() - birthDate.year();
const monthDiff = today.month() - birthDate.month();

// Adjust age if birthday hasn't occurred yet this year
if (monthDiff < 0 || (monthDiff === 0 && today.date() < birthDate.date())) {
age--;
}

return age >= requiredAge;
},
});
};

export class JsonSchemaRuleEngine implements RuleEngine {
Expand Down
1 change: 1 addition & 0 deletions apps/kyb-app/src/domains/collection-flow/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export interface UIOptions {
success?: string;
failure?: string;
};
disableLanguageSelection?: boolean;
}

export interface UISchema {
Expand Down
4 changes: 4 additions & 0 deletions apps/kyb-app/src/helpers/transform-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export const transformRJSFErrors = (errors: RJSFValidationError[]): RJSFValidati
error.message = 'Please provide valid email address.';
}

if (error.params?.format === 'minAge18') {
error.message = 'You must be at least 18 years old to apply.';
}

return error;
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,29 @@ export const CollectionFlowV1 = withSessionProtected(() => {
const [isLogoLoaded, setLogoLoaded] = useState(customer?.logoImageUri ? false : true);

useEffect(() => {
if (!customer?.logoImageUri) return;
if (!customer?.logoImageUri) {
return;
}

// Resseting loaded state in case of logo change
setLogoLoaded(false);
}, [customer?.logoImageUri]);

if (getCollectionFlowState(initialContext)?.status === CollectionFlowStatusesEnum.approved)
if (getCollectionFlowState(initialContext)?.status === CollectionFlowStatusesEnum.approved) {
return <Approved />;
}

if (getCollectionFlowState(initialContext)?.status === CollectionFlowStatusesEnum.rejected)
if (getCollectionFlowState(initialContext)?.status === CollectionFlowStatusesEnum.rejected) {
return <Rejected />;
}

if (getCollectionFlowState(initialContext)?.status === CollectionFlowStatusesEnum.completed)
if (getCollectionFlowState(initialContext)?.status === CollectionFlowStatusesEnum.completed) {
return <CompletedScreen />;
}

if (getCollectionFlowState(initialContext)?.status === CollectionFlowStatusesEnum.failed)
if (getCollectionFlowState(initialContext)?.status === CollectionFlowStatusesEnum.failed) {
return <FailedScreen />;
}

return definition && collectionFlowData ? (
<DynamicUI initialState={initialUIState}>
Expand Down Expand Up @@ -184,11 +190,17 @@ export const CollectionFlowV1 = withSessionProtected(() => {
>
{() => {
// Temp state, has to be resolved to success or failure by plugins
if (state === 'done') return <LoadingScreen />;
if (state === 'done') {
return <LoadingScreen />;
}

if (isCompleted(state)) return <CompletedScreen />;
if (isCompleted(state)) {
return <CompletedScreen />;
}

if (isFailed(state)) return <FailedScreen />;
if (isFailed(state)) {
return <FailedScreen />;
}

return (
<DynamicUI.PageResolver state={state} pages={elements ?? []}>
Expand All @@ -205,9 +217,11 @@ export const CollectionFlowV1 = withSessionProtected(() => {
<div className="flex h-full flex-1 flex-col">
<div className="flex justify-between gap-8 pb-10">
<AppShell.Navigation />
<div className="flex w-full justify-end">
<AppShell.LanguagePicker />
</div>
{schema?.uiOptions?.disableLanguageSelection ? null : (
<div className="flex w-full justify-end">
<AppShell.LanguagePicker />
</div>
)}
</div>
<div className="pb-10">
{customer?.logoImageUri && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ export const CollectionFlowV2 = withSessionProtected(() => {
<div className="flex h-full flex-1 flex-col">
<div className="flex justify-between gap-8 pb-10">
<AppShell.Navigation />
<div className="flex w-full justify-end">
<AppShell.LanguagePicker />
</div>
{schema?.uiOptions?.disableLanguageSelection ? null : (
<div className="flex w-full justify-end">
<AppShell.LanguagePicker />
</div>
)}
</div>
<div className="pb-10">
{customer?.logoImageUri && (
Expand All @@ -175,11 +177,11 @@ export const CollectionFlowV2 = withSessionProtected(() => {
) : null}
</div>
<div>
{themeDefinition.settings.contactInformation ? (
{themeDefinition.settings?.contactInformation ? (
<div
className="text-sm"
dangerouslySetInnerHTML={{
__html: themeDefinition.settings.contactInformation,
__html: themeDefinition.settings?.contactInformation,
}}
/>
) : customer?.displayName ? (
Expand Down
6 changes: 6 additions & 0 deletions examples/headless-example/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ballerine/headless-example

## 0.3.97

### Patch Changes

- @ballerine/workflow-browser-sdk@0.6.98

## 0.3.96

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions examples/headless-example/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/headless-example",
"private": true,
"version": "0.3.96",
"version": "0.3.97",
"type": "module",
"scripts": {
"spellcheck": "cspell \"*\"",
Expand Down Expand Up @@ -35,7 +35,7 @@
},
"dependencies": {
"@ballerine/common": "0.9.77",
"@ballerine/workflow-browser-sdk": "0.6.97",
"@ballerine/workflow-browser-sdk": "0.6.98",
"@felte/reporter-svelte": "^1.1.5",
"@felte/validator-zod": "^1.0.13",
"@fontsource/inter": "^4.5.15",
Expand Down
6 changes: 6 additions & 0 deletions packages/workflow-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ballerine/workflow-core

## 0.6.98

### Patch Changes

- Bump

## 0.6.97

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/workflow-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/workflow-core",
"author": "Ballerine <[email protected]>",
"version": "0.6.97",
"version": "0.6.98",
"description": "workflow-core",
"module": "./dist/esm/index.js",
"main": "./dist/cjs/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ export const BALLERINE_API_PLUGIN_FACTORY = {
transformer: 'jmespath',
mapping: `{
${options.dataMapping || ''}
context: @,
companyName: data.companyName,
customerName: metadata.customerName,
collectionFlowUrl: join('',['{secret.COLLECTION_FLOW_URL}','/?token=',metadata.token,'&lng=',workflowRuntimeConfig.language]),
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8357918

Please sign in to comment.