'use client' import type { FC } from 'react' import type { Dependency } from '../../types' import * as React from 'react' import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import Modal from '@/app/components/base/modal' import { cn } from '@/utils/classnames' import { InstallStep } from '../../types' import useHideLogic from '../hooks/use-hide-logic' import ReadyToInstall from './ready-to-install' const i18nPrefix = '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`, { ns: 'plugin' }) if (step === InstallStep.installed) return t(`${i18nPrefix}.installComplete`, { ns: 'plugin' }) return t(`${i18nPrefix}.installPlugin`, { ns: 'plugin' }) }, [step, t]) return (
{getTitle()}
) } export default React.memo(InstallBundle)