Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onchange event #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dev/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ export default class App extends Component {
addResponseMessage(newMessage);
}

handleOnChangeMessage = (event) => {
event.preventDefault();
console.log(event.target.value);
}

render() {
return (
<Widget
title="Bienvenido"
subtitle="Asistente virtual"
senderPlaceHolder="Escribe aquí ..."
handleNewUserMessage={this.handleNewUserMessage}
handleOnChangeMessage={this.handleOnChangeMessage}
badge={1}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import send from '@assets/send_button.svg';

import './style.scss';

const Sender = ({ sendMessage, placeholder, disabledInput, autofocus }) =>
const Sender = ({ sendMessage, placeholder, disabledInput, autofocus, handleOnChangeMessage }) =>
<form className="rcw-sender" onSubmit={sendMessage}>
<input type="text" className="rcw-new-message" name="message" placeholder={placeholder} disabled={disabledInput} autoFocus={autofocus} autoComplete="off" />
<input onChange={handleOnChangeMessage} type="text" className="rcw-new-message" name="message" placeholder={placeholder} disabled={disabledInput} autoFocus={autofocus} autoComplete="off" />
<button type="submit" className="rcw-send">
<img src={send} className="rcw-send-icon" alt="send" />
</button>
</form>;

Sender.propTypes = {
sendMessage: PropTypes.func,
handleOnChangeMessage: PropTypes.func,
placeholder: PropTypes.string,
disabledInput: PropTypes.bool,
autofocus: PropTypes.bool
Expand Down
4 changes: 3 additions & 1 deletion src/components/Widget/components/Conversation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Conversation = props =>
profileAvatar={props.profileAvatar}
/>
<Sender
handleOnChangeMessage={props.handleOnChangeMessage}
sendMessage={props.sendMessage}
placeholder={props.senderPlaceHolder}
disabledInput={props.disabledInput}
Expand All @@ -36,7 +37,8 @@ Conversation.propTypes = {
toggleChat: PropTypes.func,
showCloseButton: PropTypes.bool,
disabledInput: PropTypes.bool,
autofocus: PropTypes.bool
autofocus: PropTypes.bool,
handleOnChangeMessage: PropTypes.func,
};

export default Conversation;
4 changes: 3 additions & 1 deletion src/components/Widget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Widget extends Component {
badge={this.props.badge}
autofocus={this.props.autofocus}
customLauncher={this.props.customLauncher}
handleOnChangeMessage={this.props.handleOnChangeMessage}
/>
);
}
Expand All @@ -59,7 +60,8 @@ Widget.propTypes = {
fullScreenMode: PropTypes.bool,
badge: PropTypes.number,
autofocus: PropTypes.bool,
customLauncher: PropTypes.func
customLauncher: PropTypes.func,
handleOnChangeMessage: PropTypes.func
};

export default connect()(Widget);
4 changes: 3 additions & 1 deletion src/components/Widget/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const WidgetLayout = props => (
disabledInput={props.disabledInput}
autofocus={props.autofocus}
titleAvatar={props.titleAvatar}
handleOnChangeMessage={props.handleOnChangeMessage}
/>
}
{props.customLauncher ?
Expand Down Expand Up @@ -52,7 +53,8 @@ WidgetLayout.propTypes = {
fullScreenMode: PropTypes.bool,
badge: PropTypes.number,
autofocus: PropTypes.bool,
customLauncher: PropTypes.func
customLauncher: PropTypes.func,
handleOnChangeMessage: PropTypes.func,
};

export default connect(store => ({
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ConnectedWidget = props =>
badge={props.badge}
autofocus={props.autofocus}
customLauncher={props.launcher}
handleOnChangeMessage={props.handleOnChangeMessage}
/>
</Provider>;

Expand All @@ -33,7 +34,8 @@ ConnectedWidget.propTypes = {
fullScreenMode: PropTypes.bool,
badge: PropTypes.number,
autofocus: PropTypes.bool,
launcher: PropTypes.func
launcher: PropTypes.func,
handleOnChangeMessage: PropTypes.func,
};

ConnectedWidget.defaultProps = {
Expand Down