-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
94 lines (83 loc) · 2.57 KB
/
index.js
File metadata and controls
94 lines (83 loc) · 2.57 KB
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
90
91
92
93
94
import React, { useState } from 'react'
import axios from 'axios'
import {
ChakraProvider,
Circle,
Fade,
useDisclosure,
Stack,
Text,
Flex,
Heading
} from '@chakra-ui/react'
import { ChatIcon, CloseIcon } from '@chakra-ui/icons'
import styles from './styles.module.css'
import Landing from './components/Landing/Landing'
import RealtimeChatbox from './components/RealtimeChatBox/RealtimeChatbox'
import { routes } from './constants'
export const ChmodChatComponent = ({ chatProps }) => {
axios.defaults.baseURL = process.env.REACT_APP_CHMOD
// eslint-disable-next-line dot-notation
axios.defaults.headers.common['Authorization'] = chatProps.sessionToken
const [activeRoute, setActiveRoute] = useState(routes.LANDING)
const { isOpen, onToggle } = useDisclosure()
const onBack = () => {
setActiveRoute(routes.LANDING)
}
const onNavigate = (route) => {
setActiveRoute(route)
}
return (
<ChakraProvider>
<Circle className={styles.chatIcon} onClick={onToggle}>
{!isOpen ? <ChatIcon color='white' /> : <CloseIcon color='white' />}
</Circle>
{isOpen && (
<Fade in={isOpen}>
<Flex
position='fixed'
bottom={24}
width='320px'
height='490px'
right={8}
rounded='md'
shadow='md'
direction='column'
justifyContent='space-between'
bgColor='white'
zIndex='2147483000'
>
<Stack
direction='column'
backgroundColor='teal.500'
spacing={2}
background='linear-gradient(135deg, hsla(179, 58%, 52%, 1) 0%, hsla(179, 51%, 39%, 1) 100%)'
padding={6}
>
<Heading as='h4' size='md' color='white'>
{chatProps.appName} Assistant
</Heading>
<Text fontSize='xl' color='white'>
Hi 👋
</Text>
<Text color='white' fontSize='xs'>
We help you grow your business
</Text>
</Stack>
{activeRoute === routes.LANDING && (
<Landing onNavigate={onNavigate} />
)}
{activeRoute === routes.LIVE_CHAT && (
<RealtimeChatbox onBack={onBack} />
)}
<Flex position='sticky' bottom={0} justifyContent='center'>
<span className={styles.chatFooter}>
Powered by <b>chmod777</b>
</span>
</Flex>
</Flex>
</Fade>
)}
</ChakraProvider>
)
}