Toggle navigation
Toggle navigation
This project
Loading...
Sign in
서민정
/
SEARCH-AND-CHAT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
2
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
서민정
2020-05-20 01:09:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8a03775440cde788b2787a9ae9d4a14ea56301bf
8a037754
1 parent
fd85e7aa
occur error about Card component and map function
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
6 deletions
README.md
client/src/_actions/message_actions.js
client/src/_reducers/message_reducer.js
client/src/chatbot/chatbot.js
client/src/chatbot/sections/card.js
README.md
View file @
8a03775
...
...
@@ -2,7 +2,7 @@
## CHATBOT WITH CRAWLING
front
-
[
x
]
Modify card component
-
[
]
Modify card component
-
[
]
Remove card message on dialogflow
-
[
]
Modify Intent on dialogflow
-
[
]
Add additional functions on dialogflow
...
...
client/src/_actions/message_actions.js
View file @
8a03775
...
...
@@ -2,6 +2,7 @@ import {
SAVE_MESSAGE
,
}
from
'./types'
;
//dataToSubmit 에 conversation이 들어감.
export
function
saveMessage
(
dataToSubmit
)
{
return
{
...
...
client/src/_reducers/message_reducer.js
View file @
8a03775
...
...
@@ -2,6 +2,7 @@ import {
SAVE_MESSAGE
,
}
from
'../_actions/types'
;
//비어있는 message array에 넣을 것
export
default
function
(
state
=
{
messages
:[]},
action
)
{
switch
(
action
.
type
)
{
case
SAVE_MESSAGE
:
...
...
client/src/chatbot/chatbot.js
View file @
8a03775
...
...
@@ -44,7 +44,11 @@ function Chatbot() {
console
.
log
(
"res"
,
response
)
for
(
let
content
of
response
.
data
)
{
console
.
log
(
content
)
conversation
=
{
who
:
'소통이'
,
content
:
content
}
dispatch
(
saveMessage
(
conversation
))
}
}
else
{
...
...
@@ -78,6 +82,7 @@ function Chatbot() {
}
//eventQuery 삭제하기.
const
eventQuery
=
async
(
event
)
=>
{
// We need to take care of the message Chatbot sent
...
...
@@ -130,7 +135,7 @@ function Chatbot() {
}
const
renderCards
=
(
cards
)
=>
{
return
cards
.
map
((
card
,
i
)
=>
<
Card
key
=
{
i
}
cardInfo
=
{
card
.
structValue
}
/>
)
return
cards
.
map
((
card
,
i
)
=>
<
Card
key
=
{
i
}
cardInfo
=
{
card
.
content
}
/>
)
}
...
...
@@ -142,7 +147,8 @@ function Chatbot() {
// template for normal text
if
(
message
.
content
&&
message
.
content
.
text
&&
message
.
content
.
text
.
text
)
{
return
<
Message
key
=
{
i
}
who
=
{
message
.
who
}
text
=
{
message
.
content
.
text
.
text
}
/
>
}
else
if
(
message
.
content
&&
message
.
content
.
payload
.
fields
.
card
)
{
}
else
if
(
message
.
content
&&
message
.
content
.
description
)
{
const
AvatarSrc
=
message
.
who
===
'소통이'
?
<
Icon
type
=
"robot"
/>
:
<
Icon
type
=
"smile"
/>
...
...
@@ -151,7 +157,7 @@ function Chatbot() {
<
List
.
Item
.
Meta
avatar
=
{
<
Avatar
icon
=
{
AvatarSrc
}
/>
}
title
=
{
message
.
who
}
description
=
{
renderCards
(
message
.
content
.
payload
.
fields
.
card
.
listValue
.
values
)}
description
=
{
renderCards
(
message
.
content
)}
/
>
<
/List.Item
>
<
/div
>
...
...
client/src/chatbot/sections/card.js
View file @
8a03775
...
...
@@ -4,6 +4,34 @@ import { Card, Icon } from 'antd';
const
{
Meta
}
=
Card
;
function
CardComponent
(
props
)
{
console
.
log
(
props
)
return
(
<
Card
style
=
{{
width
:
300
}}
cover
=
{
<
img
alt
=
{
props
.
cardInfo
.
content
.
description
}
src
=
{
props
.
cardInfo
.
content
.
image
}
/
>
}
actions
=
{[
<
a
target
=
"_blank"
rel
=
"noopener noreferrer"
href
=
{
props
.
cardInfo
.
content
.
link
}
>
<
Icon
type
=
"ellipsis"
key
=
"ellipsis"
/>
<
/a
>
]}
>
<
Meta
title
=
{
props
.
cardInfo
.
content
.
title
}
description
=
{
props
.
cardInfo
.
content
.
description
}
/
>
<
/Card
>
)
}
/*
function CardComponent(props) {
return (
<Card
style={{ width: 300 }}
...
...
@@ -27,5 +55,5 @@ function CardComponent(props) {
)
}
*/
export
default
CardComponent
...
...
Please
register
or
login
to post a comment