index.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import {
  6. RiErrorWarningFill,
  7. } from '@remixicon/react'
  8. import s from './style.module.css'
  9. import Modal from '@/app/components/base/modal'
  10. import Button from '@/app/components/base/button'
  11. type Props = {
  12. isShow: boolean
  13. onHide: () => void
  14. onRemove: () => void
  15. text?: string
  16. children?: JSX.Element
  17. }
  18. const DeleteConfirmModal: FC<Props> = ({
  19. isShow,
  20. onHide,
  21. onRemove,
  22. children,
  23. text,
  24. }) => {
  25. const { t } = useTranslation()
  26. if (!isShow)
  27. return null
  28. return (
  29. <Modal
  30. isShow={isShow}
  31. onClose={onHide}
  32. className={s.delModal}
  33. closable
  34. >
  35. <div onClick={(e) => {
  36. e.stopPropagation()
  37. e.stopPropagation()
  38. e.nativeEvent.stopImmediatePropagation()
  39. }}>
  40. <div className={s.warningWrapper}>
  41. <RiErrorWarningFill 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. variant='warning'
  52. onClick={onRemove}
  53. className='border-red-700'
  54. >
  55. {t('common.operation.sure')}
  56. </Button>
  57. </div>
  58. </div>
  59. </Modal>
  60. )
  61. }
  62. export default React.memo(DeleteConfirmModal)