Skip to content

Commit

Permalink
XS-30 fixed locale in month year selector
Browse files Browse the repository at this point in the history
  • Loading branch information
manojx031 committed Jul 31, 2024
1 parent ebc760d commit 1291542
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/components/DatePicker/MonthYearSelector.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import dayjs from "dayjs";
import PropTypes from "prop-types";
import React from "react";
import { Select } from "../Forms/Select";

const today = dayjs();
Expand All @@ -9,11 +9,11 @@ const getDiffInMonths = (to, from) => {
return 12 * (to.getFullYear() - from.getFullYear()) + (to.getMonth() - from.getMonth());
};

export const MonthYearSelector = ({ date, onChange, currentMonth }) => {
const months = [...Array.from({ length: 12 }).keys()].map((m) => today.month(m).format("MMM"));
export const MonthYearSelector = ({ date, locale, onChange, currentMonth }) => {
const months = [...Array.from({ length: 12 }).keys()].map((m) => today.locale(locale).month(m).format("MMM"));
// 2012 as baseline + 5 years in future
const years = [...Array.from({ length: today.year() - 2012 + 5 + 1 }).keys()].map((y) =>
today.year(2012 + y).format("YYYY"),
today.locale(locale).year(2012 + y).format("YYYY"),
);

/**
Expand Down
8 changes: 6 additions & 2 deletions src/components/Utilities/Currency.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import getUserLocale from "get-user-locale";
import PropTypes from "prop-types";
import React from "react";
import React, { useContext } from "react";
import { getSymbol, isZeroDecimal } from "../../helpers/currency";
import { almostZero, numberFormat, roundNumber } from "../../helpers/numbers";
import { Context } from "../Provider";

const userLocale = getUserLocale();

Expand All @@ -15,7 +16,10 @@ export const Currency = ({
isNarrowSymbolForm,
children,
}) => {
const {locale} = useContext(Context);

let amount = children;

if (almostZero(amount)) {
amount = 0;
}
Expand All @@ -25,7 +29,7 @@ export const Currency = ({
if (compact) {
return (
<span className="ui-currency">
{getSymbol(currency, locale, isNarrowSymbolForm)}
{getSymbol(currency, locale , isNarrowSymbolForm)}
{formattedAmount}
</span>
);
Expand Down

0 comments on commit 1291542

Please sign in to comment.