wca-designsystem 1.0.58 → 1.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.58",
2
+ "version": "1.0.59",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -61,7 +61,7 @@ const Template: any = (args: any) => {
61
61
  {...args}
62
62
  messages={messages}
63
63
  isTyping={isTyping}
64
- disabledInputUser={true}
64
+ disabledInputUser={false}
65
65
  setMessages={setMessages}
66
66
  setIsTyping={setIsTyping}
67
67
  respostaUser={respostaUser}
@@ -27,18 +27,21 @@ type ChatBotProps = {
27
27
  messages: MensagemChat[]
28
28
  setMessages: React.Dispatch<React.SetStateAction<MensagemChat[]>>
29
29
  disabledInputUser?: boolean
30
+ handleUserTextInput: () => void
31
+ handleOptionClick: (id: string, opcaoId: string) => void
30
32
  }
31
33
 
32
34
  const ChatBot = ({
33
35
  messages,
34
36
  isTyping,
35
37
  setMessages,
36
- setIsTyping,
37
38
  respostaUser,
38
39
  setRespostaUser,
40
+ handleOptionClick,
41
+ handleUserTextInput,
39
42
  disabledInputUser = false,
40
43
  }: ChatBotProps) => {
41
- const handleOptionSelect = (option: any) => {
44
+ const handleOptionSelect = (idChat: string, option: any) => {
42
45
  const indexWithOptions = messages.findIndex((msg: any) => msg.options)
43
46
 
44
47
  if (indexWithOptions !== -1) {
@@ -52,16 +55,10 @@ const ChatBot = ({
52
55
 
53
56
  updatedMessages.push({ type: 'user', text: option })
54
57
  setMessages(updatedMessages)
55
- setIsTyping(true)
58
+ handleOptionClick(idChat, option)
56
59
  }
57
60
  }
58
61
 
59
- const handleSend = (innerHtml: string) => {
60
- setMessages((prev: any) => [...prev, { type: 'user', text: innerHtml }])
61
- setRespostaUser('')
62
- setIsTyping(true)
63
- }
64
-
65
62
  return (
66
63
  <ChatWrapper>
67
64
  <ChatContainer>
@@ -93,7 +90,7 @@ const ChatBot = ({
93
90
  {msg.options.map((opt: any, i: number) => (
94
91
  <BotaoChat
95
92
  key={opt}
96
- onClick={() => handleOptionSelect(opt)}
93
+ onClick={() => handleOptionSelect(msg.idChat, opt)}
97
94
  >
98
95
  {i + 1}. {opt}
99
96
  </BotaoChat>
@@ -120,7 +117,7 @@ const ChatBot = ({
120
117
  <MessageInput
121
118
  value={respostaUser}
122
119
  onChange={(val) => setRespostaUser(val)}
123
- onSend={(msg) => handleSend(msg)}
120
+ onSend={() => handleUserTextInput()}
124
121
  attachButton={false}
125
122
  placeholder={
126
123
  disabledInputUser