Skip to content

Commit

Permalink
Merge pull request #270 from GTBitsOfGood/266-pmt-mapscout-feedback-t…
Browse files Browse the repository at this point in the history
…o-slack

Send feedback to slack channel
  • Loading branch information
avayedawadi authored Mar 30, 2024
2 parents d888641 + 3a06010 commit fb403bd
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/components/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,29 @@ import { chatRef } from '../../store';
import Discussion from './Discussion';
import { updateNewChat as Update } from '../../functions/reduxActions';

async function sendSlackMessage(email, message) {
const data = {
email: (email + "; Feedback: " + message),
};

const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data)

};
console.log(requestOptions);
fetch("https://bit-bot-five.vercel.app/bog/mapscout", requestOptions)
}

function Chat({ firebase, newChat, updateNewChat }) {
const [message, setMessage] = useState('');
const addToDo = async (newToDo) => {
chatRef.push().set(newToDo);
};

useEffect(() => {
if (newChat) {
updateNewChat(false);
}
}, [newChat, updateNewChat]);

const inputChange = (e) => {
setMessage(e.target.value);
};
Expand All @@ -35,6 +46,7 @@ function Chat({ firebase, newChat, updateNewChat }) {
uid: firebase.auth.uid,
username: firebase.auth.email,
}).then(() => setMessage(''));
sendSlackMessage(firebase.auth.email, message);
}
};

Expand Down

0 comments on commit fb403bd

Please sign in to comment.