Files
Joshen Lim 42b6571e7d Chore/housekeeping org pages (#53303)
## Context

Some minor UI issues that I found while reviewing another PR

- Fix `NoProjectsOnPaidOrgInfo` prematurely showing while project
details is still loading
<img width="1249" height="376" alt="image"
src="https://github.com/user-attachments/assets/3f41f4a3-849f-4685-bcc4-6fed3b433042"
/>
- Fix padding alignment for Organization details form group
<img width="1115" height="282" alt="image"
src="https://github.com/user-attachments/assets/c0865614-208c-4335-87d3-176c4411b6a4"
/>
- Fix projects list on `/org/[slug]` showing stale projects while
switching orgs - just removed `keepPreviousData` so that the card
loaders shows up
- Fix organization settings in sidebar menu not showing active state
while on certain settings pages like audit-log-drains, webhooks, etc
2026-11-13 10:16:48 +07:00

42 lines
1.1 KiB
TypeScript

import type { ReactNode } from 'react'
import { ORG_SETTINGS_ROUTES } from '@/components/layouts/OrganizationLayout/OrganizationLayout.utils'
export interface OrgNavItem {
label: string
href: string
key: string
icon: ReactNode
}
export function getOrgActiveRoute(pathname: string): string | undefined {
const segments = pathname.split('/').filter(Boolean)
const orgIndex = segments.indexOf('org')
if (orgIndex === -1 || segments.length <= orgIndex + 1) return undefined
return segments[orgIndex + 2]
}
export function getOrgSectionKeyFromPathname(activeRoute: string | undefined): string | null {
if (activeRoute && ORG_SETTINGS_ROUTES.includes(activeRoute)) {
return 'settings'
}
return null
}
export function isOrgMenuActive(
item: OrgNavItem,
index: number,
pathname: string,
activeRoute: string | undefined
): boolean {
if (index === 0) {
return activeRoute === undefined
}
if (item.key === 'settings') {
const route = activeRoute ?? getOrgActiveRoute(pathname)
if (route === undefined) return false
return route === 'settings' || ORG_SETTINGS_ROUTES.includes(route)
}
return activeRoute === item.key
}