'use client' import { useTranslation } from 'react-i18next' import { Fragment } from 'react' import { useSWRConfig } from 'swr' import { EllipsisHorizontalIcon } from '@heroicons/react/24/solid' import { Menu, Transition } from '@headlessui/react' import { syncDataSourceNotion, updateDataSourceNotionAction } from '@/service/common' import Toast from '@/app/components/base/toast' import type { DataSourceNotion } from '@/models/common' import { FilePlus02 } from '@/app/components/base/icons/src/vender/line/files' import { RefreshCw05 } from '@/app/components/base/icons/src/vender/line/arrows' import { Trash03 } from '@/app/components/base/icons/src/vender/line/general' type OperateProps = { workspace: DataSourceNotion onAuthAgain: () => void } export default function Operate({ workspace, onAuthAgain, }: OperateProps) { const itemClassName = ` flex px-3 py-2 hover:bg-gray-50 text-sm text-gray-700 cursor-pointer ` const itemIconClassName = ` mr-2 mt-[2px] w-4 h-4 text-gray-500 ` const { t } = useTranslation() const { mutate } = useSWRConfig() const updateIntegrates = () => { Toast.notify({ type: 'success', message: t('common.api.success'), }) mutate({ url: 'data-source/integrates' }) } const handleSync = async () => { await syncDataSourceNotion({ url: `/oauth/data-source/notion/${workspace.id}/sync` }) updateIntegrates() } const handleRemove = async () => { await updateDataSourceNotionAction({ url: `/data-source/integrates/${workspace.id}/disable` }) updateIntegrates() } return ( { ({ open }) => ( <>
{t('common.dataSource.notion.changeAuthorizedPages')}
{workspace.source_info.total} {t('common.dataSource.notion.pagesAuthorized')}
{t('common.dataSource.notion.sync')}
{t('common.dataSource.notion.remove')}
) }
) }