searchReceiver = () => {
const {navigate, params} = this.props;
this.props.AuthStore.getToken();
const token = (this.props.AuthStore.appState !== null) ? this.props.AuthStore.appState.user.access_token : null;
RestClient.postRequest(AppUrl.search_receiver, {
receiver_id: parseInt(params.id)
}, {
headers: {
"Authorization": "Bearer "+token
}
}).then((res) => {
const result = res.data;
console.log(result);
if (result.success === false) {
Notification.error(result);
navigate("/");
} else {
const newForm = {
...this.state.form,
message_id: result.data.message_id
}
this.setState({
isLoading : false,
receiver_info: result.data.receiver_info,
form: newForm
}, () => {
// SOCKET KISMINDA KULLANICILAR DIZISINE KAYDEDELİM
this.socket.emit("add_user", {
"sender_id": this.state.form.sender_id,
"message_id": this.state.form.message_id
});
this.getMessages();
this.messageRead(this.state.form.message_id);
});
}
}).catch((err) => {
console.log(err);
Notification.error({
title: "Başarısız",
message: "Bir Hata Oluştu.Lütfen Daha Sonra Tekrar Deneyiniz."
});
navigate("/");
})
}