index.tsx 1.2 KB

1234567891011121314151617181920212223242526272829
  1. 'use client'
  2. import AppContext from '@/context/app-context'
  3. import { LicenseStatus } from '@/types/feature'
  4. import { useTranslation } from 'react-i18next'
  5. import { useContextSelector } from 'use-context-selector'
  6. import dayjs from 'dayjs'
  7. const LicenseNav = () => {
  8. const { t } = useTranslation()
  9. const systemFeatures = useContextSelector(AppContext, s => s.systemFeatures)
  10. if (systemFeatures.license?.status === LicenseStatus.EXPIRING) {
  11. const expiredAt = systemFeatures.license?.expired_at
  12. const count = dayjs(expiredAt).diff(dayjs(), 'days')
  13. return <div className='px-2 py-1 mr-4 rounded-full bg-util-colors-orange-orange-50 border-util-colors-orange-orange-100 system-xs-medium text-util-colors-orange-orange-600'>
  14. {count <= 1 && <span>{t('common.license.expiring', { count })}</span>}
  15. {count > 1 && <span>{t('common.license.expiring_plural', { count })}</span>}
  16. </div>
  17. }
  18. if (systemFeatures.license.status === LicenseStatus.ACTIVE) {
  19. return <div className='px-2 py-1 mr-4 rounded-md bg-util-colors-indigo-indigo-50 border-util-colors-indigo-indigo-100 system-xs-medium text-util-colors-indigo-indigo-600'>
  20. Enterprise
  21. </div>
  22. }
  23. return null
  24. }
  25. export default LicenseNav