서민정

update card.js and show card on front

...@@ -41,15 +41,21 @@ function Chatbot() { ...@@ -41,15 +41,21 @@ 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 - console.log("res",response)
45 44
46 - for (let content of response.data) { 45 + for(var i = 0; i < 3; i++){
47 conversation = { 46 conversation = {
48 - who: '소통이', 47 + who : '소통이',
49 - content : content 48 + content : response.data[i]
50 } 49 }
51 dispatch(saveMessage(conversation)) 50 dispatch(saveMessage(conversation))
52 } 51 }
52 + // for (let content of response.data) {
53 + // conversation = {
54 + // who: '소통이',
55 + // content : content
56 + // }
57 + // dispatch(saveMessage(conversation))
58 + // }
53 59
54 } else { 60 } else {
55 //I will send request to the textQuery ROUTE 61 //I will send request to the textQuery ROUTE
...@@ -81,8 +87,6 @@ function Chatbot() { ...@@ -81,8 +87,6 @@ function Chatbot() {
81 87
82 } 88 }
83 89
84 -
85 - //eventQuery 삭제하기.
86 const eventQuery = async (event) => { 90 const eventQuery = async (event) => {
87 91
88 // We need to take care of the message Chatbot sent 92 // We need to take care of the message Chatbot sent
...@@ -94,7 +98,6 @@ function Chatbot() { ...@@ -94,7 +98,6 @@ function Chatbot() {
94 //I will send request to the textQuery ROUTE 98 //I will send request to the textQuery ROUTE
95 const response = await Axios.post('/api/dialogflow/eventQuery', eventQueryVariables) 99 const response = await Axios.post('/api/dialogflow/eventQuery', eventQueryVariables)
96 for (let content of response.data.fulfillmentMessages) { 100 for (let content of response.data.fulfillmentMessages) {
97 -
98 let conversation = { 101 let conversation = {
99 who: '소통이', 102 who: '소통이',
100 content: content 103 content: content
...@@ -135,7 +138,12 @@ function Chatbot() { ...@@ -135,7 +138,12 @@ function Chatbot() {
135 } 138 }
136 139
137 const renderCards = (cards) => { 140 const renderCards = (cards) => {
138 - return cards.map((card,i) => <Card key={i} cardInfo={card.content} />) 141 + let Cards = []; //넣을 배열
142 + let pushCard = {};
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} />)
139 } 147 }
140 148
141 149
...@@ -151,7 +159,7 @@ function Chatbot() { ...@@ -151,7 +159,7 @@ function Chatbot() {
151 else if (message.content && message.content.description) { 159 else if (message.content && message.content.description) {
152 160
153 const AvatarSrc = message.who === '소통이' ? <Icon type="robot" /> : <Icon type="smile" /> 161 const AvatarSrc = message.who === '소통이' ? <Icon type="robot" /> : <Icon type="smile" />
154 - 162 + console.log("message content",message.content)
155 return <div> 163 return <div>
156 <List.Item style={{ padding: '1rem' }}> 164 <List.Item style={{ padding: '1rem' }}>
157 <List.Item.Meta 165 <List.Item.Meta
......
...@@ -4,24 +4,24 @@ import { Card, Icon } from 'antd'; ...@@ -4,24 +4,24 @@ import { Card, Icon } from 'antd';
4 const { Meta } = Card; 4 const { Meta } = Card;
5 5
6 function CardComponent(props) { 6 function CardComponent(props) {
7 - console.log(props) 7 + console.log("props" ,props)
8 return ( 8 return (
9 <Card 9 <Card
10 style={{ width: 300 }} 10 style={{ width: 300 }}
11 cover={ 11 cover={
12 <img 12 <img
13 - alt={props.cardInfo.content.description} 13 + alt={props.cardInfo.description}
14 - src={props.cardInfo.content.image} /> 14 + src={props.cardInfo.image} />
15 } 15 }
16 actions={[ 16 actions={[
17 - <a target="_blank" rel="noopener noreferrer" href={props.cardInfo.content.link}> 17 + <a target="_blank" rel="noopener noreferrer" href={props.cardInfo.link}>
18 <Icon type="ellipsis" key="ellipsis" /> 18 <Icon type="ellipsis" key="ellipsis" />
19 </a> 19 </a>
20 ]} 20 ]}
21 > 21 >
22 <Meta 22 <Meta
23 - title={props.cardInfo.content.title} 23 + title={props.cardInfo.title}
24 - description={props.cardInfo.content.description} 24 + description={props.cardInfo.description}
25 /> 25 />
26 26
27 </Card> 27 </Card>
......