labs-enable-button.tsx 885 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { useTranslation } from 'react-i18next'
  2. import OLButton from '@/shared/components/ol/ol-button'
  3. type LabsEnableButtonProps = {
  4. optedIn: boolean
  5. disabled: boolean
  6. loading?: boolean
  7. ghost?: boolean
  8. handleEnable: () => void
  9. handleDisable: () => void
  10. }
  11. export function LabsEnableButton({
  12. optedIn,
  13. disabled,
  14. loading,
  15. ghost,
  16. handleEnable,
  17. handleDisable,
  18. }: LabsEnableButtonProps) {
  19. const { t } = useTranslation()
  20. const isDisabled = loading || disabled
  21. if (optedIn) {
  22. return (
  23. <OLButton
  24. variant={ghost ? 'danger-ghost' : 'secondary'}
  25. onClick={handleDisable}
  26. disabled={isDisabled}
  27. >
  28. {t('disable')}
  29. </OLButton>
  30. )
  31. }
  32. return (
  33. <OLButton
  34. variant={ghost ? 'secondary' : 'primary'}
  35. onClick={handleEnable}
  36. disabled={isDisabled}
  37. >
  38. {t('enable')}
  39. </OLButton>
  40. )
  41. }