forked from github/plane
fix: project ordering messing up in projects page (#1122)
This commit is contained in:
parent
74329a49cc
commit
7e5b26ea82
@ -8,10 +8,12 @@ export const groupBy = (array: any[], key: string) => {
|
||||
};
|
||||
|
||||
export const orderArrayBy = (
|
||||
array: any[],
|
||||
orgArray: any[],
|
||||
key: string,
|
||||
ordering: "ascending" | "descending" = "ascending"
|
||||
) => {
|
||||
const array = [...orgArray];
|
||||
|
||||
if (!array || !Array.isArray(array) || array.length === 0) return [];
|
||||
|
||||
if (key[0] === "-") {
|
||||
|
@ -19,9 +19,9 @@ const useProjects = () => {
|
||||
workspaceSlug ? () => projectService.getProjects(workspaceSlug as string) : null
|
||||
);
|
||||
|
||||
const recentProjects = projects
|
||||
const recentProjects = [...(projects ?? [])]
|
||||
?.sort((a, b) => Date.parse(`${a.updated_at}`) - Date.parse(`${b.updated_at}`))
|
||||
.filter((_item, index) => index < 3);
|
||||
?.slice(0, 3);
|
||||
|
||||
return {
|
||||
projects: orderArrayBy(projects ?? [], "is_favorite", "descending") || [],
|
||||
|
Loading…
Reference in New Issue
Block a user