'use client' import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen' import { Button } from '@langgenius/dify-ui/button' import { cn } from '@langgenius/dify-ui/cn' import { useRef } from 'react' import { useTranslation } from 'react-i18next' import Loading from '@/app/components/base/loading' import AppInputsForm from '@/app/components/plugins/plugin-detail-panel/app-selector/app-inputs-form' import { useAppInputsFormSchema } from '@/app/components/plugins/plugin-detail-panel/app-selector/hooks/use-app-inputs-form-schema' type Props = Readonly<{ value?: { app_id: string inputs: Record } appDetail: Pick onFormChange: (value: Record) => void }> const AppInputsPanel = ({ value, appDetail, onFormChange }: Props) => { const { t } = useTranslation() const inputsRef = useRef>(value?.inputs || {}) const { inputFormSchema, isError, isLoading, retry } = useAppInputsFormSchema({ appDetail }) const handleFormChange = (newValue: Record) => { inputsRef.current = newValue onFormChange(newValue) } const hasInputs = inputFormSchema.length > 0 return (
{isLoading && (
)} {!isLoading && isError && (
{t(($) => $['errorBoundary.title'], { ns: 'common' })}
)} {!isLoading && !isError && (
{t(($) => $['appSelector.params'], { ns: 'app' })}
)} {!isLoading && !isError && !hasInputs && (
{t(($) => $['appSelector.noParams'], { ns: 'app' })}
)} {!isLoading && !isError && hasInputs && (
)}
) } export default AppInputsPanel