BOD-14 Backend server work + sending of messages WIP for front end

This commit is contained in:
Patrick Fic
2020-03-25 15:50:46 -07:00
parent 5b5ffe21cd
commit 84a5820d8d
32 changed files with 892 additions and 274 deletions

View File

@@ -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);