From 45e8153c157e0cf3dab4d6be3214035846cb7758 Mon Sep 17 00:00:00 2001 From: Alberto Espinoza Date: Mon, 23 Oct 2023 15:51:51 -0600 Subject: [PATCH] R2-2618 Date format in Insights should match format used in rest of app --- .../insights-sub-report/utils/translate-group-id.js | 2 +- .../utils/translate-group-id.unit.test.js | 6 +++--- .../components/insights-sub-report/utils/translate-week.js | 2 +- .../insights-sub-report/utils/translate-week.unit.test.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/javascript/components/insights-sub-report/utils/translate-group-id.js b/app/javascript/components/insights-sub-report/utils/translate-group-id.js index 262d9b29fd..9725a50f1d 100644 --- a/app/javascript/components/insights-sub-report/utils/translate-group-id.js +++ b/app/javascript/components/insights-sub-report/utils/translate-group-id.js @@ -10,7 +10,7 @@ export default (groupId, groupedBy, localizeDate) => { case MONTH: { const [year, groupKey] = groupId.split("-"); - return `${year}-${groupTranslator(groupKey, localizeDate)}`; + return `${groupTranslator(groupKey, localizeDate)}-${year}`; } case WEEK: { const [start, end] = groupId.split(" - "); diff --git a/app/javascript/components/insights-sub-report/utils/translate-group-id.unit.test.js b/app/javascript/components/insights-sub-report/utils/translate-group-id.unit.test.js index dc824d7796..ccb0d3c078 100644 --- a/app/javascript/components/insights-sub-report/utils/translate-group-id.unit.test.js +++ b/app/javascript/components/insights-sub-report/utils/translate-group-id.unit.test.js @@ -14,13 +14,13 @@ describe("translateGroupId", () => { it("translates group of months", () => { const result = translateGroupId("2023-03", MONTH, format); - expect(result).to.equals("2023-Mar"); + expect(result).to.equals("Mar-2023"); }); it("translates group of quarters", () => { const result = translateGroupId("2023-Q1", QUARTER, format); - expect(result).to.equals("2023-Q1"); + expect(result).to.equals("Q1-2023"); }); it("translates group of weeks", () => { @@ -28,6 +28,6 @@ describe("translateGroupId", () => { const result = translateGroupId("2023-01-01 - 2023-01-07", WEEK, localizeDate); - expect(result).to.equals("2023-Jan-01 - 2023-Jan-07"); + expect(result).to.equals("01-Jan-2023 - 07-Jan-2023"); }); }); diff --git a/app/javascript/components/insights-sub-report/utils/translate-week.js b/app/javascript/components/insights-sub-report/utils/translate-week.js index 0105a70641..6abcd07cc9 100644 --- a/app/javascript/components/insights-sub-report/utils/translate-week.js +++ b/app/javascript/components/insights-sub-report/utils/translate-week.js @@ -1,3 +1,3 @@ export default (startDate, endDate, localizeDate) => { - return `${localizeDate(startDate, "yyyy-MMM-dd")} - ${localizeDate(endDate, "yyyy-MMM-dd")}`; + return `${localizeDate(startDate, "dd-MMM-yyyy")} - ${localizeDate(endDate, "dd-MMM-yyyy")}`; }; diff --git a/app/javascript/components/insights-sub-report/utils/translate-week.unit.test.js b/app/javascript/components/insights-sub-report/utils/translate-week.unit.test.js index 4723c2628a..73e0e140c0 100644 --- a/app/javascript/components/insights-sub-report/utils/translate-week.unit.test.js +++ b/app/javascript/components/insights-sub-report/utils/translate-week.unit.test.js @@ -7,6 +7,6 @@ describe("translateWeek", () => { const localizeDate = (value, dateFormat) => format(parseISO(value), dateFormat); const result = translateWeek("2020-06-07", "2020-06-13", localizeDate); - expect(result).to.equal("2020-Jun-07 - 2020-Jun-13"); + expect(result).to.equal("07-Jun-2020 - 13-Jun-2020"); }); });