index.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import s from './style.module.css'
  6. import Modal from '@/app/components/base/modal'
  7. import Button from '@/app/components/base/button'
  8. import { AlertCircle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback'
  9. type Props = {
  10. isShow: boolean
  11. onHide: () => void
  12. onRemove: () => void
  13. text?: string
  14. children?: JSX.Element
  15. }
  16. const DeleteConfirmModal: FC<Props> = ({
  17. isShow,
  18. onHide,
  19. onRemove,
  20. children,
  21. text,
  22. }) => {
  23. const { t } = useTranslation()
  24. if (!isShow)
  25. return null
  26. return (
  27. <Modal
  28. isShow={isShow}
  29. onClose={onHide}
  30. className={s.delModal}
  31. closable
  32. >
  33. <div onClick={(e) => {
  34. e.stopPropagation()
  35. e.stopPropagation()
  36. e.nativeEvent.stopImmediatePropagation()
  37. }}>
  38. <div className={s.warningWrapper}>
  39. <AlertCircle className='w-6 h-6 text-red-600' />
  40. </div>
  41. {text
  42. ? (
  43. <div className='text-xl font-semibold text-gray-900 mb-3'>{text}</div>
  44. )
  45. : children}
  46. <div className='flex gap-2 justify-end'>
  47. <Button onClick={onHide}>{t('common.operation.cancel')}</Button>
  48. <Button
  49. type='warning'
  50. onClick={onRemove}
  51. className='border-red-700 border-[0.5px]'
  52. >
  53. {t('common.operation.sure')}
  54. </Button>
  55. </div>
  56. </div>
  57. </Modal>
  58. )
  59. }
  60. export default React.memo(DeleteConfirmModal)