File size: 2,930 Bytes
27fd333
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use client'
import type { FC } from 'react'
import React, { useEffect } from 'react'
import cn from 'classnames'
import type { IMainProps } from '@/app/components/share/chat'
import Main from '@/app/components/share/chatbot'
import Loading from '@/app/components/base/loading'
import { fetchSystemFeatures } from '@/service/share'
import LogoSite from '@/app/components/base/logo/logo-site'

const Chatbot: FC<IMainProps> = () => {
  const [isSSOEnforced, setIsSSOEnforced] = React.useState(true)
  const [loading, setLoading] = React.useState(true)

  useEffect(() => {
    fetchSystemFeatures().then((res) => {
      setIsSSOEnforced(res.sso_enforced_for_web)
      setLoading(false)
    })
  }, [])

  return (
    <>
      {
        loading
          ? (
            <div className="flex items-center justify-center h-full" >
              <div className={
                cn(
                  'flex flex-col items-center w-full grow items-center justify-center',
                  'px-6',
                  'md:px-[108px]',
                )
              }>
                <Loading type='area' />
              </div>
            </div >
          )
          : (
            <>
              {isSSOEnforced
                ? (
                  <div className={cn(
                    'flex w-full min-h-screen',
                    'sm:p-4 lg:p-8',
                    'gap-x-20',
                    'justify-center lg:justify-start',
                  )}>
                    <div className={
                      cn(
                        'flex w-full flex-col bg-white shadow rounded-2xl shrink-0',
                        'space-between',
                      )
                    }>
                      <div className='flex items-center justify-between p-6 w-full'>
                        <LogoSite />
                      </div>

                      <div className={
                        cn(
                          'flex flex-col items-center w-full grow items-center justify-center',
                          'px-6',
                          'md:px-[108px]',
                        )
                      }>
                        <div className='flex flex-col md:w-[400px]'>
                          <div className="w-full mx-auto">
                            <h2 className="text-[16px] font-bold text-gray-900">
                          Warning: Chatbot is not available
                            </h2>
                            <p className="text-[16px] text-gray-600 mt-2">
                          Because SSO is enforced. Please contact your administrator.
                            </p>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                )
                : <Main />
              }
            </>
          )}
    </>
  )
}

export default React.memo(Chatbot)