From b5c8b0bb680bceecaa4f63e7a5243df7077d7150 Mon Sep 17 00:00:00 2001 From: Marcus Blais <31868036+blai0264@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:09:28 -0400 Subject: [PATCH] sorted project updates by date on old design (#1059) * sorted project updates by date on old design * updated updatesData variable on project pages --- lib/utils/sortUpdatesByDate.js | 5 +++++ pages/projects/benefits-navigator/index.js | 3 ++- pages/projects/dashboard/index.js | 3 ++- pages/projects/digital-standards-playbook/index.js | 3 ++- pages/projects/making-easier-get-benefits/index.js | 3 ++- pages/projects/oas-benefits-estimator/index.js | 3 ++- 6 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 lib/utils/sortUpdatesByDate.js diff --git a/lib/utils/sortUpdatesByDate.js b/lib/utils/sortUpdatesByDate.js new file mode 100644 index 0000000000..86e6387b6d --- /dev/null +++ b/lib/utils/sortUpdatesByDate.js @@ -0,0 +1,5 @@ +export const sortUpdatesByDate = (array) => { + return [...array].sort((a, b) => { + return b.scDateModifiedOverwrite.localeCompare(a.scDateModifiedOverwrite); + }); +}; diff --git a/pages/projects/benefits-navigator/index.js b/pages/projects/benefits-navigator/index.js index d3ee86c023..21a23a1b0a 100644 --- a/pages/projects/benefits-navigator/index.js +++ b/pages/projects/benefits-navigator/index.js @@ -11,10 +11,11 @@ import { Collapse } from "../../../components/molecules/Collapse"; import Image from "next/image"; import stageDictionary from "../../../lib/utils/stageDictionary"; import TextRender from "../../../components/text_node_renderer/TextRender"; +import { sortUpdatesByDate } from "../../../lib/utils/sortUpdatesByDate"; export default function BenefitsNavigatorOverview(props) { const [pageData] = useState(props.pageData.item); - const [updatesData] = useState(props.updatesData); + const updatesData = sortUpdatesByDate(props.updatesData); const [filteredDictionary] = useState( props.dictionary.items.filter( (item) => diff --git a/pages/projects/dashboard/index.js b/pages/projects/dashboard/index.js index b257439138..dd67565e09 100644 --- a/pages/projects/dashboard/index.js +++ b/pages/projects/dashboard/index.js @@ -13,10 +13,11 @@ import stageDictionary from "../../../lib/utils/stageDictionary"; import TextRender from "../../../components/text_node_renderer/TextRender"; import Card from "../../../components/molecules/Card"; import FragmentRender from "../../../components/fragment_renderer/FragmentRender"; +import { sortUpdatesByDate } from "../../../lib/utils/sortUpdatesByDate"; export default function MscaDashboard(props) { const pageData = props.pageData?.item; - const updatesData = props.updatesData; + const updatesData = sortUpdatesByDate(props.updatesData); const filteredDictionary = props.dictionary?.items?.filter( (item) => diff --git a/pages/projects/digital-standards-playbook/index.js b/pages/projects/digital-standards-playbook/index.js index d342b46b31..c264b24c58 100644 --- a/pages/projects/digital-standards-playbook/index.js +++ b/pages/projects/digital-standards-playbook/index.js @@ -10,10 +10,11 @@ import { Heading } from "../../../components/molecules/Heading"; import { ActionButton } from "../../../components/atoms/ActionButton"; import Image from "next/image"; import stageDictionary from "../../../lib/utils/stageDictionary"; +import { sortUpdatesByDate } from "../../../lib/utils/sortUpdatesByDate"; export default function DigitalStandardsPlaybookPage(props) { const [pageData] = useState(props.pageData.item); - const [updatesData] = useState(props.updatesData); + const updatesData = sortUpdatesByDate(props.updatesData); const filteredDictionary = props.dictionary?.items?.filter( (item) => diff --git a/pages/projects/making-easier-get-benefits/index.js b/pages/projects/making-easier-get-benefits/index.js index d8dcf2c352..190ce588bc 100644 --- a/pages/projects/making-easier-get-benefits/index.js +++ b/pages/projects/making-easier-get-benefits/index.js @@ -11,10 +11,11 @@ import { Heading } from "../../../components/molecules/Heading"; import TextRender from "../../../components/text_node_renderer/TextRender"; import Image from "next/image"; import stageDictionary from "../../../lib/utils/stageDictionary"; +import { sortUpdatesByDate } from "../../../lib/utils/sortUpdatesByDate"; export default function IntegratedChannelStrategyPage(props) { const [pageData] = useState(props.pageData.item); - const [updatesData] = useState(props.updatesData); + const updatesData = sortUpdatesByDate(props.updatesData); const [filteredDictionary] = useState( props.dictionary.items.filter( (item) => diff --git a/pages/projects/oas-benefits-estimator/index.js b/pages/projects/oas-benefits-estimator/index.js index 485c501315..0a151068e6 100644 --- a/pages/projects/oas-benefits-estimator/index.js +++ b/pages/projects/oas-benefits-estimator/index.js @@ -10,10 +10,11 @@ import { createBreadcrumbs } from "../../../lib/utils/createBreadcrumbs"; import { Heading } from "../../../components/molecules/Heading"; import Image from "next/image"; import stageDictionary from "../../../lib/utils/stageDictionary"; +import { sortUpdatesByDate } from "../../../lib/utils/sortUpdatesByDate"; export default function OasBenefitsEstimator(props) { const [pageData] = useState(props.pageData.item); - const [updatesData] = useState(props.updatesData); + const updatesData = sortUpdatesByDate(props.updatesData); const [filteredDictionary] = useState( props.dictionary.items.filter( (item) =>