page.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 EnterpriseSSOForm from './enterpriseSSOForm'
  10. import { IS_CE_EDITION } from '@/config'
  11. import { getEnterpriseFeatures } from '@/service/enterprise'
  12. import type { EnterpriseFeatures } from '@/types/enterprise'
  13. import { defaultEnterpriseFeatures } from '@/types/enterprise'
  14. const SignIn = () => {
  15. const [loading, setLoading] = useState<boolean>(true)
  16. const [enterpriseFeatures, setEnterpriseFeatures] = useState<EnterpriseFeatures>(defaultEnterpriseFeatures)
  17. useEffect(() => {
  18. getEnterpriseFeatures().then((res) => {
  19. setEnterpriseFeatures(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 items-center justify-center',
  61. 'px-6',
  62. 'md:px-[108px]',
  63. )
  64. }>
  65. <Loading type='area' />
  66. </div>
  67. )}
  68. {!loading && !enterpriseFeatures.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 && enterpriseFeatures.sso_enforced_for_signin && (
  77. <EnterpriseSSOForm protocol={enterpriseFeatures.sso_enforced_for_signin_protocol} />
  78. )}
  79. </div>
  80. </div>
  81. </>
  82. )
  83. }
  84. export default SignIn