From a38585b95637cf3f9aca46dbe3c501e1ba43e562 Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Wed, 22 Jan 2025 17:21:05 -0400 Subject: [PATCH] [TM-1625] sort project list in dashboard --- .../dashboard/project-list/index.page.tsx | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/pages/dashboard/project-list/index.page.tsx b/src/pages/dashboard/project-list/index.page.tsx index b397cad91..4f85cf414 100644 --- a/src/pages/dashboard/project-list/index.page.tsx +++ b/src/pages/dashboard/project-list/index.page.tsx @@ -98,32 +98,34 @@ const ProjectList = () => { const { activeProjects } = useDashboardData(filters); const DATA_TABLE_PROJECT_LIST = activeProjects - ? activeProjects?.map( - (item: { - uuid: string; - name: string; - organisation: string; - programme: string; - country_slug: string; - project_country: string; - trees_under_restoration: number; - hectares_under_restoration: number; - jobs_created: number; - }) => ({ - uuid: item.uuid, - project: item?.name, - organization: item?.organisation, - programme: getFrameworkName(frameworks, item?.programme), - country: { - country_slug: item?.country_slug, - label: item?.project_country, - image: `/flags/${item?.country_slug?.toLowerCase()}.svg` - }, - treesPlanted: item.trees_under_restoration.toLocaleString(), - restorationHectares: item.hectares_under_restoration.toLocaleString(), - jobsCreated: item.jobs_created.toLocaleString() - }) - ) + ? activeProjects + .map( + (item: { + uuid: string; + name: string; + organisation: string; + programme: string; + country_slug: string; + project_country: string; + trees_under_restoration: number; + hectares_under_restoration: number; + jobs_created: number; + }) => ({ + uuid: item.uuid, + project: item?.name, + organization: item?.organisation, + programme: getFrameworkName(frameworks, item?.programme), + country: { + country_slug: item?.country_slug, + label: item?.project_country, + image: `/flags/${item?.country_slug?.toLowerCase()}.svg` + }, + treesPlanted: item.trees_under_restoration.toLocaleString(), + restorationHectares: item.hectares_under_restoration.toLocaleString(), + jobsCreated: item.jobs_created.toLocaleString() + }) + ) + .sort((a: { organization: string }, b: { organization: any }) => a.organization.localeCompare(b.organization)) : []; return (