File size: 2,646 Bytes
4304c6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import type { FC } from 'react'
import React from 'react'
import {
  Bars3Icon,
  PencilSquareIcon,
} from '@heroicons/react/24/solid'
import { useTranslation } from 'react-i18next'
import AppIcon from '@/app/components/base/app-icon'
import { ReplayIcon } from '@/app/components/app/chat/icon-component'
import Tooltip from '@/app/components/base/tooltip'

export type IHeaderProps = {
  title: string
  customerIcon?: React.ReactNode
  icon: string
  icon_background: string
  isMobile?: boolean
  isEmbedScene?: boolean
  onShowSideBar?: () => void
  onCreateNewChat?: () => void
}
const Header: FC<IHeaderProps> = ({

  title,

  isMobile,

  customerIcon,

  icon,

  icon_background,

  isEmbedScene = false,

  onShowSideBar,

  onCreateNewChat,

}) => {
  const { t } = useTranslation()
  if (!isMobile)
    return null

  if (isEmbedScene) {
    return (
      <div

        className={`

          shrink-0 flex items-center justify-between h-14 px-4 bg-gray-100 

          bg-gradient-to-r from-blue-600 to-sky-500

        `}

      >

        <div className="flex items-center space-x-2">

          {customerIcon || <AppIcon size="small" icon={icon} background={icon_background} />}

          <div

            className={'text-sm font-bold text-white'}

          >

            {title}

          </div>

        </div>

        <Tooltip

          selector={'embed-scene-restart-button'}

          htmlContent={t('share.chat.resetChat')}

          position='top'

        >

          <div className='flex cursor-pointer hover:rounded-lg hover:bg-black/5 w-8 h-8 items-center justify-center' onClick={() => {

            onCreateNewChat?.()

          }}>

            <ReplayIcon className="h-4 w-4 text-sm font-bold text-white" />

          </div>

        </Tooltip>

      </div>
    )
  }

  return (
    <div className="shrink-0 flex items-center justify-between h-14 px-4 bg-gray-100">

      <div

        className='flex items-center justify-center h-8 w-8 cursor-pointer'

        onClick={() => onShowSideBar?.()}

      >

        <Bars3Icon className="h-4 w-4 text-gray-500" />

      </div>

      <div className='flex items-center space-x-2'>

        <AppIcon size="small" icon={icon} background={icon_background} />

        <div className=" text-sm text-gray-800 font-bold">{title}</div>

      </div>

      <div className='flex items-center justify-center h-8 w-8 cursor-pointer'

        onClick={() => onCreateNewChat?.()}

      >

        <PencilSquareIcon className="h-4 w-4 text-gray-500" />

      </div>

    </div>
  )
}

export default React.memo(Header)