'use client' import type { App } from '@/types/app' 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' import { cn } from '@/utils/classnames' type Props = { value?: { app_id: string inputs: Record } appDetail: App onFormChange: (value: Record) => void } const AppInputsPanel = ({ value, appDetail, onFormChange, }: Props) => { const { t } = useTranslation() const inputsRef = useRef>(value?.inputs || {}) const { inputFormSchema, isLoading } = useAppInputsFormSchema({ appDetail }) const handleFormChange = (newValue: Record) => { inputsRef.current = newValue onFormChange(newValue) } const hasInputs = inputFormSchema.length > 0 return (
{isLoading &&
} {!isLoading && (
{t('appSelector.params', { ns: 'app' })}
)} {!isLoading && !hasInputs && (
{t('appSelector.noParams', { ns: 'app' })}
)} {!isLoading && hasInputs && (
)}
) } export default AppInputsPanel