Files
plane/packages/utils/src/workspace.ts
Prateek Shourya 6fa8c0f2f2 [WEB-3394] fix: pages app workspace switcher and plan name (#2501)
* fix: pages app workspace switcher and plan name

* improvement: subscription name and color updated along with API response
2025-02-14 19:29:07 +05:30

24 lines
804 B
TypeScript

// plane imports
import { EProductSubscriptionTier } from "@plane/constants";
import { IWorkspace } from "@plane/types";
export const orderWorkspacesList = (workspaces: IWorkspace[]): IWorkspace[] =>
workspaces.sort((a, b) => {
// Get subscription tiers with fallback to FREE
const aTier = EProductSubscriptionTier[a.current_plan ?? "FREE"];
const bTier = EProductSubscriptionTier[b.current_plan ?? "FREE"];
// First sort by tier (descending order - highest tier first)
if (aTier !== bTier) {
return bTier - aTier;
}
// If same tier, sort by trial status (non-trial first)
if (a.is_on_trial !== b.is_on_trial) {
return a.is_on_trial ? 1 : -1;
}
// If same tier and trial status, sort alphabetically
return a.name.localeCompare(b.name);
});