NewAppCard.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use client'
  2. import { forwardRef, useState } from 'react'
  3. import classNames from 'classnames'
  4. import { useTranslation } from 'react-i18next'
  5. import style from '../list.module.css'
  6. import NewAppDialog from './NewAppDialog'
  7. import { useProviderContext } from '@/context/provider-context'
  8. export type CreateAppCardProps = {
  9. onSuccess?: () => void
  10. }
  11. const CreateAppCard = forwardRef<HTMLAnchorElement, CreateAppCardProps>(({ onSuccess }, ref) => {
  12. const { t } = useTranslation()
  13. const { onPlanInfoChanged } = useProviderContext()
  14. const [showNewAppDialog, setShowNewAppDialog] = useState(false)
  15. return (
  16. <a ref={ref} className={classNames(style.listItem, style.newItemCard)} onClick={() => setShowNewAppDialog(true)}>
  17. <div className={style.listItemTitle}>
  18. <span className={style.newItemIcon}>
  19. <span className={classNames(style.newItemIconImage, style.newItemIconAdd)} />
  20. </span>
  21. <div className={classNames(style.listItemHeading, style.newItemCardHeading)}>
  22. {t('app.createApp')}
  23. </div>
  24. </div>
  25. {/* <div className='text-xs text-gray-500'>{t('app.createFromConfigFile')}</div> */}
  26. <NewAppDialog show={showNewAppDialog} onSuccess={
  27. () => {
  28. onPlanInfoChanged()
  29. if (onSuccess)
  30. onSuccess()
  31. }} onClose={() => setShowNewAppDialog(false)} />
  32. </a>
  33. )
  34. })
  35. export default CreateAppCard