editing-title.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. const isSyncingWorkflowDraft = useStore(s => s.isSyncingWorkflowDraft)
  13. return (
  14. <div className='flex items-center h-[18px] text-xs text-gray-500'>
  15. {
  16. !!draftUpdatedAt && (
  17. <>
  18. {t('workflow.common.autoSaved')} {formatTime(draftUpdatedAt / 1000, 'HH:mm:ss')}
  19. </>
  20. )
  21. }
  22. <span className='flex items-center mx-1'>·</span>
  23. {
  24. publishedAt
  25. ? `${t('workflow.common.published')} ${formatTimeFromNow(publishedAt)}`
  26. : t('workflow.common.unpublished')
  27. }
  28. {
  29. isSyncingWorkflowDraft && (
  30. <>
  31. <span className='flex items-center mx-1'>·</span>
  32. {t('workflow.common.syncingData')}
  33. </>
  34. )
  35. }
  36. </div>
  37. )
  38. }
  39. export default memo(EditingTitle)