editing-title.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import { memo } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import { useWorkflow } from '../hooks'
  4. import { useStore } from '@/app/components/workflow/store'
  5. import useTimestamp from '@/hooks/use-timestamp'
  6. const EditingTitle = () => {
  7. const { t } = useTranslation()
  8. const { formatTime } = useTimestamp()
  9. const { formatTimeFromNow } = useWorkflow()
  10. const draftUpdatedAt = useStore(state => state.draftUpdatedAt)
  11. const publishedAt = useStore(state => state.publishedAt)
  12. return (
  13. <div className='flex items-center h-[18px] text-xs text-gray-500'>
  14. {
  15. !!draftUpdatedAt && (
  16. <>
  17. {t('workflow.common.autoSaved')} {formatTime(draftUpdatedAt / 1000, 'HH:mm:ss')}
  18. </>
  19. )
  20. }
  21. <span className='flex items-center mx-1'>·</span>
  22. {
  23. publishedAt
  24. ? `${t('workflow.common.published')} ${formatTimeFromNow(publishedAt)}`
  25. : t('workflow.common.unpublished')
  26. }
  27. </div>
  28. )
  29. }
  30. export default memo(EditingTitle)