index.tsx 1.6 KB

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