'use client' import type { FC } from 'react' import Modal from '@/app/components/base/modal' import React, { useCallback, useState } from 'react' import { InstallStep } from '../../types' import type { Dependency } from '../../types' import ReadyToInstall from './ready-to-install' import { useTranslation } from 'react-i18next' import useHideLogic from '../hooks/use-hide-logic' import cn from '@/utils/classnames' const i18nPrefix = 'plugin.installModal' export enum InstallType { fromLocal = 'fromLocal', fromMarketplace = 'fromMarketplace', fromDSL = 'fromDSL', } type Props = { installType?: InstallType fromDSLPayload: Dependency[] // plugins?: PluginDeclaration[] onClose: () => void } const InstallBundle: FC = ({ installType = InstallType.fromMarketplace, fromDSLPayload, onClose, }) => { const { t } = useTranslation() const [step, setStep] = useState(installType === InstallType.fromMarketplace ? InstallStep.readyToInstall : InstallStep.uploading) const { modalClassName, foldAnimInto, setIsInstalling, handleStartToInstall, } = useHideLogic(onClose) const getTitle = useCallback(() => { if (step === InstallStep.uploadFailed) return t(`${i18nPrefix}.uploadFailed`) if (step === InstallStep.installed) return t(`${i18nPrefix}.installComplete`) return t(`${i18nPrefix}.installPlugin`) }, [step, t]) return (
{getTitle()}
) } export default React.memo(InstallBundle)