'use client' import { forwardRef, useMemo, useState } from 'react' import { useRouter, useSearchParams, } from 'next/navigation' import { useTranslation } from 'react-i18next' import CreateAppTemplateDialog from '@/app/components/app/create-app-dialog' import CreateAppModal from '@/app/components/app/create-app-modal' import CreateFromDSLModal, { CreateFromDSLModalTab } from '@/app/components/app/create-from-dsl-modal' import { useProviderContext } from '@/context/provider-context' import { FileArrow01, FilePlus01, FilePlus02 } from '@/app/components/base/icons/src/vender/line/files' export type CreateAppCardProps = { onSuccess?: () => void } // eslint-disable-next-line react/display-name const CreateAppCard = forwardRef(({ onSuccess }, ref) => { const { t } = useTranslation() const { onPlanInfoChanged } = useProviderContext() const searchParams = useSearchParams() const { replace } = useRouter() const dslUrl = searchParams.get('remoteInstallUrl') || undefined const [showNewAppTemplateDialog, setShowNewAppTemplateDialog] = useState(false) const [showNewAppModal, setShowNewAppModal] = useState(false) const [showCreateFromDSLModal, setShowCreateFromDSLModal] = useState(!!dslUrl) const activeTab = useMemo(() => { if (dslUrl) return CreateFromDSLModalTab.FROM_URL return undefined }, [dslUrl]) return (
{t('app.createApp')}
setShowNewAppModal(true)}> {t('app.newApp.startFromBlank')}
setShowNewAppTemplateDialog(true)}> {t('app.newApp.startFromTemplate')}
setShowCreateFromDSLModal(true)} >
{t('app.importDSL')}
setShowNewAppModal(false)} onSuccess={() => { onPlanInfoChanged() if (onSuccess) onSuccess() }} /> setShowNewAppTemplateDialog(false)} onSuccess={() => { onPlanInfoChanged() if (onSuccess) onSuccess() }} /> { setShowCreateFromDSLModal(false) if (dslUrl) replace('/') }} activeTab={activeTab} dslUrl={dslUrl} onSuccess={() => { onPlanInfoChanged() if (onSuccess) onSuccess() }} />
) }) export default CreateAppCard