Skip to content

Commit 6a74106

Browse files
authored
🪟 🧹 Round credits values on credit consumption page (#21873)
* Round credits values in table and chart * round to two decimal places * get rid of styled component
1 parent ec934ad commit 6a74106

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

airbyte-webapp/src/components/ui/BarChart/BarChart.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useMemo } from "react";
2+
import { FormattedNumber } from "react-intl";
23
import {
34
Bar,
45
BarChart as BasicBarChart,
@@ -63,7 +64,12 @@ export const BarChart: React.FC<BarChartProps> = React.memo(({ data, legendLabel
6364
>
6465
<Label value={yLabel} fontSize={11} fill={chartTicksColor} fontWeight={600} position="top" offset={10} />
6566
</YAxis>
66-
<Tooltip cursor={{ fill: chartHoverFill }} />
67+
<Tooltip
68+
cursor={{ fill: chartHoverFill }}
69+
formatter={(value: number) => {
70+
return [<FormattedNumber value={value} maximumFractionDigits={2} minimumFractionDigits={2} />, yLabel];
71+
}}
72+
/>
6773
{legendLabels.map((barName, key) => (
6874
<Bar key={barName} dataKey={barName} fill={barChartColors[key]} />
6975
))}

airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/RemainingCredits.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ const RemainingCredits: React.FC<Props> = ({ selfServiceCheckoutEnabled }) => {
137137
<CreditView>
138138
<FormattedMessage id="credits.remainingCredits" />
139139
<Count>
140-
<FormattedNumber value={cloudWorkspace.remainingCredits} />
140+
<FormattedNumber
141+
value={cloudWorkspace.remainingCredits}
142+
maximumFractionDigits={2}
143+
minimumFractionDigits={2}
144+
/>
141145
</Count>
142146
</CreditView>
143147
<Actions>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@use "scss/variables";
2+
3+
.content {
4+
padding: 0 variables.$spacing-2xl 0 variables.$spacing-lg;
5+
}
6+
7+
.usageValue {
8+
padding-right: 10px;
9+
min-width: 53px;
10+
}

airbyte-webapp/src/packages/cloud/views/credits/CreditsPage/components/UsagePerConnectionTable.tsx

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import queryString from "query-string";
22
import React, { useCallback } from "react";
3-
import { FormattedMessage } from "react-intl";
3+
import { FormattedMessage, FormattedNumber } from "react-intl";
44
import { useNavigate } from "react-router-dom";
55
import { CellProps } from "react-table";
6-
import styled from "styled-components";
76

87
import { SortOrderEnum } from "components/EntityTable/types";
98
import { Table, SortableTableHeader } from "components/ui/Table";
9+
import { Text } from "components/ui/Text";
1010

1111
import { useQuery } from "hooks/useQuery";
1212
import { CreditConsumptionByConnector } from "packages/cloud/lib/domain/cloudWorkspaces/types";
@@ -15,18 +15,7 @@ import { useSourceDefinitionList } from "services/connector/SourceDefinitionServ
1515

1616
import ConnectionCell from "./ConnectionCell";
1717
import UsageCell from "./UsageCell";
18-
19-
const Content = styled.div`
20-
padding: 0 60px 0 15px;
21-
`;
22-
23-
const UsageValue = styled.div`
24-
font-weight: 500;
25-
font-size: 14px;
26-
line-height: 17px;
27-
padding-right: 10px;
28-
min-width: 53px;
29-
`;
18+
import styles from "./UsagePerConnectionTable.module.scss";
3019

3120
interface UsagePerConnectionTableProps {
3221
creditConsumption: CreditConsumptionByConnector[];
@@ -142,7 +131,11 @@ const UsagePerConnectionTable: React.FC<UsagePerConnectionTableProps> = ({ credi
142131
accessor: "creditsConsumed",
143132
collapse: true,
144133
customPadding: { right: 0 },
145-
Cell: ({ cell }: CellProps<FullTableProps>) => <UsageValue>{cell.value}</UsageValue>,
134+
Cell: ({ cell }: CellProps<FullTableProps>) => (
135+
<Text className={styles.usageValue} size="lg">
136+
<FormattedNumber value={cell.value} maximumFractionDigits={2} minimumFractionDigits={2} />
137+
</Text>
138+
),
146139
},
147140
{
148141
Header: "",
@@ -162,9 +155,9 @@ const UsagePerConnectionTable: React.FC<UsagePerConnectionTableProps> = ({ credi
162155
);
163156

164157
return (
165-
<Content>
158+
<div className={styles.content}>
166159
<Table columns={columns} data={sortingData} light />
167-
</Content>
160+
</div>
168161
);
169162
};
170163

0 commit comments

Comments
 (0)