feat(app-switcher): читать конфиг из auth-portal вместо локального editor
Docker / build (push) Failing after 18s
Docker / build (push) Failing after 18s
CURRENT_APP_ID vps; настройка ссылок только на портале. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -1,19 +1,35 @@
|
||||
import { useMemo } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import type { AppSwitcherConfig } from '@cfdm/shared/contracts/app-switcher'
|
||||
import { appSwitcherQueryOptions } from '@/queries/app-switcher'
|
||||
import { getAppUrl as getAppUrlFromConfig } from '@/lib/app-switcher-config'
|
||||
|
||||
import { DEFAULT_APP_SWITCHER_CONFIG } from '@/lib/app-switcher-config'
|
||||
import {
|
||||
DEFAULT_APP_SWITCHER_CONFIG,
|
||||
getAppUrl as getAppUrlFromConfig,
|
||||
} from '@/lib/app-switcher-config'
|
||||
import { getClaims } from '@/lib/auth'
|
||||
|
||||
export function useAppSwitcherConfig(): {
|
||||
config: AppSwitcherConfig
|
||||
isLoading: boolean
|
||||
} {
|
||||
const { data, isLoading } = useQuery(appSwitcherQueryOptions())
|
||||
return {
|
||||
config: data ?? DEFAULT_APP_SWITCHER_CONFIG,
|
||||
isLoading,
|
||||
}
|
||||
const claims = getClaims()
|
||||
|
||||
const config = useMemo(() => {
|
||||
const raw = data ?? DEFAULT_APP_SWITCHER_CONFIG
|
||||
const apps = raw.apps.filter((a) => (a as { enabled?: boolean }).enabled !== false)
|
||||
const allowed = claims?.apps
|
||||
if (!allowed?.length) {
|
||||
return { ...raw, apps }
|
||||
}
|
||||
const set = new Set(allowed)
|
||||
return {
|
||||
...raw,
|
||||
apps: apps.filter((a) => set.has(a.id)),
|
||||
}
|
||||
}, [data, claims?.apps])
|
||||
|
||||
return { config, isLoading }
|
||||
}
|
||||
|
||||
export function useAppUrl(appId: string): string | undefined {
|
||||
|
||||
Reference in New Issue
Block a user