Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dataset footer styles #1254

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 20 additions & 24 deletions web/app/(commonLayout)/datasets/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
'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<HTMLDivElement>(null)
const { data } = useSWR(activeTab === 'dataset' ? null : '/datasets/api-base-info', fetchDatasetApiBaseUrl)
Expand All @@ -34,26 +35,21 @@ const Container = () => {
onChange={newActiveTab => setActiveTab(newActiveTab)}
options={options}
/>
{
activeTab === 'api' && (
<ApiServer apiBaseUrl={data?.api_base_url || ''} />
)
}
{activeTab === 'api' && data && <ApiServer apiBaseUrl={data.api_base_url || ''} />}
</div>
{
activeTab === 'dataset' && (
<div className=''>
<Datasets containerRef={containerRef}/>

{activeTab === 'dataset'
? (
<>
<Datasets containerRef={containerRef} />
<DatasetFooter />
</div>
)
}
{
activeTab === 'api' && (
<Doc apiBaseUrl={data?.api_base_url || ''} />
</>
)
}
: (
activeTab === 'api' && data && <Doc apiBaseUrl={data.api_base_url || ''} />
)}
</div>

)
}

Expand Down
Loading