Skip to content

Commit ca75c26

Browse files
authored
Bal 4297 documents tracker mapping (#3402)
* feat: added variant to end user & updated entity creation & updated endpoints * feat: reworked documents mapping & fixed state computation * fix: post merge fix * fix: added assert valid project ids
1 parent ae49701 commit ca75c26

File tree

19 files changed

+109
-110
lines changed

19 files changed

+109
-110
lines changed

apps/backoffice-v2/src/common/components/molecules/DocumentTracker/hooks/useDocumentTracker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const useDocumentTracker = ({ workflowId }: { workflowId: string }) => {
4646
templateId: identifier.document.type,
4747
entity: {
4848
id: identifier.entity.id,
49-
type: identifier.entity.entityType,
49+
type: identifier.entity.variant,
5050
},
5151
})),
5252
}),

apps/backoffice-v2/src/domains/documents/schemas.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ export const DocumentTrackerItemSchema = z.object({
2525
issuingVersion: z.string(),
2626
version: z.string(),
2727
}),
28-
entity: z.discriminatedUnion('entityType', [
28+
entity: z.discriminatedUnion('variant', [
2929
ObjectWithIdSchema.extend({
30-
entityType: z.literal(EntityType.BUSINESS),
30+
variant: z.literal(EntityType.BUSINESS),
3131
companyName: z.string(),
3232
}),
3333
EndUserSchema.extend({
34-
entityType: z.literal(EntityType.UBO),
34+
variant: z.literal(EntityType.UBO),
3535
}),
3636
EndUserSchema.extend({
37-
entityType: z.literal(EntityType.DIRECTOR),
37+
variant: z.literal(EntityType.DIRECTOR),
3838
}),
3939
]),
4040
}),

apps/backoffice-v2/src/domains/individuals/fetchers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const EndUserSchema = z.object({
3838
}),
3939
})
4040
.optional(),
41+
variant: z.enum(['director', 'ubo']).optional(),
4142
createdFrom: z.enum(['user', 'analyst', 'registry']).nullable().optional(),
4243
});
4344

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { TWorkflowById } from '@/domains/workflows/fetchers';
2-
import { selectDirectors } from '@/pages/Entity/selectors/selectDirectors';
32

43
export const getDirectorsIdsFromWorkflow = (workflow: TWorkflowById) =>
5-
selectDirectors(workflow)
6-
.map(director => director.ballerineEntityId)
7-
.filter(Boolean);
4+
workflow.endUsers?.filter(endUser => endUser.variant === 'director').map(endUser => endUser.id) ||
5+
[];

apps/backoffice-v2/src/lib/blocks/hooks/useDirectorsDocuments/useDirectorsDocuments.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const useDirectorsDocuments = (workflow: TWorkflowById) => {
99

1010
const { documents, documentsSchemas, isLoading } = useWorkflowDocumentsAdapter({
1111
entityIds,
12+
// TODO: Remove once documents v1 are deprecated
1213
documents: (workflow?.context?.entity?.data?.additionalInfo?.directors?.flatMap(
1314
director => director.documents ?? [],
1415
) ?? []) as TDocument[],

apps/backoffice-v2/src/lib/blocks/hooks/useDocumentBlocks/hooks/useDocuments/useDocuments.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export const useDocuments = (workflow: TWorkflowById) => {
3636
useUbosDocuments(workflow as TWorkflowById),
3737
];
3838

39+
console.log('ubo documents', ubosDocuments);
40+
3941
const businessDocumentsWithEntity = useMemo(
4042
() =>
4143
businessDocuments.map(document => ({
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
import { TWorkflowById } from '@/domains/workflows/fetchers';
22

33
export const getUbosEntityIdsFromWorkflow = (workflow: TWorkflowById) => {
4-
const directorsIds =
5-
workflow?.context?.entity?.data?.additionalInfo?.directors
6-
?.map(director => director.ballerineEntityId)
7-
.filter(Boolean) ?? [];
8-
94
return (
10-
workflow?.childWorkflows
11-
?.filter(
12-
childWorkflow =>
13-
childWorkflow.context?.entity?.variant === 'ubo' &&
14-
!directorsIds.includes(childWorkflow.context?.entity?.ballerineEntityId),
15-
)
16-
?.map(childWorkflow => childWorkflow.context?.entity?.ballerineEntityId)
17-
.filter(Boolean) ?? []
5+
workflow.endUsers?.filter(endUser => endUser.variant === 'ubo').map(endUser => endUser.id) || []
186
);
197
};

apps/backoffice-v2/src/lib/blocks/hooks/useUbosDocuments/useUbosDocuments.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const useUbosDocuments = (workflow: TWorkflowById) => {
99

1010
const { documents, documentsSchemas, isLoading } = useWorkflowDocumentsAdapter({
1111
entityIds,
12+
// TODO: Remove once documents v1 are deprecated
1213
documents: (workflow.childWorkflows
1314
?.filter(childWorkflow => childWorkflow.context?.entity?.variant === 'ubo')
1415
?.flatMap(childWorkflow => childWorkflow.context?.documents ?? []) ?? []) as TDocument[],

apps/kyb-app/src/pages/CollectionFlow/versions/v2/components/organisms/CollectionFlowUI/hooks/useRevisionFields/utils/generate-fields-for-revision/generate-fields-for-revision.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export const generateFieldsForRevision = (
2727
const fieldDefinitions = getFieldDefinitionsFromSchema(page.elements) as Array<
2828
IFormElement<TBaseFields, any>
2929
>;
30-
3130
if (isPageInRevision || isPageInEdit) {
3231
const granularRevisionFields = generateGranularRevisionFields({
3332
context,

services/workflows-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"prod": "npm run db:migrate-up && npm run start:prod",
1717
"prod:next": "npm run db:migrate-up && npm run db:data-sync && npm run start:prod",
1818
"start:watch": "nest start --watch",
19-
"start:debug": "nest start --debug --watch",
19+
"start:debug": "nest start --debug",
2020
"build": "nest build --path=tsconfig.build.json",
2121
"test": "jest --runInBand",
2222
"test:unit": "cross-env SKIP_DB_SETUP_TEARDOWN=true jest --testRegex '.*\\.unit\\.test\\.ts$'",

0 commit comments

Comments
 (0)