mirror of
https://github.com/langgenius/dify.git
synced 2026-06-23 20:41:17 +08:00
Co-authored-by: Jingyi-Dify <jingyi.qi@dify.ai> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: Bond Zhu <783504079@qq.com> Co-authored-by: Yansong Zhang <916125788@qq.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
'use client'
|
|
|
|
import type { MovedAccountSettingTab } from './destinations'
|
|
import type { IntegrationSection } from '@/app/components/integrations/routes'
|
|
import { useCallback } from 'react'
|
|
import { useModalContext } from '@/context/modal-context'
|
|
import { integrationSectionByMovedAccountSettingTab } from './destinations'
|
|
|
|
type IntegrationsSettingState
|
|
= | { payload: MovedAccountSettingTab, source?: 'agent', onCancelCallback?: () => void }
|
|
| { section: IntegrationSection, source?: 'agent', onCancelCallback?: () => void }
|
|
|
|
export const useIntegrationsSetting = () => {
|
|
const { setShowAccountSettingModal } = useModalContext()
|
|
|
|
return useCallback((state: IntegrationsSettingState) => {
|
|
const section
|
|
= 'section' in state
|
|
? state.section
|
|
: integrationSectionByMovedAccountSettingTab[state.payload]
|
|
|
|
if (section) {
|
|
setShowAccountSettingModal({
|
|
payload: section,
|
|
...(state.source ? { source: state.source } : {}),
|
|
...(state.onCancelCallback ? { onCancelCallback: state.onCancelCallback } : {}),
|
|
})
|
|
}
|
|
}, [setShowAccountSettingModal])
|
|
}
|