Skip to content

Commit

Permalink
chore(1-3267): use the user's locale settings for formatting the tool…
Browse files Browse the repository at this point in the history
…tip date (#9113)

This PR updates the tooltip date display in the traffic usage chart to
use the user's chosen locale settings, falling back to en-US if the
settings are unavailable or otherwise unset.

So, for instance, if I have set my locale to "ja-JP", I'd get this
instead of the en US format:

![image](https://github.com/user-attachments/assets/4c1dbeab-3275-405d-ab8b-90f24531caff)
  • Loading branch information
thomasheartman authored Jan 17, 2025
1 parent 2d340f6 commit f6479b1
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { customHighlightPlugin } from 'component/common/Chart/customHighlightPlu
import { formatTickValue } from 'component/common/Chart/formatTickValue';
import { useTrafficLimit } from './hooks/useTrafficLimit';
import { BILLING_TRAFFIC_BUNDLE_PRICE } from 'component/admin/billing/BillingDashboard/BillingPlan/BillingPlan';
import { useLocationSettings } from 'hooks/useLocationSettings';

const StyledBox = styled(Box)(({ theme }) => ({
display: 'grid',
Expand Down Expand Up @@ -144,6 +145,7 @@ export const NetworkTrafficUsage: VFC = () => {

const { isOss } = useUiConfig();

const { locationSettings } = useLocationSettings();
const {
record,
period,
Expand All @@ -169,11 +171,14 @@ export const NetworkTrafficUsage: VFC = () => {
periodItem.month,
Number.parseInt(tooltipItems[0].label),
);
return tooltipDate.toLocaleDateString('en-US', {
month: 'long',
day: 'numeric',
year: 'numeric',
});
return tooltipDate.toLocaleDateString(
locationSettings?.locale ?? 'en-US',
{
month: 'long',
day: 'numeric',
year: 'numeric',
},
);
},
includedTraffic,
);
Expand Down

0 comments on commit f6479b1

Please sign in to comment.