/* eslint-disable style/multiline-ternary */ 'use client' import type { App as AppType } from '@/models/explore' import { Button } from '@langgenius/dify-ui/button' import { Dialog, DialogContent } from '@langgenius/dify-ui/dialog' import { Tabs, TabsList, TabsPanel, TabsTab } from '@langgenius/dify-ui/tabs' import * as React from 'react' import { useState } from 'react' import { useTranslation } from 'react-i18next' import AppUnavailable from '@/app/components/base/app-unavailable' import Loading from '@/app/components/base/loading' import { useGetTryAppInfo } from '@/service/use-try-app' import App from './app' import AppInfo from './app-info' import Preview from './preview' import { TypeEnum } from './types' type Props = Readonly<{ appId: string app: AppType canCreate?: boolean categories?: string[] createButtonStepByStepTourTarget?: string onClose: () => void onCreate: () => void }> function TryApp({ appId, app, canCreate = true, categories, createButtonStepByStepTourTarget, onClose, onCreate, }: Props) { const { t } = useTranslation() const canUseTryTab = app.can_trial const [type, setType] = useState(() => (canUseTryTab ? TypeEnum.TRY : TypeEnum.DETAIL)) const activeType = canUseTryTab ? type : TypeEnum.DETAIL const { data: appDetail, isLoading, isError, error } = useGetTryAppInfo(appId) return ( { if (!open) onClose() }} > {isLoading ? (
) : isError ? (
) : !appDetail ? (
) : ( setType(selectedValue)} className="flex h-full flex-col" >
{t(($) => $['tryApp.tabHeader.try'], { ns: 'explore' })} {t(($) => $['tryApp.tabHeader.detail'], { ns: 'explore' })}
{/* Main content */}
)}
) } export default React.memo(TryApp)