서민정

update card message

...@@ -21,7 +21,7 @@ function Chatbot() { ...@@ -21,7 +21,7 @@ function Chatbot() {
21 21
22 // First Need to take care of the message I sent 22 // First Need to take care of the message I sent
23 let conversation = { 23 let conversation = {
24 - who: 'user', 24 + who: '사용자',
25 content: { 25 content: {
26 text: { 26 text: {
27 text: text 27 text: text
...@@ -41,21 +41,18 @@ function Chatbot() { ...@@ -41,21 +41,18 @@ function Chatbot() {
41 try { 41 try {
42 if(inputString[0] === '@'){ 42 if(inputString[0] === '@'){
43 const response = await Axios.post('/api/crawling/textQuery', textQueryVariables) 43 const response = await Axios.post('/api/crawling/textQuery', textQueryVariables)
44 - 44 + let conversations = {}
45 + let pushConversations = []
45 for(var i = 0; i < 3; i++){ 46 for(var i = 0; i < 3; i++){
46 conversation = { 47 conversation = {
47 who : '소통이', 48 who : '소통이',
48 content : response.data[i] 49 content : response.data[i]
49 } 50 }
50 - dispatch(saveMessage(conversation)) 51 + pushConversations.push(conversation)
51 } 52 }
52 - // for (let content of response.data) { 53 + conversations["card"] = pushConversations
53 - // conversation = { 54 + console.log("conversations",conversations)
54 - // who: '소통이', 55 + dispatch(saveMessage(conversations))
55 - // content : content
56 - // }
57 - // dispatch(saveMessage(conversation))
58 - // }
59 56
60 } else { 57 } else {
61 //I will send request to the textQuery ROUTE 58 //I will send request to the textQuery ROUTE
...@@ -138,17 +135,14 @@ function Chatbot() { ...@@ -138,17 +135,14 @@ function Chatbot() {
138 } 135 }
139 136
140 const renderCards = (cards) => { 137 const renderCards = (cards) => {
141 - let Cards = []; //넣을 배열 138 + cards.map((card,i) => console.log("card.content",card.content))
142 - let pushCard = {}; 139 + return cards.map((card,i) => <Card key={i} cardInfo={card.content} />)
143 - pushCard["content"] = cards;
144 - Cards.push(pushCard);
145 - Cards.map((card,i) => console.log("card.content",card.content))
146 - return Cards.map((card,i) => <Card key={i} cardInfo={card.content} />)
147 } 140 }
148 141
149 142
150 const renderOneMessage = (message, i) => { 143 const renderOneMessage = (message, i) => {
151 console.log('message', message) 144 console.log('message', message)
145 + console.log('message.card',message.card)
152 146
153 // we need to give some condition here to separate message kinds 147 // we need to give some condition here to separate message kinds
154 148
...@@ -156,7 +150,7 @@ function Chatbot() { ...@@ -156,7 +150,7 @@ function Chatbot() {
156 if (message.content && message.content.text && message.content.text.text) { 150 if (message.content && message.content.text && message.content.text.text) {
157 return <Message key={i} who={message.who} text={message.content.text.text} /> 151 return <Message key={i} who={message.who} text={message.content.text.text} />
158 } 152 }
159 - else if (message.content && message.content.description) { 153 + else if (message.card) {
160 154
161 const AvatarSrc = message.who === '소통이' ? <Icon type="robot" /> : <Icon type="smile" /> 155 const AvatarSrc = message.who === '소통이' ? <Icon type="robot" /> : <Icon type="smile" />
162 console.log("message content",message.content) 156 console.log("message content",message.content)
...@@ -165,7 +159,7 @@ function Chatbot() { ...@@ -165,7 +159,7 @@ function Chatbot() {
165 <List.Item.Meta 159 <List.Item.Meta
166 avatar={<Avatar icon={AvatarSrc} />} 160 avatar={<Avatar icon={AvatarSrc} />}
167 title={message.who} 161 title={message.who}
168 - description={renderCards(message.content)} 162 + description={renderCards(message.card)}
169 /> 163 />
170 </List.Item> 164 </List.Item>
171 </div> 165 </div>
......
...@@ -3,7 +3,7 @@ import { List, Icon, Avatar } from 'antd'; ...@@ -3,7 +3,7 @@ import { List, Icon, Avatar } from 'antd';
3 3
4 function Message(props) { 4 function Message(props) {
5 5
6 - const AvatarSrc = props.who ==='bot' ? <Icon type="robot" /> : <Icon type="smile" /> 6 + const AvatarSrc = props.who ==='소통이' ? <Icon type="robot" /> : <Icon type="smile" />
7 7
8 return ( 8 return (
9 <List.Item style={{ padding: '1rem' }}> 9 <List.Item style={{ padding: '1rem' }}>
......