Commit de87d1fc by Giang Tran

update status

parent 67d5a8be
......@@ -57,6 +57,11 @@ export const updateLangugeApi = async (body) =>
.then((res) => res)
.catch((err) => err);
export const getDetailUser = async (body) =>
GetData(url.urlGetDetailUser, body)
.then((res) => res)
.catch((err) => err);
export const getNewestVersionInfo = async (body) =>
GetData(url.urlGetNewestVersionInfo, body)
.then((res) => res)
......
......@@ -22,6 +22,7 @@ export default {
urlAddMethodBank: root + 'api/v1/customers/store-payment-method',
urlDeleteMethodBank: root + 'api/v1/customers/delete-payment-method',
urlUpdateMethodBank: root + 'api/v1/customers/update-payment-method',
urlGetDetailUser: root + 'api/v1/customers/detail',
//Home
......
......@@ -6,11 +6,24 @@ import AsyncStorage from '@react-native-community/async-storage';
import KEY from '../assets/AsynStorage';
import {showNotificaton, updateNotification} from '../actions/SnackBarAction';
import {connect} from 'react-redux';
import {saveUserToRedux} from '../actions/users';
import {newScreenInit} from '../actions/ScreenInitAction';
import {getDetailUser} from '../apis/Functions/users';
import {convertScreen} from '../Config/Functions';
const FirebaseNotification = (props) => {
const refetchDataUser = async () => {
const res = await getDetailUser({
id: props.user.uid,
platform: Platform.OS,
});
console.log('res', res.data.data);
if (res.data.code == 200 && res.data.data) {
props.saveUserToRedux(res.data.data);
}
};
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
console.log('Message handled in the background!', remoteMessage);
});
......@@ -26,6 +39,9 @@ const FirebaseNotification = (props) => {
const unsubscribe = messaging().onMessage(async (remoteMessage) => {
console.log('A new FCM message arrived!', remoteMessage.data);
const {action_type, body, title, record_id} = remoteMessage.data;
if (action_type != 'CUSTOMER_NEWS') refetchDataUser();
props.showNotificaton({
title,
content: body,
......@@ -91,7 +107,7 @@ const FirebaseNotification = (props) => {
const mapStateToProps = (state) => {
return {
loadingModal: state.ModalLoadingReducer,
user: state.userReducer,
};
};
......@@ -99,4 +115,5 @@ export default connect(mapStateToProps, {
showNotificaton,
newScreenInit,
updateNotification,
saveUserToRedux,
})(FirebaseNotification);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment