From 5d3e20d0c831e513f6450d4f440cd154f6b747ea Mon Sep 17 00:00:00 2001 From: crazywoola <427733928@qq.com> Date: Thu, 28 Sep 2023 09:53:59 +0800 Subject: [PATCH 1/2] fix: update api --- web/app/(commonLayout)/datasets/Container.tsx | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/web/app/(commonLayout)/datasets/Container.tsx b/web/app/(commonLayout)/datasets/Container.tsx index 871ef04951be1a..9f143433e4744a 100644 --- a/web/app/(commonLayout)/datasets/Container.tsx +++ b/web/app/(commonLayout)/datasets/Container.tsx @@ -1,59 +1,55 @@ 'use client' +// Libraries import { useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import useSWR from 'swr' + +// Components import Datasets from './Datasets' import DatasetFooter from './DatasetFooter' import ApiServer from './ApiServer' import Doc from './Doc' import TabSlider from '@/app/components/base/tab-slider' + +// Services import { fetchDatasetApiBaseUrl } from '@/service/datasets' const Container = () => { const { t } = useTranslation() + const options = [ - { - value: 'dataset', - text: t('dataset.datasets'), - }, - { - value: 'api', - text: t('dataset.datasetsApi'), - }, + { value: 'dataset', text: t('dataset.datasets') }, + { value: 'api', text: t('dataset.datasetsApi') }, ] + const [activeTab, setActiveTab] = useState('dataset') const containerRef = useRef(null) const { data } = useSWR(activeTab === 'dataset' ? null : '/datasets/api-base-info', fetchDatasetApiBaseUrl) return ( -
+
setActiveTab(newActiveTab)} options={options} /> - { - activeTab === 'api' && ( - - ) - } + {activeTab === 'api' && data && }
- { - activeTab === 'dataset' && ( -
- + + {activeTab === 'dataset' + ? ( + <> + -
- ) - } - { - activeTab === 'api' && ( - + ) - } + : ( + activeTab === 'api' && data && + )}
+ ) } From 4d8c79a8b62103f6c2a6eb6cf4e7677d72b545ac Mon Sep 17 00:00:00 2001 From: crazywoola <427733928@qq.com> Date: Thu, 28 Sep 2023 10:00:16 +0800 Subject: [PATCH 2/2] fix: styles --- web/app/(commonLayout)/datasets/Container.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/(commonLayout)/datasets/Container.tsx b/web/app/(commonLayout)/datasets/Container.tsx index 9f143433e4744a..c9158a84872dd6 100644 --- a/web/app/(commonLayout)/datasets/Container.tsx +++ b/web/app/(commonLayout)/datasets/Container.tsx @@ -28,7 +28,7 @@ const Container = () => { const { data } = useSWR(activeTab === 'dataset' ? null : '/datasets/api-base-info', fetchDatasetApiBaseUrl) return ( -
+