Skip to content

Commit

Permalink
chore(*): resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Omri-Levy committed Jan 23, 2025
2 parents 1ba4689 + aa53dd4 commit 76d0201
Show file tree
Hide file tree
Showing 53 changed files with 1,071 additions and 637 deletions.
12 changes: 8 additions & 4 deletions apps/backoffice-v2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

### Patch Changes

- @ballerine/workflow-browser-sdk@0.6.89
- @ballerine/workflow-node-sdk@0.6.89
- Updated dependencies
- @ballerine/common@0.9.70
- @ballerine/workflow-browser-sdk@0.6.89
- @ballerine/workflow-node-sdk@0.6.89

## 0.7.96

### Patch Changes

- @ballerine/workflow-browser-sdk@0.6.88
- @ballerine/workflow-node-sdk@0.6.88
- Updated dependencies
- @ballerine/common@0.9.69
- @ballerine/workflow-browser-sdk@0.6.88
- @ballerine/workflow-node-sdk@0.6.88

## 0.7.95

Expand Down
2 changes: 1 addition & 1 deletion apps/backoffice-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"dependencies": {
"@ballerine/blocks": "0.2.34",
"@ballerine/common": "0.9.68",
"@ballerine/common": "0.9.70",
"@ballerine/workflow-browser-sdk": "0.6.89",
"@ballerine/workflow-node-sdk": "0.6.89",
"@ballerine/react-pdf-toolkit": "^1.2.67",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export const useApproveTaskByIdMutation = (workflowId: string) => {

return useMutation({
mutationFn: ({
directorId,
documentId,
contextUpdateMethod = 'base',
comment,
}: {
directorId?: string;
documentId: string;
contextUpdateMethod?: 'base' | 'director';
comment?: string;
Expand All @@ -25,6 +27,7 @@ export const useApproveTaskByIdMutation = (workflowId: string) => {
workflowId,
documentId,
body: {
directorId,
decision: Action.APPROVE,
comment,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ export const useRemoveDecisionTaskByIdMutation = (workflowId: string) => {
return useMutation({
mutationFn: ({
documentId,
directorId,
contextUpdateMethod,
}: {
documentId: string;
directorId?: string;
contextUpdateMethod: 'base' | 'director';
}) =>
updateWorkflowDecision({
workflowId,
documentId,
body: {
directorId,
decision: null,
reason: null,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ export const useRevisionTaskByIdMutation = () => {
workflowId,
documentId,
reason,
directorId,
contextUpdateMethod,
}: {
workflowId: string;
documentId: string;
reason?: string;
directorId?: string;
contextUpdateMethod?: 'base' | 'director';
}) =>
updateWorkflowDecision({
workflowId,
documentId,
contextUpdateMethod,
body: {
directorId,
decision: Action.REVISION,
reason,
},
Expand Down
24 changes: 24 additions & 0 deletions apps/backoffice-v2/src/domains/individuals/fetchers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { handleZodError } from '@/common/utils/handle-zod-error/handle-zod-error';

import { Method } from '@/common/enums';

import { z } from 'zod';

import { HitSchema } from '@/lib/blocks/components/AmlBlock/utils/aml-adapter';

import { apiClient } from '@/common/api-client/api-client';

export const EndUserSchema = z.object({
amlHits: z.array(HitSchema.extend({ vendor: z.string().optional() })).optional(),
});

export const getEndUserById = async ({ id }: { id: string }) => {
const [endUser, error] = await apiClient({
endpoint: `end-users/${id}`,
method: Method.GET,
schema: EndUserSchema,
timeout: 30_000,
});

return handleZodError(error, endUser);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useIsAuthenticated } from '@/domains/auth/context/AuthProvider/hooks/useIsAuthenticated/useIsAuthenticated';
import { useQuery } from '@tanstack/react-query';
import { endUsersQueryKeys } from '../../query-keys';

export const useEndUserByIdQuery = ({ id }: { id: string }) => {
const isAuthenticated = useIsAuthenticated();

return useQuery({
...endUsersQueryKeys.byId({ id }),
enabled: !!id && isAuthenticated,
});
};
9 changes: 9 additions & 0 deletions apps/backoffice-v2/src/domains/individuals/query-keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createQueryKeys } from '@lukemorales/query-key-factory';
import { getEndUserById } from './fetchers';

export const endUsersQueryKeys = createQueryKeys('end-users', {
byId: ({ id }: { id: string }) => ({
queryKey: ['end-users', id],
queryFn: () => getEndUserById({ id }),
}),
});
1 change: 1 addition & 0 deletions apps/backoffice-v2/src/domains/workflows/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export const updateWorkflowDecision = async ({
documentId: string;
body: {
decision: string | null;
directorId?: string;
reason?: string;
comment?: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const CallToActionLegacy: FunctionComponent<ICallToActionLegacyProps> = (
isLoadingReuploadNeeded,
onDialogClose,
id,
directorId,
workflow,
decision,
disabled,
Expand Down Expand Up @@ -263,6 +264,7 @@ export const CallToActionLegacy: FunctionComponent<ICallToActionLegacyProps> = (
)}
onClick={onReuploadNeeded({
workflowId: workflow?.id,
directorId,
documentId: id,
reason: comment ? `${reason} - ${comment}` : reason,
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface ICallToActionLegacyProps {
text: string;
props: {
id: string;
directorId?: string;
workflow: TWorkflowById;
disabled: boolean;
decision: 'reject' | 'approve' | 'revision' | 'revised';
Expand All @@ -15,10 +16,12 @@ export interface ICallToActionLegacyProps {
onReuploadReset?: () => void;
onReuploadNeeded: ({
workflowId,
directorId,
documentId,
reason,
}: {
workflowId: string;
directorId?: string;
documentId: string;
reason?: string;
}) => () => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { BlocksComponent } from '@ballerine/blocks';
import { cells } from '../../create-blocks-typed/create-blocks-typed';
import { useEndUserByIdQuery } from '@/domains/individuals/queries/useEndUserByIdQuery/useEndUserByIdQuery';
import { useDirectorBlock } from './hooks/useDirectorBlock/useDirectorBlock';

export const DirectorBlock = ({
workflowId,
onReuploadNeeded,
onRemoveDecision,
onApprove,
director,
tags,
revisionReasons,
isEditable,
isApproveDisabled,
documentSchemas,
isLoadingDocuments,
workflow,
}: Omit<Parameters<typeof useDirectorBlock>[0], 'director'> & {
director: Omit<Parameters<typeof useDirectorBlock>[0]['director'], 'aml'>;
}) => {
const { data: endUser } = useEndUserByIdQuery({ id: director.id });
const directorWithAml = {
...director,
aml: {
vendor: endUser?.amlHits?.find(({ vendor }) => !!vendor)?.vendor,
hits: endUser?.amlHits,
},
};
const directorBlock = useDirectorBlock({
workflowId,
onReuploadNeeded,
onRemoveDecision,
onApprove,
director: directorWithAml,
tags,
revisionReasons,
isEditable,
isApproveDisabled,
documentSchemas,
isLoadingDocuments,
workflow,
});

return (
<BlocksComponent blocks={directorBlock} cells={cells}>
{(Cell, cell) => <Cell {...cell} />}
</BlocksComponent>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { createBlocksTyped } from '@/lib/blocks/create-blocks-typed/create-blocks-typed';
import { ComponentProps } from 'react';
import { DirectorBlock } from '../../DirectorBlock';
import { getDocumentsByCountry } from '@ballerine/common';
import { extractCountryCodeFromDocuments } from '@/pages/Entity/hooks/useEntityLogic/utils';

export const createDirectorsBlocks = ({
workflowId,
onReuploadNeeded,
onRemoveDecision,
onApprove,
directors,
tags,
revisionReasons,
isEditable,
isApproveDisabled,
isLoadingDocuments,
workflow,
}: Omit<ComponentProps<typeof DirectorBlock>, 'director' | 'documentSchemas'> & {
directors: Array<ComponentProps<typeof DirectorBlock>['director']>;
}) => {
const directorsBlocks = createBlocksTyped().addBlock();

if (!directors?.length) {
return [];
}

directors?.forEach(director => {
const issuerCountryCode = extractCountryCodeFromDocuments(director.documents);
const documentSchemas = issuerCountryCode ? getDocumentsByCountry(issuerCountryCode) : [];

if (!Array.isArray(documentSchemas) || !documentSchemas.length) {
console.warn(`No document schema found for issuer country code of "${issuerCountryCode}".`);
}

directorsBlocks.addCell({
type: 'node',
value: (
<DirectorBlock
workflowId={workflowId}
onReuploadNeeded={onReuploadNeeded}
onRemoveDecision={onRemoveDecision}
onApprove={onApprove}
director={director}
tags={tags}
revisionReasons={revisionReasons}
isEditable={isEditable}
isApproveDisabled={isApproveDisabled}
documentSchemas={documentSchemas}
isLoadingDocuments={isLoadingDocuments}
workflow={workflow}
/>
),
});
});

return directorsBlocks.build();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { createDirectorsBlocks } from './create-directors-blocks';

export const directorDocumentsAdapter = ({ documents, storageFiles }) => {
return documents?.map(
(document, documentIndex) =>
({
id: document?.id,
category: document?.category,
type: document?.type,
issuer: {
country: document?.issuer?.country,
},
decision: {
status: document?.decision?.status,
},
version: document?.version,
properties: document?.properties,
propertiesSchema: document?.propertiesSchema,
pages: document?.pages?.map(
(page, pageIndex) =>
({
type: page?.type,
imageUrl: storageFiles?.[documentIndex]?.[pageIndex],
metadata: {
side: page?.metadata?.side,
},
} satisfies Parameters<
typeof createDirectorsBlocks
>[0]['directors'][number]['documents'][number]['pages'][number]),
),
} satisfies Parameters<
typeof createDirectorsBlocks
>[0]['directors'][number]['documents'][number]),
);
};

export const directorAdapter =
storageFiles =>
({ ballerineEntityId, firstName, lastName, additionalInfo }) => {
const documents = directorDocumentsAdapter({
documents: additionalInfo?.documents,
storageFiles,
});

return {
id: ballerineEntityId,
firstName,
lastName,
documents,
} satisfies Parameters<typeof createDirectorsBlocks>[0]['directors'][number];
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './useDirectorBlock';
Loading

0 comments on commit 76d0201

Please sign in to comment.