1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 'use client'
- import List from './list'
- import React, { useEffect, useState } from 'react'
- import useSWR from 'swr'
- import { fetchLog } from '@/service/common'
- const LogIndex = () => {
- const [page, setPage] = React.useState<number>(0)
- const [limit, setLimit] = useState<number>(10)
- const { data, mutate }: any = useSWR(
- {
- url: '/intentions/train_tasks',
- params: {
- page: page + 1,
- limit,
- },
- },
- fetchLog,
- )
- const list: any = data?.data || []
- const total = data?.total || 0
- useEffect(() => {
- mutate()
- }, [page, limit])
- return (
- <>
- <div className='flex h-full w-full flex-col bg-background-default-subtle p-6'>
- <div className="flex-1">
- <List
- list={list || []}
- onUpdate={mutate}
- pagination={{
- total,
- limit,
- onLimitChange: setLimit,
- current: page,
- onChange: setPage,
- }}
- />
- </div>
- </div>
- </>
- )
- }
- export default LogIndex
|