index.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use client'
  2. import React from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import { useFeatures } from '../hooks'
  5. import type { OnFeaturesChange } from '../types'
  6. import FeatureModal from './feature-modal'
  7. import Button from '@/app/components/base/button'
  8. import { Plus } from '@/app/components/base/icons/src/vender/line/general'
  9. type ChooseFeatureProps = {
  10. onChange?: OnFeaturesChange
  11. disabled?: boolean
  12. }
  13. const ChooseFeature = ({
  14. onChange,
  15. disabled,
  16. }: ChooseFeatureProps) => {
  17. const { t } = useTranslation()
  18. const showFeaturesModal = useFeatures(s => s.showFeaturesModal)
  19. const setShowFeaturesModal = useFeatures(s => s.setShowFeaturesModal)
  20. return (
  21. <>
  22. <Button
  23. className={`
  24. px-3 py-0 h-8 rounded-lg border border-primary-100 bg-primary-25 shadow-xs text-xs font-semibold text-primary-600
  25. ${disabled && 'cursor-not-allowed opacity-50'}
  26. `}
  27. onClick={() => !disabled && setShowFeaturesModal(true)}
  28. >
  29. <Plus className='mr-1 w-4 h-4' />
  30. {t('appDebug.operation.addFeature')}
  31. </Button>
  32. {
  33. showFeaturesModal && (
  34. <FeatureModal onChange={onChange} />
  35. )
  36. }
  37. </>
  38. )
  39. }
  40. export default React.memo(ChooseFeature)