dify/web/app/components/integrations/hooks/use-integration-section.ts
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

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')
)
}