index.tsx 1.2 KB

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