Showing
5 changed files
with
42 additions
and
6 deletions
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | ## CHATBOT WITH CRAWLING | 2 | ## CHATBOT WITH CRAWLING |
3 | 3 | ||
4 | front | 4 | front |
5 | -- [x] Modify card component | 5 | +- [ ] Modify card component |
6 | - [ ] Remove card message on dialogflow | 6 | - [ ] Remove card message on dialogflow |
7 | - [ ] Modify Intent on dialogflow | 7 | - [ ] Modify Intent on dialogflow |
8 | - [ ] Add additional functions on dialogflow | 8 | - [ ] Add additional functions on dialogflow | ... | ... |
... | @@ -2,6 +2,7 @@ import { | ... | @@ -2,6 +2,7 @@ import { |
2 | SAVE_MESSAGE, | 2 | SAVE_MESSAGE, |
3 | } from '../_actions/types'; | 3 | } from '../_actions/types'; |
4 | 4 | ||
5 | +//비어있는 message array에 넣을 것 | ||
5 | export default function (state = {messages:[]}, action) { | 6 | export default function (state = {messages:[]}, action) { |
6 | switch (action.type) { | 7 | switch (action.type) { |
7 | case SAVE_MESSAGE: | 8 | case SAVE_MESSAGE: | ... | ... |
... | @@ -44,7 +44,11 @@ function Chatbot() { | ... | @@ -44,7 +44,11 @@ function Chatbot() { |
44 | console.log("res",response) | 44 | console.log("res",response) |
45 | 45 | ||
46 | for (let content of response.data) { | 46 | for (let content of response.data) { |
47 | - console.log(content) | 47 | + conversation = { |
48 | + who: '소통이', | ||
49 | + content : content | ||
50 | + } | ||
51 | + dispatch(saveMessage(conversation)) | ||
48 | } | 52 | } |
49 | 53 | ||
50 | } else { | 54 | } else { |
... | @@ -78,6 +82,7 @@ function Chatbot() { | ... | @@ -78,6 +82,7 @@ function Chatbot() { |
78 | } | 82 | } |
79 | 83 | ||
80 | 84 | ||
85 | + //eventQuery 삭제하기. | ||
81 | const eventQuery = async (event) => { | 86 | const eventQuery = async (event) => { |
82 | 87 | ||
83 | // We need to take care of the message Chatbot sent | 88 | // We need to take care of the message Chatbot sent |
... | @@ -130,7 +135,7 @@ function Chatbot() { | ... | @@ -130,7 +135,7 @@ function Chatbot() { |
130 | } | 135 | } |
131 | 136 | ||
132 | const renderCards = (cards) => { | 137 | const renderCards = (cards) => { |
133 | - return cards.map((card,i) => <Card key={i} cardInfo={card.structValue} />) | 138 | + return cards.map((card,i) => <Card key={i} cardInfo={card.content} />) |
134 | } | 139 | } |
135 | 140 | ||
136 | 141 | ||
... | @@ -142,7 +147,8 @@ function Chatbot() { | ... | @@ -142,7 +147,8 @@ function Chatbot() { |
142 | // template for normal text | 147 | // template for normal text |
143 | if (message.content && message.content.text && message.content.text.text) { | 148 | if (message.content && message.content.text && message.content.text.text) { |
144 | return <Message key={i} who={message.who} text={message.content.text.text} /> | 149 | return <Message key={i} who={message.who} text={message.content.text.text} /> |
145 | - } else if (message.content && message.content.payload.fields.card) { | 150 | + } |
151 | + else if (message.content && message.content.description) { | ||
146 | 152 | ||
147 | const AvatarSrc = message.who === '소통이' ? <Icon type="robot" /> : <Icon type="smile" /> | 153 | const AvatarSrc = message.who === '소통이' ? <Icon type="robot" /> : <Icon type="smile" /> |
148 | 154 | ||
... | @@ -151,7 +157,7 @@ function Chatbot() { | ... | @@ -151,7 +157,7 @@ function Chatbot() { |
151 | <List.Item.Meta | 157 | <List.Item.Meta |
152 | avatar={<Avatar icon={AvatarSrc} />} | 158 | avatar={<Avatar icon={AvatarSrc} />} |
153 | title={message.who} | 159 | title={message.who} |
154 | - description={renderCards(message.content.payload.fields.card.listValue.values)} | 160 | + description={renderCards(message.content)} |
155 | /> | 161 | /> |
156 | </List.Item> | 162 | </List.Item> |
157 | </div> | 163 | </div> | ... | ... |
... | @@ -4,6 +4,34 @@ import { Card, Icon } from 'antd'; | ... | @@ -4,6 +4,34 @@ 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) | ||
8 | + return ( | ||
9 | + <Card | ||
10 | + style={{ width: 300 }} | ||
11 | + cover={ | ||
12 | + <img | ||
13 | + alt={props.cardInfo.content.description} | ||
14 | + src={props.cardInfo.content.image} /> | ||
15 | + } | ||
16 | + actions={[ | ||
17 | + <a target="_blank" rel="noopener noreferrer" href={props.cardInfo.content.link}> | ||
18 | + <Icon type="ellipsis" key="ellipsis" /> | ||
19 | + </a> | ||
20 | + ]} | ||
21 | + > | ||
22 | + <Meta | ||
23 | + title={props.cardInfo.content.title} | ||
24 | + description={props.cardInfo.content.description} | ||
25 | + /> | ||
26 | + | ||
27 | + </Card> | ||
28 | + | ||
29 | + ) | ||
30 | +} | ||
31 | + | ||
32 | + | ||
33 | +/* | ||
34 | +function CardComponent(props) { | ||
7 | return ( | 35 | return ( |
8 | <Card | 36 | <Card |
9 | style={{ width: 300 }} | 37 | style={{ width: 300 }} |
... | @@ -27,5 +55,5 @@ function CardComponent(props) { | ... | @@ -27,5 +55,5 @@ function CardComponent(props) { |
27 | 55 | ||
28 | ) | 56 | ) |
29 | } | 57 | } |
30 | - | 58 | +*/ |
31 | export default CardComponent | 59 | export default CardComponent | ... | ... |
-
Please register or login to post a comment