|  |  |  |  |  |  | 
													
												
													
														|  |  | import { fetchNotionConnection } from '@/service/common' |  |  | import { fetchNotionConnection } from '@/service/common' | 
													
												
													
														|  |  | import NotionIcon from '@/app/components/base/notion-icon' |  |  | import NotionIcon from '@/app/components/base/notion-icon' | 
													
												
													
														|  |  | import { noop } from 'lodash-es' |  |  | import { noop } from 'lodash-es' | 
													
												
													
														|  |  |  |  |  | import { useTranslation } from 'react-i18next' | 
													
												
													
														|  |  |  |  |  | import Toast from '@/app/components/base/toast' | 
													
												
													
														|  |  | 
 |  |  | 
 | 
													
												
													
														|  |  | const Icon: FC<{ |  |  | const Icon: FC<{ | 
													
												
													
														|  |  | src: string |  |  | src: string | 
													
												
											
												
													
														|  |  |  |  |  |  | 
													
												
													
														|  |  | const { isCurrentWorkspaceManager } = useAppContext() |  |  | const { isCurrentWorkspaceManager } = useAppContext() | 
													
												
													
														|  |  | const [canConnectNotion, setCanConnectNotion] = useState(false) |  |  | const [canConnectNotion, setCanConnectNotion] = useState(false) | 
													
												
													
														|  |  | const { data } = useSWR(canConnectNotion ? '/oauth/data-source/notion' : null, fetchNotionConnection) |  |  | const { data } = useSWR(canConnectNotion ? '/oauth/data-source/notion' : null, fetchNotionConnection) | 
													
												
													
														|  |  |  |  |  | const { t } = useTranslation() | 
													
												
													
														|  |  | 
 |  |  | 
 | 
													
												
													
														|  |  | const connected = !!workspaces.length |  |  | const connected = !!workspaces.length | 
													
												
													
														|  |  | 
 |  |  | 
 | 
													
												
											
												
													
														|  |  |  |  |  |  | 
													
												
													
														|  |  | } |  |  | } | 
													
												
													
														|  |  | 
 |  |  | 
 | 
													
												
													
														|  |  | useEffect(() => { |  |  | useEffect(() => { | 
													
												
													
														|  |  | if (data?.data) |  |  |  | 
													
												
													
														|  |  | window.location.href = data.data |  |  |  | 
													
												
													
														|  |  | }, [data]) |  |  |  | 
													
												
													
														|  |  |  |  |  | if (data && 'data' in data) { | 
													
												
													
														|  |  |  |  |  | if (data.data && typeof data.data === 'string' && data.data.startsWith('http')) { | 
													
												
													
														|  |  |  |  |  | window.location.href = data.data | 
													
												
													
														|  |  |  |  |  | } | 
													
												
													
														|  |  |  |  |  | else if (data.data === 'internal') { | 
													
												
													
														|  |  |  |  |  | Toast.notify({ | 
													
												
													
														|  |  |  |  |  | type: 'info', | 
													
												
													
														|  |  |  |  |  | message: t('common.dataSource.notion.integratedAlert'), | 
													
												
													
														|  |  |  |  |  | }) | 
													
												
													
														|  |  |  |  |  | } | 
													
												
													
														|  |  |  |  |  | } | 
													
												
													
														|  |  |  |  |  | }, [data, t]) | 
													
												
													
														|  |  |  |  |  | 
 | 
													
												
													
														|  |  | return ( |  |  | return ( | 
													
												
													
														|  |  | <Panel |  |  | <Panel | 
													
												
													
														|  |  | type={DataSourceType.notion} |  |  | type={DataSourceType.notion} |