mirror of
https://github.com/langgenius/dify.git
synced 2026-07-23 03:58:31 +08:00
22 lines
783 B
TypeScript
22 lines
783 B
TypeScript
import type { IntegrationSection } from '@/app/components/integrations/routes'
|
|
import { parseAsStringLiteral, useQueryState } from 'nuqs'
|
|
import {
|
|
INTEGRATION_SECTION_VALUES,
|
|
sectionByToolCategory,
|
|
TOOL_CATEGORY_VALUES,
|
|
} from '@/app/components/integrations/routes'
|
|
|
|
const parseAsIntegrationSection = parseAsStringLiteral(INTEGRATION_SECTION_VALUES)
|
|
const parseAsToolCategory = parseAsStringLiteral(TOOL_CATEGORY_VALUES)
|
|
|
|
export function useIntegrationSection(routeSection?: IntegrationSection) {
|
|
const [sectionParam] = useQueryState('section', parseAsIntegrationSection)
|
|
const [categoryParam] = useQueryState('category', parseAsToolCategory)
|
|
|
|
return (
|
|
routeSection ??
|
|
sectionParam ??
|
|
(categoryParam ? sectionByToolCategory[categoryParam] : 'provider')
|
|
)
|
|
}
|