mirror of
https://github.com/supabase/supabase.git
synced 2026-06-16 02:26:42 +08:00
* **Chores** * Updated internal module import paths across hook files to use standardized path aliases for improved code consistency and maintainability.
23 lines
749 B
TypeScript
23 lines
749 B
TypeScript
import { useIsLoggedIn, useParams } from 'common'
|
|
|
|
import { useOrganizationsQuery } from '@/data/organizations/organizations-query'
|
|
import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
|
|
|
|
export function useSelectedOrganizationQuery({ enabled = true } = {}) {
|
|
const isLoggedIn = useIsLoggedIn()
|
|
|
|
const { ref, slug } = useParams()
|
|
const { data: selectedProject } = useProjectDetailQuery({ ref })
|
|
|
|
return useOrganizationsQuery({
|
|
enabled: isLoggedIn && enabled,
|
|
select: (data) => {
|
|
return data.find((org) => {
|
|
if (slug !== undefined) return org.slug === slug
|
|
if (selectedProject !== undefined) return org.id === selectedProject.organization_id
|
|
return undefined
|
|
})
|
|
},
|
|
})
|
|
}
|