Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAL-1957 #2374

Merged
merged 10 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/backoffice-v2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
### Patch Changes

- Updated dependencies
- @ballerine/[email protected]
- @ballerine/[email protected]
- @ballerine/[email protected]
- @ballerine/[email protected]

## 0.7.7
Expand Down
6 changes: 3 additions & 3 deletions apps/backoffice-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
"preview": "vite preview"
},
"dependencies": {
"@ballerine/common": "0.9.6",
"@ballerine/blocks": "0.2.3",
"@ballerine/common": "0.9.5",
"@ballerine/ui": "^0.5.1",
"@ballerine/workflow-browser-sdk": "0.6.8",
"@ballerine/workflow-node-sdk": "0.6.8",
"@ballerine/workflow-browser-sdk": "0.6.9",
"@ballerine/workflow-node-sdk": "0.6.9",
"@fontsource/inter": "^4.5.15",
"@formkit/auto-animate": "1.0.0-beta.5",
"@hookform/resolvers": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from 'sonner';
import { t } from 'i18next';
import { TWorkflowById, updateWorkflowDecision } from '../../../../workflows/fetchers';
import { workflowsQueryKeys } from '../../../../workflows/query-keys';
import { toast } from 'sonner';
import { Action } from '../../../../../common/enums';
import { useFilterId } from '../../../../../common/hooks/useFilterId/useFilterId';
import { TWorkflowById, updateWorkflowDecision } from '../../../../workflows/fetchers';
import { workflowsQueryKeys } from '../../../../workflows/query-keys';

export const useApproveTaskByIdMutation = (workflowId: string) => {
const queryClient = useQueryClient();
Expand All @@ -15,15 +15,18 @@ export const useApproveTaskByIdMutation = (workflowId: string) => {
mutationFn: ({
documentId,
contextUpdateMethod = 'base',
comment,
}: {
documentId: string;
contextUpdateMethod?: 'base' | 'director';
comment?: string;
}) =>
updateWorkflowDecision({
workflowId,
documentId,
body: {
decision: Action.APPROVE,
comment,
},
contextUpdateMethod,
}),
Expand Down
15 changes: 8 additions & 7 deletions apps/backoffice-v2/src/domains/workflows/fetchers.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { env } from '@/common/env/env';
import qs from 'qs';
import { deepCamelKeys } from 'string-ts';
import { z } from 'zod';
import { apiClient } from '@/common/api-client/api-client';
import { Method, States } from '@/common/enums';
import { env } from '@/common/env/env';
import { getOriginUrl } from '@/common/utils/get-origin-url/get-url-origin';
import { handleZodError } from '@/common/utils/handle-zod-error/handle-zod-error';
import { WorkflowDefinitionByIdSchema } from '@/domains/workflow-definitions/fetchers';
import { AmlSchema } from '@/lib/blocks/components/AmlBlock/utils/aml-adapter';
import { ObjectWithIdSchema } from '@/lib/zod/utils/object-with-id/object-with-id';
import { zPropertyKey } from '@/lib/zod/utils/z-property-key/z-property-key';
import qs from 'qs';
import { deepCamelKeys } from 'string-ts';
import { z } from 'zod';
import { IWorkflowId } from './interfaces';
import { getOriginUrl } from '@/common/utils/get-origin-url/get-url-origin';
import { WorkflowDefinitionByIdSchema } from '@/domains/workflow-definitions/fetchers';
import { AmlSchema } from '@/lib/blocks/components/AmlBlock/utils/aml-adapter';

export const fetchWorkflows = async (params: {
filterId: string;
Expand Down Expand Up @@ -239,6 +239,7 @@ export const updateWorkflowDecision = async ({
body: {
decision: string | null;
reason?: string;
comment?: string;
};
contextUpdateMethod: 'base' | 'director';
}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { StateTag, TStateTags, isObject } from '@ballerine/common';
import { ComponentProps, useCallback, useMemo } from 'react';

import { Separator } from '@/common/components/atoms/Separator/Separator';
import { MotionButton } from '@/common/components/molecules/MotionButton/MotionButton';
import { useFilterId } from '@/common/hooks/useFilterId/useFilterId';
import { ctw } from '@/common/utils/ctw/ctw';
Expand All @@ -21,7 +22,6 @@ import { capitalize } from '../../../../../../common/utils/capitalize/capitalize
import { valueOrNA } from '../../../../../../common/utils/value-or-na/value-or-na';
import { useStorageFilesQuery } from '../../../../../../domains/storage/hooks/queries/useStorageFilesQuery/useStorageFilesQuery';
import { TWorkflowById } from '../../../../../../domains/workflows/fetchers';
import { Separator } from '@/common/components/atoms/Separator/Separator';

const motionBadgeProps = {
exit: { opacity: 0, transition: { duration: 0.2 } },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useCallback, useState } from 'react';

export const useCommentInput = () => {
const [value, setValue] = useState('');

const handleChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
setValue(event.target.value);
}, []);

const clear = useCallback(() => {
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
setValue('');
}, []);

return {
value,
handleChange,
clear,
};
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MotionButton } from '@/common/components/molecules/MotionButton/MotionButton';
import { checkIsBusiness } from '@/common/utils/check-is-business/check-is-business';
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
import { ctw } from '@/common/utils/ctw/ctw';
import { valueOrNA } from '@/common/utils/value-or-na/value-or-na';
import { useApproveTaskByIdMutation } from '@/domains/entities/hooks/mutations/useApproveTaskByIdMutation/useApproveTaskByIdMutation';
Expand All @@ -8,6 +9,7 @@ import { useStorageFilesQuery } from '@/domains/storage/hooks/queries/useStorage
import { TWorkflowById } from '@/domains/workflows/fetchers';
import { createBlocksTyped } from '@/lib/blocks/create-blocks-typed/create-blocks-typed';
import { motionButtonProps } from '@/lib/blocks/hooks/useAssosciatedCompaniesBlock/useAssociatedCompaniesBlock';
import { useCommentInput } from '@/lib/blocks/hooks/useDocumentBlocks/hooks/useCommentInput/useCommentInput';
import { checkCanApprove } from '@/lib/blocks/hooks/useDocumentBlocks/utils/check-can-approve/check-can-approve';
import { checkCanReject } from '@/lib/blocks/hooks/useDocumentBlocks/utils/check-can-reject/check-can-reject';
import { checkCanRevision } from '@/lib/blocks/hooks/useDocumentBlocks/utils/check-can-revision/check-can-revision';
Expand All @@ -23,12 +25,11 @@ import {
import { selectWorkflowDocuments } from '@/pages/Entity/selectors/selectWorkflowDocuments';
import { getDocumentsSchemas } from '@/pages/Entity/utils/get-documents-schemas/get-documents-schemas';
import { CommonWorkflowStates, StateTag } from '@ballerine/common';
import { Button } from '@ballerine/ui';
import { Button, TextArea } from '@ballerine/ui';
import { X } from 'lucide-react';
import * as React from 'react';
import { FunctionComponent, useCallback, useMemo } from 'react';
import { toTitleCase } from 'string-ts';
import { checkIsBusiness } from '@/common/utils/check-is-business/check-is-business';

export const useDocumentBlocks = ({
workflow,
Expand Down Expand Up @@ -80,17 +81,27 @@ export const useDocumentBlocks = ({
const { mutate: mutateApproveTaskById, isLoading: isLoadingApproveTaskById } =
useApproveTaskByIdMutation(workflow?.id);
const { isLoading: isLoadingRejectTaskById } = useRejectTaskByIdMutation(workflow?.id);

const {
value: commentValue,
handleChange: handleCommentChange,
clear: clearComment,
} = useCommentInput();
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
const onMutateApproveTaskById = useCallback(
({
taskId,
contextUpdateMethod,
comment,
}: {
taskId: string;
contextUpdateMethod: 'base' | 'director';
comment?: string;
}) =>
() =>
mutateApproveTaskById({ documentId: taskId, contextUpdateMethod }),
[mutateApproveTaskById],
() => {
mutateApproveTaskById({ documentId: taskId, contextUpdateMethod, comment });
clearComment();
},
[mutateApproveTaskById, clearComment],
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
);
const { mutate: onMutateRemoveDecisionById } = useRemoveDecisionTaskByIdMutation(workflow?.id);

Expand Down Expand Up @@ -264,16 +275,24 @@ export const useDocumentBlocks = ({
),
title: `Approval confirmation`,
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
description: <p className={`text-sm`}>Are you sure you want to approve?</p>,
content: (
<TextArea
placeholder={'Add a comment'}
value={commentValue}
onChange={handleCommentChange}
/>
),
close: (
<div className={`space-x-2`}>
<Button type={'button'} variant={`secondary`}>
<Button type={'button'} variant={`secondary`} onClick={clearComment}>
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
Cancel
</Button>
<Button
disabled={!canApprove}
onClick={onMutateApproveTaskById({
taskId: id,
contextUpdateMethod: 'base',
comment: commentValue || undefined,
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved
})}
>
Approve
Expand Down
2 changes: 2 additions & 0 deletions apps/kyb-app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Patch Changes

- Updated dependencies
- @ballerine/[email protected]
- @ballerine/[email protected]
- @ballerine/[email protected]

## 0.3.8
Expand Down
4 changes: 2 additions & 2 deletions apps/kyb-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"test:dev": "vitest"
},
"dependencies": {
"@ballerine/common": "^0.9.6",
"@ballerine/blocks": "0.2.3",
"@ballerine/common": "^0.9.5",
"@ballerine/ui": "0.5.2",
"@ballerine/workflow-browser-sdk": "0.6.8",
"@ballerine/workflow-browser-sdk": "0.6.9",
"@lukemorales/query-key-factory": "^1.0.3",
"@radix-ui/react-icons": "^1.3.0",
"@rjsf/core": "^5.9.0",
Expand Down
8 changes: 8 additions & 0 deletions examples/headless-example/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @ballerine/headless-example

## 0.3.8

### Patch Changes

- Updated dependencies
- @ballerine/[email protected]
- @ballerine/[email protected]

## 0.3.7

### Patch Changes
Expand Down
6 changes: 3 additions & 3 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.7",
"version": "0.3.8",
"type": "module",
"scripts": {
"spellcheck": "cspell \"*\"",
Expand Down Expand Up @@ -34,8 +34,8 @@
"vite": "^4.5.3"
},
"dependencies": {
"@ballerine/common": "0.9.5",
"@ballerine/workflow-browser-sdk": "0.6.8",
"@ballerine/common": "0.9.6",
"@ballerine/workflow-browser-sdk": "0.6.9",
"@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/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ballerine/common

## 0.9.6

### Patch Changes

- Context schema update
chesterkmr marked this conversation as resolved.
Show resolved Hide resolved

## 0.9.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"name": "@ballerine/common",
"author": "Ballerine <[email protected]>",
"version": "0.9.5",
"version": "0.9.6",
"description": "common",
"module": "./dist/esm/index.js",
"main": "./dist/cjs/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const defaultContextSchema = Type.Object({
Type.Null(),
]),
),
comment: Type.Optional(Type.String()),
rejectionReason: Type.Optional(
Type.Union([
Type.String(),
Expand Down
7 changes: 7 additions & 0 deletions packages/workflow-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @ballerine/workflow-core

## 0.6.9

### Patch Changes

- Updated dependencies
- @ballerine/[email protected]

## 0.6.8

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions 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.8",
"version": "0.6.9",
"description": "workflow-core",
"module": "./dist/esm/index.js",
"main": "./dist/cjs/index.js",
Expand Down Expand Up @@ -31,7 +31,7 @@
"node": ">=12"
},
"dependencies": {
"@ballerine/common": "0.9.5",
"@ballerine/common": "0.9.6",
"ajv": "^8.12.0",
"i18n-iso-countries": "^7.6.0",
"jmespath": "^0.16.0",
Expand Down
Loading
Loading