From 1291542235505984fd0cf5f8c8d1b66a4d94fd55 Mon Sep 17 00:00:00 2001 From: Manoj Vaibhav Date: Wed, 31 Jul 2024 15:54:49 +0530 Subject: [PATCH] XS-30 fixed locale in month year selector --- src/components/DatePicker/MonthYearSelector.jsx | 8 ++++---- src/components/Utilities/Currency.jsx | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/DatePicker/MonthYearSelector.jsx b/src/components/DatePicker/MonthYearSelector.jsx index c29c20883..dd3b6b888 100644 --- a/src/components/DatePicker/MonthYearSelector.jsx +++ b/src/components/DatePicker/MonthYearSelector.jsx @@ -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(); @@ -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"), ); /** diff --git a/src/components/Utilities/Currency.jsx b/src/components/Utilities/Currency.jsx index 1c42e1ded..bf28b2854 100644 --- a/src/components/Utilities/Currency.jsx +++ b/src/components/Utilities/Currency.jsx @@ -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(); @@ -15,7 +16,10 @@ export const Currency = ({ isNarrowSymbolForm, children, }) => { + const {locale} = useContext(Context); + let amount = children; + if (almostZero(amount)) { amount = 0; } @@ -25,7 +29,7 @@ export const Currency = ({ if (compact) { return ( - {getSymbol(currency, locale, isNarrowSymbolForm)} + {getSymbol(currency, locale , isNarrowSymbolForm)} {formattedAmount} );