Skip to content

Commit

Permalink
chore(nuvei): merge
Browse files Browse the repository at this point in the history
  • Loading branch information
alonp99 committed Oct 2, 2024
2 parents c9ee508 + cb1d027 commit 1ef0964
Show file tree
Hide file tree
Showing 86 changed files with 1,077 additions and 336 deletions.
38 changes: 38 additions & 0 deletions apps/backoffice-v2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
# @ballerine/backoffice-v2

## 0.7.51

### Patch Changes

- Updated dependencies
- @ballerine/common@0.9.36
- @ballerine/workflow-browser-sdk@0.6.48
- @ballerine/workflow-node-sdk@0.6.48

## 0.7.50

### Patch Changes

- Updated dependencies
- @ballerine/common@0.9.35
- @ballerine/workflow-browser-sdk@0.6.47
- @ballerine/workflow-node-sdk@0.6.47

## 0.7.49

### Patch Changes

- Bump
- Updated dependencies
- @ballerine/blocks@0.2.20
- @ballerine/common@0.9.34
- @ballerine/react-pdf-toolkit@1.2.34
- @ballerine/ui@0.5.34
- @ballerine/workflow-browser-sdk@0.6.46
- @ballerine/workflow-node-sdk@0.6.46

## 0.7.48

### Patch Changes

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

## 0.7.47

### Patch Changes
Expand Down
20 changes: 10 additions & 10 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.47",
"version": "0.7.51",
"description": "Ballerine - Backoffice",
"homepage": "https://github.com/ballerine-io/ballerine",
"repository": {
Expand Down Expand Up @@ -50,12 +50,12 @@
"preview": "vite preview"
},
"dependencies": {
"@ballerine/blocks": "0.2.19",
"@ballerine/common": "0.9.33",
"@ballerine/react-pdf-toolkit": "^1.2.33",
"@ballerine/ui": "^0.5.33",
"@ballerine/workflow-browser-sdk": "0.6.44",
"@ballerine/workflow-node-sdk": "0.6.44",
"@ballerine/blocks": "0.2.20",
"@ballerine/common": "0.9.36",
"@ballerine/react-pdf-toolkit": "^1.2.34",
"@ballerine/ui": "^0.5.34",
"@ballerine/workflow-browser-sdk": "0.6.48",
"@ballerine/workflow-node-sdk": "0.6.48",
"@botpress/webchat": "^2.1.10",
"@botpress/webchat-generator": "^0.2.9",
"@fontsource/inter": "^4.5.15",
Expand Down Expand Up @@ -98,7 +98,7 @@
"i18next-http-backend": "^2.1.1",
"leaflet": "^1.9.4",
"libphonenumber-js": "^1.10.49",
"lucide-react": "^0.239.0",
"lucide-react": "^0.445.0",
"match-sorter": "^6.3.1",
"msw": "^1.0.0",
"posthog-js": "^1.154.2",
Expand Down Expand Up @@ -126,8 +126,8 @@
"zod": "^3.22.3"
},
"devDependencies": {
"@ballerine/config": "^1.1.17",
"@ballerine/eslint-config-react": "^2.0.17",
"@ballerine/config": "^1.1.18",
"@ballerine/eslint-config-react": "^2.0.18",
"@cspell/cspell-types": "^6.31.1",
"@faker-js/faker": "^7.6.0",
"@playwright/test": "^1.32.1",
Expand Down
4 changes: 4 additions & 0 deletions apps/backoffice-v2/public/locales/en/toast.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
"pdf_certificate": {
"error": "Failed to open PDF certificate."
},
"document_ocr": {
"success": "OCR performed successfully.",
"error": "Failed to perform OCR on the document."
},
"business_report_creation": {
"success": "Merchant check created successfully.",
"error": "Error occurred while creating a merchant check.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ctw } from '@/common/utils/ctw/ctw';
import { ComponentProps, FunctionComponent } from 'react';
import { Loader2, ScanTextIcon } from 'lucide-react';

export interface IImageOCR extends ComponentProps<'button'> {
onOcrPressed?: () => void;
isOcrDisabled: boolean;
isLoadingOCR?: boolean;
}

export const ImageOCR: FunctionComponent<IImageOCR> = ({
isOcrDisabled,
onOcrPressed,
className,
isLoadingOCR,
...props
}) => (
<button
{...props}
type="button"
className={ctw(
'btn btn-circle btn-ghost btn-sm bg-base-300/70 text-[0.688rem] focus:outline-primary disabled:bg-base-300/70',
isLoadingOCR,
className,
)}
onClick={() => onOcrPressed?.()}
disabled={isOcrDisabled || isLoadingOCR}
>
{isLoadingOCR ? (
<Loader2 className="animate-spin stroke-foreground" />
) : (
<ScanTextIcon className={'p-0.5'} />
)}
</button>
);
1 change: 1 addition & 0 deletions apps/backoffice-v2/src/domains/customer/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const CustomerSchema = z.object({
createBusinessReportBatch: z
.object({ enabled: z.boolean().default(false), options: createBusinessReportOptions })
.optional(),
isDocumentOcrEnabled: z.boolean().default(false).optional(),
})
.nullable(),
config: z
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { fetchWorkflowDocumentOCRResult } from '@/domains/workflows/fetchers';
import { toast } from 'sonner';
import { t } from 'i18next';
import { workflowsQueryKeys } from '@/domains/workflows/query-keys';
import { useFilterId } from '@/common/hooks/useFilterId/useFilterId';

export const useDocumentOcr = ({ workflowId }: { workflowId: string }) => {
const filterId = useFilterId();
const workflowById = workflowsQueryKeys.byId({ workflowId, filterId });
const queryClient = useQueryClient();

return useMutation({
mutationFn: ({ documentId }: { documentId: string }) => {
return fetchWorkflowDocumentOCRResult({
workflowRuntimeId: workflowId,
documentId,
});
},
onSuccess: (data, variables) => {
void queryClient.invalidateQueries(workflowsQueryKeys._def);
toast.success(t('toast:document_ocr.success'));
},
onError: (error, variables) => {
console.error('OCR error:', error, 'for document:', variables.documentId);
void queryClient.invalidateQueries(workflowsQueryKeys._def);
toast.error(t('toast:document_ocr.error'));
},
});
};
18 changes: 18 additions & 0 deletions apps/backoffice-v2/src/domains/workflows/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,21 @@ export const createWorkflowRequest = async ({

return handleZodError(error, workflow);
};

export const fetchWorkflowDocumentOCRResult = async ({
workflowRuntimeId,
documentId,
}: {
workflowRuntimeId: string;
documentId: string;
}) => {
const [workflow, error] = await apiClient({
method: Method.GET,
url: `${getOriginUrl(
env.VITE_API_URL,
)}/api/v1/internal/workflows/${workflowRuntimeId}/documents/${documentId}/run-ocr`,
schema: z.any(),
});

return handleZodError(error, workflow);
};
8 changes: 8 additions & 0 deletions apps/backoffice-v2/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,11 @@
}
}
}

a.bpComposerPoweredBy {
display: none !important;
}

button.bpModalDialogNewConversationButton {
background-color: var(--bpPrimary-500) !important;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CommonWorkflowEvent } from '@ballerine/common';
import { ComponentProps, FunctionComponent, useCallback, useEffect, useState } from 'react';
import { toast } from 'sonner';
import { useApproveTaskByIdMutation } from '../../../../../../domains/entities/hooks/mutations/useApproveTaskByIdMutation/useApproveTaskByIdMutation';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const CaseCallToActionLegacy: FunctionComponent<ICaseCallToActionLegacyPr
<DialogFooter>
<DialogClose asChild>
<Button
className={ctw(`gap-x-2`, {
className={ctw(`gap-x-2 !bg-foreground`, {
loading: isLoadingRevisionCase,
})}
disabled={isLoadingRevisionCase}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const Details: FunctionComponent<ExtractCellProps<'details'>> = ({
workflowId,
documents = [],
onSubmit,
isSaveDisabled,
props,
}) => {
if (!value.data?.length) {
Expand All @@ -38,6 +39,7 @@ export const Details: FunctionComponent<ExtractCellProps<'details'>> = ({
documents={documents}
title={value?.title}
data={sortedData}
isSaveDisabled={isSaveDisabled}
contextUpdateMethod={contextUpdateMethod}
onSubmit={onSubmit}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const EditableDetails: FunctionComponent<IEditableDetails> = ({
documents,
title,
workflowId,
isSaveDisabled,
contextUpdateMethod = 'base',
onSubmit: onSubmitCallback,
}) => {
Expand Down Expand Up @@ -427,7 +428,11 @@ export const EditableDetails: FunctionComponent<IEditableDetails> = ({
</div>
<div className={`flex justify-end`}>
{data?.some(({ isEditable }) => isEditable) && (
<Button type="submit" className={`ms-auto mt-3`}>
<Button
type="submit"
className={`ms-auto mt-3 aria-disabled:pointer-events-none aria-disabled:opacity-50`}
aria-disabled={isSaveDisabled}
>
Save
</Button>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface IEditableDetails {
documents: IEditableDetailsDocument[];
title: string;
workflowId: string;
isSaveDisabled?: boolean;
contextUpdateMethod?: 'base' | 'director';
onSubmit?: (document: AnyObject) => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ export const useKycBlock = ({
}}
disabled={isDisabled}
size={'wide'}
variant={'success'}
className={ctw({
'!bg-success': !isDisabled,
})}
>
Approve
</MotionButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ export const MultiDocuments: FunctionComponent<IMultiDocumentsProps> = ({ value

return (
<div className={`m-2 rounded p-1`}>
<Case.Documents documents={documents} isLoading={value?.isLoading} />
<Case.Documents
documents={documents}
isDocumentEditable={value?.isDocumentEditable}
isLoading={value?.isLoading}
onOcrPressed={value?.onOcrPressed}
isLoadingOCR={value?.isLoadingOCR}
/>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export interface IMultiDocumentsProps {
value: {
isLoading: boolean;
onOcrPressed: () => void;
isLoadingOCR: boolean;
isDocumentEditable: boolean;
data: Array<{
imageUrl: string;
title: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export type TDetailsCell = {
hideSeparator?: boolean;
documents?: IEditableDetailsDocument[];
contextUpdateMethod?: 'base' | 'director';
isSaveDisabled?: boolean;
value: {
id: string;
title: string;
Expand Down
Loading

0 comments on commit 1ef0964

Please sign in to comment.