Skip to content

Commit 50b9aac

Browse files
feat: backoffice ui improvements (#2827)
1 parent ac65909 commit 50b9aac

File tree

8 files changed

+71
-30
lines changed

8 files changed

+71
-30
lines changed

apps/backoffice-v2/src/common/hooks/useSearchParamsByEntity/validation-schemas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export const MonitoringReportsTabs = [
3939

4040
export const CaseTabs = [
4141
'summary',
42-
'companyInformation',
43-
'storeInfo',
42+
'company',
43+
'store',
4444
'documents',
4545
'ubos',
4646
'associatedCompanies',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const useAssociatedCompaniesInformationBlock = (workflows: TWorkflowById[
4040
type: 'details',
4141
hideSeparator: true,
4242
value: {
43-
title: 'Company Information',
43+
title: 'Company',
4444
data: Object.entries(entityData)?.map(([title, value]) => ({
4545
title,
4646
value,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const useStoreInfoBlock = ({ storeInfo, workflow }) => {
1616
.addBlock()
1717
.addCell({
1818
type: 'heading',
19-
value: 'Store Info',
19+
value: 'Store',
2020
})
2121
.addCell({
2222
type: 'subheading',

apps/backoffice-v2/src/lib/blocks/variants/DefaultBlocks/hooks/useCaseBlocksLogic/utils/get-tabs-block-map.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const getTabsToBlocksMap = ({
6767
? merchantScreeningBlock
6868
: []),
6969
],
70-
[Tab.COMPANY_INFORMATION]: [
70+
[Tab.COMPANY]: [
7171
...entityInfoBlock,
7272
// ...mapBlock,
7373
...addressWithContainerBlock,
@@ -76,11 +76,7 @@ export const getTabsToBlocksMap = ({
7676
...companySanctionsBlock,
7777
...bankingDetailsBlock,
7878
],
79-
[Tab.STORE_INFO]: [
80-
...storeInfoBlock,
81-
...processingDetailsBlock,
82-
...websiteBasicRequirementBlock,
83-
],
79+
[Tab.STORE]: [...storeInfoBlock, ...processingDetailsBlock, ...websiteBasicRequirementBlock],
8480
[Tab.DOCUMENTS]: [...parentDocumentBlocks],
8581
[Tab.UBOS]: [
8682
...ubosUserProvidedBlock,

apps/backoffice-v2/src/lib/blocks/variants/DefaultBlocks/hooks/useCaseBlocksLogic/utils/get-variant-tabs.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { WorkflowDefinitionConfigThemeEnum } from '@ballerine/common';
55

66
export const Tab = {
77
SUMMARY: 'SUMMARY',
8-
COMPANY_INFORMATION: 'COMPANY_INFORMATION',
9-
STORE_INFO: 'STORE_INFO',
8+
COMPANY: 'COMPANY',
9+
STORE: 'STORE',
1010
DOCUMENTS: 'DOCUMENTS',
1111
UBOS: 'UBOS',
1212
ASSOCIATED_COMPANIES: 'ASSOCIATED_COMPANIES',
@@ -28,14 +28,14 @@ export const getVariantTabs = (
2828
disabled: !tabBlocks[Tab.SUMMARY]?.length,
2929
},
3030
{
31-
name: Tab.COMPANY_INFORMATION,
32-
displayName: 'Company Information',
33-
disabled: !tabBlocks[Tab.COMPANY_INFORMATION]?.length,
31+
name: Tab.COMPANY,
32+
displayName: 'Company',
33+
disabled: !tabBlocks[Tab.COMPANY]?.length,
3434
},
3535
{
36-
name: Tab.STORE_INFO,
37-
displayName: 'Store Info',
38-
disabled: !tabBlocks[Tab.STORE_INFO]?.length,
36+
name: Tab.STORE,
37+
displayName: 'Store',
38+
disabled: !tabBlocks[Tab.STORE]?.length,
3939
},
4040
{
4141
name: Tab.DOCUMENTS,

apps/backoffice-v2/src/pages/Entities/components/Cases/Cases.Item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const Item: FunctionComponent<IItemProps> = ({
7676
</motion.div>
7777
<Avatar
7878
src={entityAvatarUrl}
79-
className="text-sm d-8"
79+
className="text-base font-semibold d-8"
8080
alt={`${fullName}'s avatar`}
8181
placeholder={entityInitials}
8282
style={{

apps/backoffice-v2/src/pages/Entity/components/Case/Case.Actions.tsx

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Badge } from '@ballerine/ui';
2-
import { FunctionComponent } from 'react';
2+
import { FunctionComponent, useMemo } from 'react';
33
import { StateTag } from '@ballerine/common';
44

55
import { tagToBadgeData } from './consts';
@@ -10,6 +10,9 @@ import { useCaseActionsLogic } from './hooks/useCaseActionsLogic/useCaseActionsL
1010
import { AssignDropdown } from '@/common/components/atoms/AssignDropdown/AssignDropdown';
1111
import { CaseOptions } from '@/pages/Entity/components/Case/components/CaseOptions/CaseOptions';
1212
import { ActionsVariant } from '@/pages/Entity/components/Case/actions-variants/ActionsVariant/ActionsVariant';
13+
import { Avatar } from '@/common/components/atoms/Avatar';
14+
import { stringToRGB } from '@/common/utils/string-to-rgb/string-to-rgb';
15+
import { createInitials } from '@/common/utils/create-initials/create-initials';
1316

1417
/**
1518
* @description To be used by {@link Case}. Displays the entity's full name, avatar, and handles the reject/approve mutation.
@@ -26,6 +29,7 @@ import { ActionsVariant } from '@/pages/Entity/components/Case/actions-variants/
2629
export const Actions: FunctionComponent<IActionsProps> = ({
2730
id,
2831
fullName,
32+
workflow,
2933
numberOfNotes,
3034
showResolutionButtons,
3135
}) => {
@@ -40,6 +44,9 @@ export const Actions: FunctionComponent<IActionsProps> = ({
4044
isWorkflowCompleted,
4145
} = useCaseActionsLogic({ workflowId: id, fullName });
4246

47+
const entityInitials = createInitials(fullName);
48+
const rgb = useMemo(() => stringToRGB(fullName), [fullName]);
49+
4350
return (
4451
<div className={`col-span-2 space-y-2 bg-base-100 px-4 pt-4`}>
4552
<div className={`mb-8 flex flex-row justify-between space-x-3.5`}>
@@ -56,14 +63,26 @@ export const Actions: FunctionComponent<IActionsProps> = ({
5663
</div>
5764
<div className={`min-h-20 flex justify-between gap-4`}>
5865
<div className={`flex flex-col space-y-3`}>
59-
<h2
60-
className={ctw(`w-full max-w-[35ch] break-all text-4xl font-semibold leading-9`, {
61-
'h-8 w-full max-w-[24ch] animate-pulse rounded-md bg-gray-200 theme-dark:bg-neutral-focus':
62-
isLoadingCase,
63-
})}
64-
>
65-
{fullName}
66-
</h2>
66+
<div className={`flex space-x-4`}>
67+
<Avatar
68+
src={workflow?.entity?.avatarUrl || ''}
69+
className="text-base font-semibold d-8"
70+
alt={`${fullName}'s avatar`}
71+
placeholder={entityInitials}
72+
style={{
73+
color: `rgb(${rgb})`,
74+
backgroundColor: `rgba(${rgb}, 0.2)`,
75+
}}
76+
/>
77+
<h2
78+
className={ctw(`w-full max-w-[35ch] break-all text-2xl font-semibold leading-9`, {
79+
'h-8 w-full max-w-[24ch] animate-pulse rounded-md bg-gray-200 theme-dark:bg-neutral-focus':
80+
isLoadingCase,
81+
})}
82+
>
83+
{fullName}
84+
</h2>
85+
</div>
6786
<div className={`flex items-center space-x-6`}>
6887
{tag && (
6988
<div className={`flex space-x-2`}>

services/workflows-service/src/workflow/workflow.service.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ const COLLECTION_FLOW_EVENTS_WHITELIST: readonly CollectionFlowEvent[] = [
128128
'revision',
129129
] as const;
130130

131+
const getAvatarUrl = (website: string | undefined | null) =>
132+
website
133+
? `https://t2.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=${website}&size=40`
134+
: null;
135+
131136
@Injectable()
132137
export class WorkflowService {
133138
constructor(
@@ -281,8 +286,8 @@ export class WorkflowService {
281286
return {
282287
id: workflow?.business?.id,
283288
name: workflow?.business?.companyName,
284-
avatarUrl: null,
285289
approvalState: workflow?.business?.approvalState,
290+
avatarUrl: getAvatarUrl(workflow?.business?.website),
286291
};
287292
}
288293

@@ -562,6 +567,8 @@ export class WorkflowService {
562567
return workflows.map(workflow => {
563568
const isIndividual = 'endUser' in workflow;
564569

570+
const businessWebsiteUrl = !isIndividual && getAvatarUrl(workflow?.business?.website);
571+
565572
return {
566573
id: workflow?.id,
567574
status: workflow?.status,
@@ -571,7 +578,7 @@ export class WorkflowService {
571578
name: isIndividual
572579
? `${String(workflow?.endUser?.firstName)} ${String(workflow?.endUser?.lastName)}`
573580
: workflow?.business?.companyName,
574-
avatarUrl: isIndividual ? workflow?.endUser?.avatarUrl : null,
581+
avatarUrl: isIndividual ? workflow?.endUser?.avatarUrl : businessWebsiteUrl,
575582
approvalState: isIndividual
576583
? workflow?.endUser?.approvalState
577584
: workflow?.business?.approvalState,
@@ -2140,6 +2147,25 @@ export class WorkflowService {
21402147
});
21412148
});
21422149

2150+
service.subscribe('PERSIST_WEBSITE', async ({ payload = {} }) => {
2151+
if (!payload.website) {
2152+
return;
2153+
}
2154+
2155+
const typedPayload = payload as {
2156+
website: string;
2157+
};
2158+
2159+
await this.businessService.updateById(
2160+
workflowRuntimeData.context.entity.ballerineEntityId,
2161+
{
2162+
data: {
2163+
website: typedPayload.website,
2164+
},
2165+
},
2166+
);
2167+
});
2168+
21432169
if (!service.getSnapshot().nextEvents.includes(type)) {
21442170
throw new BadRequestException(
21452171
`Event ${type} does not exist for workflow ${workflowDefinition.id}'s state: ${workflowRuntimeData.state}`,

0 commit comments

Comments
 (0)