Skip to content

Commit fb89dce

Browse files
authoredJul 31, 2024··
Added vendor to the AML block (#2590)
* feat(*): added vendor to the aml block * refactor(backoffice-v2): removed toTitleCase instance

File tree

7 files changed

+63
-14
lines changed

7 files changed

+63
-14
lines changed
 

‎apps/backoffice-v2/src/domains/workflows/fetchers.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ export const BaseWorkflowByIdSchema = z.object({
6464
workflowDefinition: WorkflowDefinitionByIdSchema,
6565
createdAt: z.string().datetime(),
6666
context: z.object({
67-
aml: AmlSchema.optional(),
67+
aml: AmlSchema.extend({
68+
vendor: z.string().optional(),
69+
}).optional(),
6870
documents: z.array(z.any()).default([]),
6971
entity: z.record(z.any(), z.any()),
7072
parentMachine: ObjectWithIdSchema.extend({

‎apps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { toTitleCase } from 'string-ts';
1+
import { titleCase } from 'string-ts';
22
import { ChevronDown } from 'lucide-react';
33
import React, { ComponentProps, useMemo } from 'react';
44
import { createColumnHelper } from '@tanstack/react-table';
@@ -12,7 +12,13 @@ import { Button } from '@/common/components/atoms/Button/Button';
1212
import { createBlocksTyped } from '@/lib/blocks/create-blocks-typed/create-blocks-typed';
1313
import { TextWithNAFallback } from '@/common/components/atoms/TextWithNAFallback/TextWithNAFallback';
1414

15-
export const useAmlBlock = (data: Array<TWorkflowById['context']['aml']>) => {
15+
export const useAmlBlock = ({
16+
data,
17+
vendor,
18+
}: {
19+
data: Array<TWorkflowById['context']['aml']>;
20+
vendor: string;
21+
}) => {
1622
const amlBlock = useMemo(() => {
1723
if (!data?.length) {
1824
return [];
@@ -37,6 +43,11 @@ export const useAmlBlock = (data: Array<TWorkflowById['context']['aml']>) => {
3743
},
3844
},
3945
columns: [
46+
{
47+
id: 'screenedBy',
48+
header: 'Screened by',
49+
cell: () => <TextWithNAFallback>{titleCase(vendor ?? '')}</TextWithNAFallback>,
50+
},
4051
{
4152
accessorKey: 'totalMatches',
4253
header: 'Total Matches',
@@ -139,7 +150,7 @@ export const useAmlBlock = (data: Array<TWorkflowById['context']['aml']>) => {
139150
cell: info => {
140151
const matchTypes = info.getValue();
141152

142-
return <TextWithNAFallback>{toTitleCase(matchTypes)}</TextWithNAFallback>;
153+
return <TextWithNAFallback>{titleCase(matchTypes)}</TextWithNAFallback>;
143154
},
144155
}),
145156
columnHelper.accessor('pep', {

‎apps/backoffice-v2/src/lib/blocks/components/KycBlock/hooks/useKycBlock/useKycBlock.tsx

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { StateTag, TStateTags, isObject } from '@ballerine/common';
1+
import { isObject, StateTag, TStateTags } from '@ballerine/common';
22
import { ComponentProps, useCallback, useMemo } from 'react';
33

44
import { Separator } from '@/common/components/atoms/Separator/Separator';
@@ -109,9 +109,36 @@ export const useKycBlock = ({
109109
childWorkflow?.context?.pluginsOutput?.kyc_session[key]?.result?.vendorResult?.aml ??
110110
childWorkflow?.context?.pluginsOutput?.kyc_session[key]?.result?.aml,
111111
);
112-
}, [kycSessionKeys]);
112+
}, [childWorkflow?.context?.pluginsOutput?.kyc_session, kycSessionKeys]);
113+
const vendor = useMemo(() => {
114+
if (!kycSessionKeys?.length) {
115+
return;
116+
}
117+
118+
const amlVendor = kycSessionKeys
119+
.map(
120+
key =>
121+
childWorkflow?.context?.pluginsOutput?.kyc_session[key]?.result?.vendorResult?.aml
122+
?.vendor ??
123+
childWorkflow?.context?.pluginsOutput?.kyc_session[key]?.result?.aml?.vendor,
124+
)
125+
.filter(Boolean);
126+
127+
if (!amlVendor.length) {
128+
const kycVendor = kycSessionKeys
129+
.map(key => childWorkflow?.context?.pluginsOutput?.kyc_session[key]?.vendor)
130+
.filter(Boolean);
113131

114-
const amlBlock = useAmlBlock(amlData);
132+
return kycVendor.join(', ');
133+
}
134+
135+
return amlVendor.join(', ');
136+
}, [childWorkflow?.context?.pluginsOutput?.kyc_session, kycSessionKeys]);
137+
138+
const amlBlock = useAmlBlock({
139+
data: amlData,
140+
vendor: vendor ?? '',
141+
});
115142

116143
const documentExtractedData = kycSessionKeys?.length
117144
? kycSessionKeys?.map((key, index, collection) =>

‎apps/backoffice-v2/src/lib/blocks/variants/DefaultBlocks/hooks/useDefaultBlocksLogic/useDefaultBlocksLogic.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,10 @@ export const useDefaultBlocksLogic = () => {
410410

411411
const amlData = useMemo(() => [workflow?.context?.aml], [workflow?.context?.aml]);
412412

413-
const amlBlock = useAmlBlock(amlData);
413+
const amlBlock = useAmlBlock({
414+
data: amlData,
415+
vendor: workflow?.context?.aml?.vendor ?? '',
416+
});
414417

415418
const amlWithContainerBlock = useMemo(() => {
416419
if (!amlBlock?.length) {

‎apps/backoffice-v2/src/lib/blocks/variants/OngoingBlocks/hooks/useOngoingBlocksLogic/useOngoingBlocksLogic.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export const useOngoingBlocksLogic = () => {
1616

1717
const amlData = useMemo(() => [workflow?.context?.aml], [workflow?.context?.aml]);
1818

19-
const amlBlock = useAmlBlock(amlData);
19+
const amlBlock = useAmlBlock({
20+
data: amlData,
21+
vendor: workflow?.context?.aml?.vendor ?? '',
22+
});
2023

2124
const amlWithContainerBlock = useMemo(() => {
2225
if (!amlBlock?.length) {

‎services/workflows-service/src/workflow/hook-callback-handler.service.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,13 @@ export class HookCallbackHandlerService {
122122
}
123123

124124
if (processName === 'aml-unified-api') {
125-
const aml = data.data as {
126-
id: string;
127-
endUserId: string;
128-
hits: Array<Record<string, unknown>>;
125+
const aml = {
126+
...(data.data as {
127+
id: string;
128+
endUserId: string;
129+
hits: Array<Record<string, unknown>>;
130+
}),
131+
vendor: data.vendor,
129132
};
130133

131134
const attributePath = resultDestinationPath.split('.');

0 commit comments

Comments
 (0)
Please sign in to comment.