page.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. 'use client'
  2. import React, { useEffect, useState } from 'react'
  3. import cn from 'classnames'
  4. import Script from 'next/script'
  5. import Loading from '../components/base/loading'
  6. import Forms from './forms'
  7. import Header from './_header'
  8. import style from './page.module.css'
  9. import UserSSOForm from './userSSOForm'
  10. import { IS_CE_EDITION } from '@/config'
  11. import type { SystemFeatures } from '@/types/feature'
  12. import { defaultSystemFeatures } from '@/types/feature'
  13. import { getSystemFeatures } from '@/service/common'
  14. const SignIn = () => {
  15. const [loading, setLoading] = useState<boolean>(true)
  16. const [systemFeatures, setSystemFeatures] = useState<SystemFeatures>(defaultSystemFeatures)
  17. useEffect(() => {
  18. getSystemFeatures().then((res) => {
  19. setSystemFeatures(res)
  20. }).finally(() => {
  21. setLoading(false)
  22. })
  23. }, [])
  24. return (
  25. <>
  26. {!IS_CE_EDITION && (
  27. <>
  28. <Script strategy="beforeInteractive" async src={'https://www.googletagmanager.com/gtag/js?id=AW-11217955271'}></Script>
  29. <Script
  30. id="ga-monitor-register"
  31. dangerouslySetInnerHTML={{
  32. __html: `
  33. window.dataLayer2 = window.dataLayer2 || [];
  34. function gtag(){dataLayer2.push(arguments);}
  35. gtag('js', new Date());
  36. gtag('config', 'AW-11217955271"');
  37. `,
  38. }}
  39. >
  40. </Script>
  41. </>
  42. )}
  43. <div className={cn(
  44. style.background,
  45. 'flex w-full min-h-screen',
  46. 'sm:p-4 lg:p-8',
  47. 'gap-x-20',
  48. 'justify-center lg:justify-start',
  49. )}>
  50. <div className={
  51. cn(
  52. 'flex w-full flex-col bg-white shadow rounded-2xl shrink-0',
  53. 'space-between',
  54. )
  55. }>
  56. <Header />
  57. {loading && (
  58. <div className={
  59. cn(
  60. 'flex flex-col items-center w-full grow justify-center',
  61. 'px-6',
  62. 'md:px-[108px]',
  63. )
  64. }>
  65. <Loading type='area' />
  66. </div>
  67. )}
  68. {!loading && !systemFeatures.sso_enforced_for_signin && (
  69. <>
  70. <Forms />
  71. <div className='px-8 py-6 text-sm font-normal text-gray-500'>
  72. © {new Date().getFullYear()} LangGenius, Inc. All rights reserved.
  73. </div>
  74. </>
  75. )}
  76. {!loading && systemFeatures.sso_enforced_for_signin && (
  77. <UserSSOForm protocol={systemFeatures.sso_enforced_for_signin_protocol} />
  78. )}
  79. </div>
  80. </div>
  81. </>
  82. )
  83. }
  84. export default SignIn