You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

maintenance-notice.tsx 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { useState } from 'react'
  2. import { X } from '@/app/components/base/icons/src/vender/line/general'
  3. import { NOTICE_I18N } from '@/i18n/language'
  4. import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
  5. const MaintenanceNotice = () => {
  6. const locale = useLanguage()
  7. const [showNotice, setShowNotice] = useState(localStorage.getItem('hide-maintenance-notice') !== '1')
  8. const handleJumpNotice = () => {
  9. window.open(NOTICE_I18N.href, '_blank')
  10. }
  11. const handleCloseNotice = () => {
  12. localStorage.setItem('hide-maintenance-notice', '1')
  13. setShowNotice(false)
  14. }
  15. const titleByLocale: { [key: string]: string } = NOTICE_I18N.title
  16. const descByLocale: { [key: string]: string } = NOTICE_I18N.desc
  17. if (!showNotice)
  18. return null
  19. return (
  20. <div className='z-20 flex h-[38px] shrink-0 items-center border-[0.5px] border-b border-b-[#FEF0C7] bg-[#FFFAEB] px-4'>
  21. <div className='mr-2 flex h-[22px] shrink-0 items-center rounded-xl bg-[#F79009] px-2 text-[11px] font-medium text-white'>{titleByLocale[locale]}</div>
  22. {
  23. (NOTICE_I18N.href && NOTICE_I18N.href !== '#')
  24. ? <div className='grow cursor-pointer text-xs font-medium text-gray-700' onClick={handleJumpNotice}>{descByLocale[locale]}</div>
  25. : <div className='grow text-xs font-medium text-gray-700'>{descByLocale[locale]}</div>
  26. }
  27. <X className='h-4 w-4 shrink-0 cursor-pointer text-gray-500' onClick={handleCloseNotice} />
  28. </div>
  29. )
  30. }
  31. export default MaintenanceNotice