Skip to content

Commit 36d47a6

Browse files
committed
feat(bug by usecase): center chart & use right title
1 parent 4967f34 commit 36d47a6

File tree

3 files changed

+47
-16
lines changed

3 files changed

+47
-16
lines changed

src/pages/Campaign/widgets/UniqueBugs4UseCase/ChartUniqueBugs4UseCase.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PieChart, Skeleton } from '@appquality/unguess-design-system';
1+
import { PieChart, Skeleton, theme } from '@appquality/unguess-design-system';
22
import { BugsByUseCaseVisualizationProps } from './types';
33
import { useBugsByUsecase } from './useBugsByUsecase';
44
import { useMaxItems } from './useMaxItems';
@@ -13,11 +13,12 @@ export const ChartUniqueBugs4UseCase = ({
1313
return <Skeleton />;
1414
}
1515
return (
16-
<div
17-
style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}
18-
>
16+
<div style={{ marginBottom: theme.space.lg }}>
1917
<PieChart
20-
legend
18+
legend={{
19+
width: '100%',
20+
columns: 2,
21+
}}
2122
width="100%"
2223
height="270px"
2324
centerItem={{ label: 'Tot. Bugs', value: total.toString() }}

src/pages/Campaign/widgets/UniqueBugs4UseCase/useBugsByUsecase.ts

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,39 @@
11
import { useState, useEffect } from 'react';
2-
import { useGetCampaignsByCidWidgetsQuery } from 'src/features/api';
2+
import {
3+
useGetCampaignsByCidWidgetsQuery,
4+
WidgetBugsByUseCase,
5+
} from 'src/features/api';
6+
37
import { WidgetItem } from './types';
48

9+
function abbreviateUsecase(string: string): string {
10+
return string
11+
.toLowerCase()
12+
.replace(/use case /, 'UC')
13+
.replace(/caso d'uso /, 'UC');
14+
}
15+
16+
function getSimpleTitle(title: WidgetBugsByUseCase['data'][0]['title']) {
17+
if (title.simple) {
18+
return title.simple.toLowerCase();
19+
}
20+
return title.full
21+
.replace(/\[(.*?)\]/, '')
22+
.replace(/use case\s?[0-9]*:*/i, '')
23+
.replace(/caso d'uso\s?[0-9]*:*/i, '')
24+
.toLowerCase();
25+
}
26+
function getArcLinkLabel(title: WidgetBugsByUseCase['data'][0]['title']) {
27+
return abbreviateUsecase(title.full);
28+
}
29+
30+
function getLegendLabel(title: WidgetBugsByUseCase['data'][0]['title']) {
31+
if (title.prefix && title.simple) {
32+
return `${title.prefix} ${title.simple}`;
33+
}
34+
return getSimpleTitle(title);
35+
}
36+
537
export const useBugsByUsecase = (campaignId: string) => {
638
const { data, isFetching, isLoading, isError } =
739
useGetCampaignsByCidWidgetsQuery({
@@ -20,18 +52,11 @@ export const useBugsByUsecase = (campaignId: string) => {
2052
setTotal(currentTotal);
2153
setItems(
2254
data.data.map((item) => ({
23-
id: item.title
24-
.replace(/use case/i, 'UC')
25-
.replace(/caso d'uso/i, 'UC')
26-
.toLowerCase(),
27-
label: item.title
28-
.replace(/\[(.*?)\]/, '')
29-
.replace(/use case\s?[0-9]*:*/i, '')
30-
.replace(/caso d'uso\s?[0-9]*:*/i, '')
31-
.toLowerCase(),
55+
id: getArcLinkLabel(item.title),
56+
label: getLegendLabel(item.title),
3257
value: item.bugs,
3358
key: item.usecase_id,
34-
children: item.title,
59+
children: item.title.full,
3560
numerator: item.bugs,
3661
denominator: currentTotal,
3762
}))

src/pages/Campaign/widgets/widgetCards/FlipCard/FlipCardBody.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ const WidgetCardFaceContent = styled.div`
1515
1616
background-color: white;
1717
width: 100%;
18+
height: 100%;
19+
display: flex;
20+
flex-direction: column;
21+
align-items: center;
22+
justify-content: center;
1823
1924
&.face-enter {
2025
opacity: 0;

0 commit comments

Comments
 (0)