rename-modal.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React, { useState } from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import Modal from '@/app/components/base/modal'
  6. import Button from '@/app/components/base/button'
  7. export type IRenameModalProps = {
  8. isShow: boolean
  9. saveLoading: boolean
  10. name: string
  11. onClose: () => void
  12. onSave: (name: string) => void
  13. }
  14. const RenameModal: FC<IRenameModalProps> = ({
  15. isShow,
  16. saveLoading,
  17. name,
  18. onClose,
  19. onSave,
  20. }) => {
  21. const { t } = useTranslation()
  22. const [tempName, setTempName] = useState(name)
  23. return (
  24. <Modal
  25. title={t('common.chat.renameConversation')}
  26. isShow={isShow}
  27. onClose={onClose}
  28. >
  29. <div className={'mt-6 font-medium text-sm leading-[21px] text-gray-900'}>{t('common.chat.conversationName')}</div>
  30. <input className={'mt-2 w-full rounded-lg h-10 box-border px-3 text-sm leading-10 bg-gray-100'}
  31. value={tempName}
  32. onChange={e => setTempName(e.target.value)}
  33. placeholder={t('common.chat.conversationNamePlaceholder') || ''}
  34. />
  35. <div className='mt-10 flex justify-end'>
  36. <Button className='mr-2 flex-shrink-0' onClick={onClose}>{t('common.operation.cancel')}</Button>
  37. <Button variant='primary' className='flex-shrink-0' onClick={() => onSave(tempName)} loading={saveLoading}>{t('common.operation.save')}</Button>
  38. </div>
  39. </Modal>
  40. )
  41. }
  42. export default React.memo(RenameModal)