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 = (
|
export const orderArrayBy = (
|
||||||
array: any[],
|
orgArray: any[],
|
||||||
key: string,
|
key: string,
|
||||||
ordering: "ascending" | "descending" = "ascending"
|
ordering: "ascending" | "descending" = "ascending"
|
||||||
) => {
|
) => {
|
||||||
|
const array = [...orgArray];
|
||||||
|
|
||||||
if (!array || !Array.isArray(array) || array.length === 0) return [];
|
if (!array || !Array.isArray(array) || array.length === 0) return [];
|
||||||
|
|
||||||
if (key[0] === "-") {
|
if (key[0] === "-") {
|
||||||
|
@ -19,9 +19,9 @@ const useProjects = () => {
|
|||||||
workspaceSlug ? () => projectService.getProjects(workspaceSlug as string) : null
|
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}`))
|
?.sort((a, b) => Date.parse(`${a.updated_at}`) - Date.parse(`${b.updated_at}`))
|
||||||
.filter((_item, index) => index < 3);
|
?.slice(0, 3);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
projects: orderArrayBy(projects ?? [], "is_favorite", "descending") || [],
|
projects: orderArrayBy(projects ?? [], "is_favorite", "descending") || [],
|
||||||
|
Loading…
Reference in New Issue
Block a user