Skip to content

Commit

Permalink
feat(business-report): upgrade user-facing part of the social media d…
Browse files Browse the repository at this point in the history
…ata UI (BAL-2577) (#2911)

* feat(business-report): upgrade user-facing part of the social media data UI

* fix: categories icon & key prop for mapped el

* fix: minor code style correction

* chore: bump packages that depend on ui

* chore: update lockfile

* fix: hide ads section
  • Loading branch information
r4zendev authored Dec 30, 2024
1 parent ebd8447 commit 5219746
Show file tree
Hide file tree
Showing 23 changed files with 462 additions and 218 deletions.
7 changes: 7 additions & 0 deletions apps/kyb-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# kyb-app

## 0.3.100

### Patch Changes

- Updated dependencies
- @ballerine/ui@0.5.56

## 0.3.99

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions apps/kyb-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/kyb-app",
"private": true,
"version": "0.3.99",
"version": "0.3.100",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -17,7 +17,7 @@
"dependencies": {
"@ballerine/blocks": "0.2.30",
"@ballerine/common": "^0.9.61",
"@ballerine/ui": "0.5.55",
"@ballerine/ui": "0.5.56",
"@ballerine/workflow-browser-sdk": "0.6.80",
"@lukemorales/query-key-factory": "^1.0.3",
"@radix-ui/react-icons": "^1.3.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/react-pdf-toolkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @ballerine/react-pdf-toolkit

## 1.2.56

### Patch Changes

- Updated dependencies
- @ballerine/ui@0.5.56

## 1.2.55

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/react-pdf-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/react-pdf-toolkit",
"private": false,
"version": "1.2.55",
"version": "1.2.56",
"types": "./dist/build.d.ts",
"main": "./dist/react-pdf-toolkit.js",
"module": "./dist/react-pdf-toolkit.mjs",
Expand All @@ -27,7 +27,7 @@
},
"dependencies": {
"@ballerine/config": "^1.1.28",
"@ballerine/ui": "0.5.55",
"@ballerine/ui": "0.5.56",
"@react-pdf/renderer": "^3.1.14",
"@sinclair/typebox": "^0.31.7",
"ajv": "^8.12.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @ballerine/ui

## 0.5.56

### Patch Changes

- Updated user-facing social media view

## 0.5.55

### Patch Changes
Expand Down
5 changes: 3 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ballerine/ui",
"private": false,
"version": "0.5.55",
"version": "0.5.56",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -18,6 +18,7 @@
"dev": "vite",
"clean": "rimraf ./tsconfig.tsbuildinfo && rimraf ./dist",
"build": "tsc && vite build",
"build:watch": "vite build --watch",
"lint": "eslint . --fix",
"format": "prettier --write .",
"preview": "vite preview",
Expand Down Expand Up @@ -53,7 +54,7 @@
"dayjs": "^1.11.6",
"i18n-iso-countries": "^7.6.0",
"lodash": "^4.17.21",
"lucide-react": "^0.144.0",
"lucide-react": "^0.245.0",
"react": "^18.0.37",
"react-dom": "^18.0.5",
"react-error-boundary": "^4.0.13",
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/components/atoms/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const buttonVariants = cva(
secondary: 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
browserLink:
'text-blue-600 hover:text-blue-800 visited:text-purple-600 underline-offset-4 hover:underline',
},
size: {
default: 'h-9 px-4 py-2',
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/atoms/Image/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { useImageProps } from 'react-image';
export interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 'src'> {
src: useImageProps['srcList'];
useImageProps?: Omit<useImageProps, 'srcList'>;
width: CSSProperties['width'];
height: CSSProperties['height'];
width?: CSSProperties['width'];
height?: CSSProperties['height'];
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './ads-provider-adapter';
export * from './create-report-adapter';
export * from './report-adapter';
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { AdsProviders, severityToDisplaySeverity } from '@/components/templates/report/constants';
import { adsProviderAdapter } from '@/components';
import { severityToDisplaySeverity } from '@/components/templates/report/constants';
import { TAdsProvider } from '@/components/templates/report/types';
import { SeverityType } from '@ballerine/common';
import { booleanToYesOrNo, SeverityType } from '@ballerine/common';

const getLabel = ({ label, provider }: { label: string; provider: string }) => {
if (label === 'page') {
Expand All @@ -23,6 +22,47 @@ export const toRiskLabels = (riskIndicators: Array<{ name: string; riskLevel: st
}));
};

export const toSocialMediaPresence = (data: Record<string, any>) => {
const { facebookData, instagramData } = data ?? {};

return {
facebook: {
page: facebookData?.pageUrl,
id: facebookData?.id,
creationDate: facebookData?.creationDate,
categories: facebookData?.pageCategories,
address: facebookData?.address,
phoneNumber: facebookData?.phoneNumber,
email: facebookData?.email,
likes: facebookData?.numberOfLikes,
},
instagram: {
page: instagramData?.pageUrl,
userName: instagramData?.username,
categories: instagramData?.pageCategories,
biography: instagramData?.biography,
followers: instagramData?.numberOfFollowers,
isBusinessAccount: booleanToYesOrNo(instagramData?.isBusinessAccount),
isVerified: booleanToYesOrNo(instagramData?.isVerified),
},
} as const satisfies Record<Lowercase<TAdsProvider>, Record<string, unknown>>;
};

export const toAdsImages = (data: Record<string, any>) => {
const { facebookData, instagramData } = data ?? {};

return {
facebook: {
src: facebookData?.screenshotUrl,
link: facebookData?.pageUrl,
},
instagram: {
src: instagramData?.screenshotUrl,
link: instagramData?.pageUrl,
},
};
};

const normalizeRiskLevel = (riskTypeLevels: Record<string, SeverityType>) => {
return Object.entries(riskTypeLevels).reduce((acc, [riskType, riskLevel]) => {
acc[riskType] =
Expand All @@ -41,30 +81,7 @@ export const reportAdapter = {
adsAndSocialMediaAnalysis: toRiskLabels(
report?.summary?.riskIndicatorsByDomain?.adsAndSocialViolations,
),
adsAndSocialMediaPresence: [
...Object.entries({ facebook: report?.socialMedia?.facebookData ?? {} }),
...Object.entries({ instagram: report?.socialMedia?.instagramData ?? {} }),
]
.map(([provider, data]) => {
if (!AdsProviders.includes(provider.toUpperCase() as TAdsProvider)) {
return;
}

const adapter = adsProviderAdapter[provider as keyof typeof adsProviderAdapter];
const adaptedData = adapter(data);

return {
label: provider,
items: Object.entries(adaptedData).map(([label, value]) => ({
label: getLabel({
label,
provider,
}),
value,
})),
};
})
?.filter((value): value is NonNullable<typeof value> => Boolean(value)),
adsAndSocialMediaPresence: toSocialMediaPresence(report?.socialMedia),
websiteLineOfBusinessAnalysis:
report?.summary?.riskIndicatorsByDomain?.lineOfBusinessViolations?.map(
({
Expand Down Expand Up @@ -125,16 +142,7 @@ export const reportAdapter = {
websiteCredibilityAnalysis: toRiskLabels(
report?.summary?.riskIndicatorsByDomain?.tldViolations,
),
adsImages: [
...Object.entries({ facebook: report?.socialMedia?.facebookData ?? {} }),
...Object.entries({ instagram: report?.socialMedia?.instagramData ?? {} }),
]
.map(([provider, data]) => ({
provider,
src: data?.screenshotUrl,
link: data?.pageUrl,
}))
.filter(({ src }: { src: string }) => !!src),
adsImages: toAdsImages(report?.socialMedia),
relatedAdsImages: report?.socialMedia?.pickedAds
?.map((data: { screenshotUrl: string; link: string }) => ({
src: data?.screenshotUrl,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5219746

Please sign in to comment.