Commit de87d1fc by Giang Tran

update status

parent 67d5a8be
...@@ -57,6 +57,11 @@ export const updateLangugeApi = async (body) => ...@@ -57,6 +57,11 @@ export const updateLangugeApi = async (body) =>
.then((res) => res) .then((res) => res)
.catch((err) => err); .catch((err) => err);
export const getDetailUser = async (body) =>
GetData(url.urlGetDetailUser, body)
.then((res) => res)
.catch((err) => err);
export const getNewestVersionInfo = async (body) => export const getNewestVersionInfo = async (body) =>
GetData(url.urlGetNewestVersionInfo, body) GetData(url.urlGetNewestVersionInfo, body)
.then((res) => res) .then((res) => res)
......
...@@ -22,6 +22,7 @@ export default { ...@@ -22,6 +22,7 @@ export default {
urlAddMethodBank: root + 'api/v1/customers/store-payment-method', urlAddMethodBank: root + 'api/v1/customers/store-payment-method',
urlDeleteMethodBank: root + 'api/v1/customers/delete-payment-method', urlDeleteMethodBank: root + 'api/v1/customers/delete-payment-method',
urlUpdateMethodBank: root + 'api/v1/customers/update-payment-method', urlUpdateMethodBank: root + 'api/v1/customers/update-payment-method',
urlGetDetailUser: root + 'api/v1/customers/detail', urlGetDetailUser: root + 'api/v1/customers/detail',
//Home //Home
......
...@@ -6,11 +6,24 @@ import AsyncStorage from '@react-native-community/async-storage'; ...@@ -6,11 +6,24 @@ import AsyncStorage from '@react-native-community/async-storage';
import KEY from '../assets/AsynStorage'; import KEY from '../assets/AsynStorage';
import {showNotificaton, updateNotification} from '../actions/SnackBarAction'; import {showNotificaton, updateNotification} from '../actions/SnackBarAction';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {saveUserToRedux} from '../actions/users';
import {newScreenInit} from '../actions/ScreenInitAction'; import {newScreenInit} from '../actions/ScreenInitAction';
import {getDetailUser} from '../apis/Functions/users';
import {convertScreen} from '../Config/Functions'; import {convertScreen} from '../Config/Functions';
const FirebaseNotification = (props) => { 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) => { messaging().setBackgroundMessageHandler(async (remoteMessage) => {
console.log('Message handled in the background!', remoteMessage); console.log('Message handled in the background!', remoteMessage);
}); });
...@@ -26,6 +39,9 @@ const FirebaseNotification = (props) => { ...@@ -26,6 +39,9 @@ const FirebaseNotification = (props) => {
const unsubscribe = messaging().onMessage(async (remoteMessage) => { const unsubscribe = messaging().onMessage(async (remoteMessage) => {
console.log('A new FCM message arrived!', remoteMessage.data); console.log('A new FCM message arrived!', remoteMessage.data);
const {action_type, body, title, record_id} = remoteMessage.data; const {action_type, body, title, record_id} = remoteMessage.data;
if (action_type != 'CUSTOMER_NEWS') refetchDataUser();
props.showNotificaton({ props.showNotificaton({
title, title,
content: body, content: body,
...@@ -91,7 +107,7 @@ const FirebaseNotification = (props) => { ...@@ -91,7 +107,7 @@ const FirebaseNotification = (props) => {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
loadingModal: state.ModalLoadingReducer, user: state.userReducer,
}; };
}; };
...@@ -99,4 +115,5 @@ export default connect(mapStateToProps, { ...@@ -99,4 +115,5 @@ export default connect(mapStateToProps, {
showNotificaton, showNotificaton,
newScreenInit, newScreenInit,
updateNotification, updateNotification,
saveUserToRedux,
})(FirebaseNotification); })(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