Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2017110273
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sdy
2021-06-03 13:08:48 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
45fb7188a54c0bd9963cfd14752fa6eb9d233245
45fb7188
1 parent
54ab2a94
create reducers
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
client/src/reducers/index.js
client/src/reducers/reducer_watson.js
client/src/reducers/index.js
0 → 100644
View file @
45fb718
import
{
combineReducers
}
from
"redux"
;
import
watson
from
"./reducer_watson"
;
export
default
combineReducers
({
watson
});
client/src/reducers/reducer_watson.js
0 → 100644
View file @
45fb718
import
{
INPUT_SUCCESS
,
INPUT_FAIL
,
SESSION_SUCCESS
,
SESSION_FAIL
,
MESSAGE_SUCCESS
,
MESSAGE_FAIL
,
}
from
"../actions/types"
;
const
initialState
=
{
messages
:
[],
userMessages
:
[],
botMessages
:
[],
botOptions
:
[]
};
export
default
(
state
=
initialState
,
action
)
=>
{
const
{
type
,
payload
,
botMsg
,
botLabels
}
=
action
;
let
{
messages
,
userMessages
,
botMessages
,
botOptions
}
=
state
;
switch
(
type
)
{
case
INPUT_SUCCESS
:
messages
=
[...
messages
,
{
message
:
payload
,
type
:
"user"
}];
userMessages
=
[...
userMessages
,
{
messages
:
payload
,
type
:
"user"
}];
return
{
...
state
,
messages
,
userMessages
,
};
case
INPUT_FAIL
:
return
{
...
state
,
};
case
SESSION_SUCCESS
:
localStorage
.
setItem
(
"session"
,
payload
[
"session_id"
]);
return
{
...
state
,
};
case
SESSION_FAIL
:
return
{
...
state
,
};
case
MESSAGE_SUCCESS
:
botOptions
=
[...
botOptions
,
{
options
:
botLabels
,
type
:
"bot"
}];
botMessages
=
[...
botMessages
,
{
botMessage
:
botMsg
,
type
:
"bot"
}];
messages
=
[...
messages
,
{
message
:
payload
,
type
:
"bot"
}];
return
{
...
state
,
messages
,
botMessages
,
botOptions
,
};
case
MESSAGE_FAIL
:
return
{
...
state
,
};
default
:
return
{
...
state
,
};
}
};
Please
register
or
login
to post a comment