BOD-14 Backend server work + sending of messages WIP for front end
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { Input } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { sendMessage } from "../../redux/messaging/messaging.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
sendMessage: message => dispatch(sendMessage(message))
|
||||
});
|
||||
|
||||
function ChatSendMessageComponent({ conversation, bodyshop, sendMessage }) {
|
||||
const [message, setMessage] = useState("");
|
||||
const { t } = useTranslation();
|
||||
console.log("message", message);
|
||||
|
||||
const handleEnter = () => {
|
||||
console.log("Sending that message ");
|
||||
sendMessage({
|
||||
to: conversation.phone,
|
||||
body: message,
|
||||
messagingServiceSid: bodyshop.messagingservicesid
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ display: "flex " }}>
|
||||
<Input.TextArea
|
||||
allowClear
|
||||
autoSize={{ minRows: 1, maxRows: 4 }}
|
||||
placeholder={t("messaging.labels.typeamessage")}
|
||||
// enterButton={}
|
||||
onChange={e => setMessage(e.target.value)}
|
||||
onPressEnter={event => {
|
||||
if (!!!event.shiftKey) handleEnter();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(ChatSendMessageComponent);
|
||||
Reference in New Issue
Block a user