Skip to content

Commit acc97cf

Browse files
authored
Add/Remove UBOs sign-off and pr comments (#2915)
* feat(*): added the ability to add and remove ubos * refactor(*): pr review changes * chore(*): updated packages * fix(workflow-service): fixed path to definition * chore(workflows-service): no longer importing from data-migrations * removed unused import * fixed failing test * refactor(*): pR comments and sign-off changes * chore(*): updated packages/ui * fix(backoffice-v2): fixed bug caused by prettier * fix(backoffice-vs): no longer closing ubos dialog after creating a ubo
1 parent 01c1a6c commit acc97cf

File tree

18 files changed

+149
-62
lines changed

18 files changed

+149
-62
lines changed

apps/backoffice-v2/src/domains/ui-definition/fetchers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { z } from 'zod';
88
export const translateUiDefinition = async ({
99
id,
1010
partialUiDefinition,
11+
locale,
1112
}: {
1213
id: string;
1314
partialUiDefinition: Record<string, unknown>;
15+
locale: string;
1416
}) => {
1517
const [data, error] = await apiClient({
16-
endpoint: `../case-management/ui-definition/${id}/translate/en`,
18+
endpoint: `../case-management/ui-definition/${id}/translate/${locale}`,
1719
method: Method.POST,
1820
body: {
1921
partialUiDefinition,

apps/backoffice-v2/src/domains/ui-definition/hooks/queries/useTranslateUiDefinitionQuery/useTranslateUiDefinitionQuery.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import { uiDefinitionQueryKeys } from '@/domains/ui-definition/query-keys';
55
export const useTranslateUiDefinitionQuery = ({
66
id,
77
partialUiDefinition,
8+
locale,
89
}: {
910
id: string;
1011
partialUiDefinition: Record<string, unknown>;
12+
locale: string;
1113
}) => {
1214
return useQuery({
13-
...uiDefinitionQueryKeys.translate({ id, partialUiDefinition }),
15+
...uiDefinitionQueryKeys.translate({ id, partialUiDefinition, locale }),
1416
enabled: !!partialUiDefinition && !!id,
1517
});
1618
};

apps/backoffice-v2/src/domains/ui-definition/query-keys.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ export const uiDefinitionQueryKeys = createQueryKeys('ui-definition', {
55
translate: ({
66
id,
77
partialUiDefinition,
8+
locale,
89
}: {
910
id: string;
1011
partialUiDefinition: Record<string, unknown>;
12+
locale: string;
1113
}) => {
1214
return {
1315
queryKey: [
1416
{
1517
id,
1618
partialUiDefinition,
19+
locale,
1720
},
1821
],
19-
queryFn: () => translateUiDefinition({ id, partialUiDefinition }),
22+
queryFn: () => translateUiDefinition({ id, partialUiDefinition, locale }),
2023
};
2124
},
2225
});

apps/backoffice-v2/src/domains/workflow-definitions/fetchers.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ export const WorkflowDefinitionConfigSchema = z
5656
.optional(),
5757
})
5858
.optional(),
59+
ubos: z
60+
.object({
61+
create: z
62+
.object({
63+
enabled: z.boolean().optional(),
64+
})
65+
.optional(),
66+
})
67+
.optional(),
5968
})
6069
.passthrough()
6170
.nullable();

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -373,19 +373,6 @@ export const useKycBlock = ({
373373
className: 'mt-0',
374374
},
375375
})
376-
.addCell({
377-
type: 'callToAction',
378-
value: {
379-
text: 'Initiate KYC',
380-
onClick: onInitiateKyc,
381-
props: {
382-
className:
383-
'justify-self-end px-2 py-0 text-xs aria-disabled:pointer-events-none aria-disabled:opacity-50',
384-
variant: 'outline',
385-
disabled: !event,
386-
},
387-
},
388-
})
389376
.build()
390377
.flat(1),
391378
})
@@ -564,6 +551,19 @@ export const useKycBlock = ({
564551
className: 'py-4 text-slate-500',
565552
},
566553
})
554+
.addCell({
555+
type: 'callToAction',
556+
value: {
557+
text: 'Initiate KYC',
558+
onClick: onInitiateKyc,
559+
props: {
560+
className:
561+
'px-2 py-0 text-xs aria-disabled:pointer-events-none aria-disabled:opacity-50 ms-3',
562+
variant: 'outline',
563+
disabled: !event,
564+
},
565+
},
566+
})
567567
.buildFlat(),
568568
})
569569
.addCell({

apps/backoffice-v2/src/lib/blocks/hooks/useManageUbosBlock/useManageUbosBlock.tsx

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,40 @@ import { transformErrors } from '@/pages/Entities/components/CaseCreation/compon
2525
import { useTranslateUiDefinitionQuery } from '@/domains/ui-definition/hooks/queries/useTranslateUiDefinitionQuery/useTranslateUiDefinitionQuery';
2626
import { useDeleteUbosByIdsMutation } from '@/domains/workflows/hooks/mutations/useDeleteUbosByIdsMutation/useDeleteUbosByIdsMutation';
2727
import { useCreateUboMutation } from '@/domains/workflows/hooks/mutations/useCreateUboMutation/useCreateUboMutation';
28+
import { useLocale } from '@/common/hooks/useLocale/useLocale';
2829

29-
export const useManageUbosBlock = () => {
30+
export const useManageUbosBlock = ({
31+
create,
32+
}: {
33+
create: {
34+
enabled: boolean;
35+
};
36+
}) => {
3037
const { data: workflow } = useCurrentCaseQuery();
3138
const { data: workflowDefinition } = useWorkflowDefinitionByIdQuery({
3239
workflowDefinitionId: workflow?.workflowDefinition?.id ?? '',
3340
});
3441
const uiDefinition = workflowDefinition?.uiDefinitions?.find(
3542
uiDefinition => uiDefinition.uiContext === 'collection_flow',
3643
);
44+
const locale = useLocale();
3745
const { data: translatedUbos } = useTranslateUiDefinitionQuery({
3846
id: uiDefinition?.id ?? '',
3947
partialUiDefinition: ubosFormJsonDefinition,
48+
locale,
4049
});
4150
const { formSchema, uiSchema } = createFormSchemaFromUIElements(translatedUbos ?? {});
4251
const [isAddingUbo, _toggleIsAddingUbo, toggleOnIsAddingUbo, toggleOffIsAddingUbo] = useToggle();
52+
const [isManageUbosOpen, toggleIsManageUbosOpen] = useToggle();
4353
const { mutate: mutateCreateUbo } = useCreateUboMutation({
4454
workflowId: workflow?.id,
45-
onSuccess: toggleOffIsAddingUbo,
55+
onSuccess: () => {
56+
if (!isAddingUbo) {
57+
return;
58+
}
59+
60+
toggleOffIsAddingUbo();
61+
},
4662
});
4763
const { mutate: mutateDeleteUbosByIds } = useDeleteUbosByIdsMutation({
4864
workflowId: workflow?.id,
@@ -107,6 +123,7 @@ export const useManageUbosBlock = () => {
107123
<Dialog
108124
trigger={
109125
<Button
126+
type={'button'}
110127
variant={'ghost'}
111128
size={'icon'}
112129
className={'aria-disabled:pointer-events-none aria-disabled:opacity-50'}
@@ -119,7 +136,7 @@ export const useManageUbosBlock = () => {
119136
description={
120137
<p className={`text-sm`}>
121138
Are you sure you want to remove this UBO? This action will be logged, and the
122-
UBO&apos;s data will be removed from the case and webhooks.
139+
UBO&apos;s data will be removed from the case.
123140
</p>
124141
}
125142
content={null}
@@ -191,8 +208,11 @@ export const useManageUbosBlock = () => {
191208
type: 'node',
192209
value: (
193210
<Dialog
211+
open={isManageUbosOpen}
212+
onOpenChange={toggleIsManageUbosOpen}
194213
trigger={
195214
<Button
215+
type={'button'}
196216
variant="outline"
197217
className={
198218
'ms-auto px-2 py-0 text-xs aria-disabled:pointer-events-none aria-disabled:opacity-50'
@@ -204,7 +224,7 @@ export const useManageUbosBlock = () => {
204224
}
205225
content={
206226
<div className={'flex flex-col justify-between space-y-4'}>
207-
{!isAddingUbo && (
227+
{(!create.enabled || !isAddingUbo) && (
208228
<div className={'flex flex-col gap-4'}>
209229
<h2 className={'text-lg font-semibold'}>Manage UBOs</h2>
210230
<UrlDataTable
@@ -216,34 +236,51 @@ export const useManageUbosBlock = () => {
216236
}}
217237
props={{
218238
scroll: {
219-
className: 'h-[73vh]',
239+
className: '[&>div]:max-h-[73vh]',
220240
},
221241
}}
222242
/>
223-
<Button
224-
className={'ms-auto aria-disabled:pointer-events-none aria-disabled:opacity-50'}
225-
onClick={toggleOnIsAddingUbo}
226-
aria-disabled={!caseState.writeEnabled}
227-
>
228-
Add
229-
</Button>
243+
{create.enabled && (
244+
<Button
245+
type={'button'}
246+
className={
247+
'ms-auto aria-disabled:pointer-events-none aria-disabled:opacity-50'
248+
}
249+
onClick={toggleOnIsAddingUbo}
250+
aria-disabled={!caseState.writeEnabled}
251+
>
252+
Add UBO
253+
</Button>
254+
)}
230255
</div>
231256
)}
232-
{isAddingUbo && (
233-
<div className={'flex flex-col gap-4'}>
234-
<Button variant={'ghost'} onClick={toggleOffIsAddingUbo} className={'me-auto'}>
235-
<ArrowLeft className={'text-muted-foreground'} size={14} />
257+
{create.enabled && isAddingUbo && (
258+
<>
259+
<Button
260+
type={'button'}
261+
variant={'ghost'}
262+
onClick={toggleOffIsAddingUbo}
263+
className={
264+
'absolute left-4 top-4 rounded-sm p-0 opacity-70 transition-opacity d-4 hover:bg-transparent hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 data-[state=open]:bg-slate-100 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-900 dark:data-[state=open]:bg-slate-800'
265+
}
266+
>
267+
<ArrowLeft className={'d-4'} />
236268
</Button>
237-
<ScrollArea orientation={'vertical'} className={'h-[73vh]'}>
238-
<DynamicForm
239-
schema={formSchema}
240-
uiSchema={uiSchema}
241-
onSubmit={onSubmit}
242-
layouts={layouts as typeof baseLayouts}
243-
transformErrors={transformErrors}
244-
/>
245-
</ScrollArea>
246-
</div>
269+
270+
<div className={'flex flex-col gap-4'}>
271+
<h2 className={'text-lg font-semibold'}>Add UBO</h2>
272+
<ScrollArea orientation={'vertical'} className={'h-[73vh]'}>
273+
<DynamicForm
274+
schema={formSchema}
275+
uiSchema={uiSchema}
276+
onSubmit={onSubmit}
277+
layouts={layouts as typeof baseLayouts}
278+
transformErrors={transformErrors}
279+
className={'[&>div>fieldset>div:first-of-type]:py-0 [&>div]:py-0'}
280+
/>
281+
</ScrollArea>
282+
</div>
283+
</>
247284
)}
248285
</div>
249286
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,12 @@ export const useDefaultBlocksLogic = () => {
339339
isRequestTimedOut: workflow?.context?.pluginsOutput?.ubo?.isRequestTimedOut,
340340
});
341341

342-
const manageUbosBlock = useManageUbosBlock();
342+
const manageUbosBlock = useManageUbosBlock({
343+
create: {
344+
...workflow?.workflowDefinition?.config?.ubos?.create,
345+
enabled: workflow?.workflowDefinition?.config?.ubos?.create?.enabled ?? false,
346+
},
347+
});
343348

344349
const directorsUserProvidedBlock = useDirectorsUserProvidedBlock(directorsUserProvided);
345350

apps/kyb-app/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# kyb-app
22

3+
## 0.3.98
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
- @ballerine/ui@0.5.55
9+
310
## 0.3.97
411

512
### Patch Changes

apps/kyb-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@ballerine/kyb-app",
33
"private": true,
4-
"version": "0.3.97",
4+
"version": "0.3.98",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
@@ -17,7 +17,7 @@
1717
"dependencies": {
1818
"@ballerine/blocks": "0.2.30",
1919
"@ballerine/common": "^0.9.60",
20-
"@ballerine/ui": "0.5.54",
20+
"@ballerine/ui": "0.5.55",
2121
"@ballerine/workflow-browser-sdk": "0.6.79",
2222
"@lukemorales/query-key-factory": "^1.0.3",
2323
"@radix-ui/react-icons": "^1.3.0",

packages/react-pdf-toolkit/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @ballerine/react-pdf-toolkit
22

3+
## 1.2.55
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
- @ballerine/ui@0.5.55
9+
310
## 1.2.54
411

512
### Patch Changes

0 commit comments

Comments
 (0)