'use client' import type { FC, SVGProps } from 'react' import React, { useState } from 'react' import useSWR from 'swr' import { usePathname } from 'next/navigation' import { Pagination } from 'react-headless-pagination' import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/24/outline' import { Trans, useTranslation } from 'react-i18next' import Link from 'next/link' import List from './list' import Filter from './filter' import s from './style.module.css' import Loading from '@/app/components/base/loading' import { fetchWorkflowLogs } from '@/service/log' import { APP_PAGE_LIMIT } from '@/config' import type { App, AppMode } from '@/types/app' export type ILogsProps = { appDetail: App } export type QueryParam = { status?: string keyword?: string } const ThreeDotsIcon = ({ className }: SVGProps) => { return } const EmptyElement: FC<{ appUrl: string }> = ({ appUrl }) => { const { t } = useTranslation() const pathname = usePathname() const pathSegments = pathname.split('/') pathSegments.pop() return
{t('appLog.table.empty.element.title')}
, testLink: }} />
} const Logs: FC = ({ appDetail }) => { const { t } = useTranslation() const [queryParams, setQueryParams] = useState({ status: 'all' }) const [currPage, setCurrPage] = React.useState(0) const query = { page: currPage + 1, limit: APP_PAGE_LIMIT, ...(queryParams.status !== 'all' ? { status: queryParams.status } : {}), ...(queryParams.keyword ? { keyword: queryParams.keyword } : {}), } const getWebAppType = (appType: AppMode) => { if (appType !== 'completion' && appType !== 'workflow') return 'chat' return appType } const { data: workflowLogs, mutate } = useSWR({ url: `/apps/${appDetail.id}/workflow-app-logs`, params: query, }, fetchWorkflowLogs) const total = workflowLogs?.total return (

{t('appLog.workflowTitle')}

{t('appLog.workflowSubtitle')}

{/* workflow log */} {total === undefined ? : total > 0 ? : } {/* Show Pagination only if the total is more than the limit */} {(total && total > APP_PAGE_LIMIT) ? {t('appLog.table.pagination.previous')}
{t('appLog.table.pagination.next')}
: null}
) } export default Logs