Commit c5c28737 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

Merge branch 'master' of ssh://repo.cs.co.id:2222/wahyu/bahanoprek

# Conflicts:
#	view/Home.js
parents ea61e16d 35cc650c
...@@ -65,11 +65,11 @@ export default function App() { ...@@ -65,11 +65,11 @@ export default function App() {
if (data.action_type == 'Rewards') { if (data.action_type == 'Rewards') {
RootNavigation.navigate('Reward Detail', { rewardId: data.data_id }); RootNavigation.navigate('Reward Detail', { rewardId: data.data_id });
} else if (data.action_type == 'Inbox') { } else if (data.action_type == 'Inbox') {
RootNavigation.navigate('Inbox Detail', { idInbox: data.data_id });
} else if (data.action_type == 'Transaction') { } else if (data.action_type == 'Transaction') {
RootNavigation.navigate('Order Detail', {idTrans:data.data_id}); RootNavigation.navigate('Order Detail', { idTrans: data.data_id });
} else if (data.action_type == 'Review') { } else if (data.action_type == 'Review') {
RootNavigation.navigate('RatingOrder', {idTrans:data.data_id}); RootNavigation.navigate('RatingOrder', { idTrans: data.data_id });
} else if (data.action_type == 'WebView') { } else if (data.action_type == 'WebView') {
} else if (data.action_type == 'Transfer Receive') { } else if (data.action_type == 'Transfer Receive') {
...@@ -106,7 +106,7 @@ export default function App() { ...@@ -106,7 +106,7 @@ export default function App() {
{ cancelable: false }, { cancelable: false },
) )
} }
} }
......
...@@ -678,7 +678,7 @@ class Auth extends React.Component { ...@@ -678,7 +678,7 @@ class Auth extends React.Component {
})} /> })} />
<Stack.Screen name="Inbox List" component={InboxList} <Stack.Screen name="Inbox List" component={InboxList}
options={{ options={({ navigation }) => ({
headerStyle: { backgroundColor: "#CFB368" }, headerStyle: { backgroundColor: "#CFB368" },
headerBackTitleStyle: { color: 'white' }, headerBackTitleStyle: { color: 'white' },
headerTintColor: '#fff', headerTintColor: '#fff',
...@@ -688,8 +688,9 @@ class Auth extends React.Component { ...@@ -688,8 +688,9 @@ class Auth extends React.Component {
color: 'white', color: 'white',
fontSize: 20, fontSize: 20,
}, },
title: i18n.t('headerInboxList') title: i18n.t('headerInboxList'),
}} /> headerLeft: props => <HeaderBackButton {...props} onPress={() => navigation.navigate('Home', { screen: 'HOME' })} />
})} />
<Stack.Screen name="Inbox Detail" component={InboxDetail} options={{ headerShown: false }} /> <Stack.Screen name="Inbox Detail" component={InboxDetail} options={{ headerShown: false }} />
......
...@@ -14,7 +14,7 @@ import CheckVersion from '../function/CheckVersion'; ...@@ -14,7 +14,7 @@ import CheckVersion from '../function/CheckVersion';
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import Toast from 'react-native-tiny-toast'; import Toast from 'react-native-tiny-toast';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
// import { StatusBar } from 'expo-status-bar'; import { Badge } from 'react-native-elements'
let version = info.expo.version let version = info.expo.version
let buildNumber = info.expo.android.versionCode let buildNumber = info.expo.android.versionCode
...@@ -35,11 +35,13 @@ class Home extends React.Component { ...@@ -35,11 +35,13 @@ class Home extends React.Component {
indicatorProfileCard: true, indicatorProfileCard: true,
slider_height: 350, slider_height: 350,
slugs: [], slugs: [],
placeholder: true placeholder: true,
inbox: "0"
} }
} }
componentDidMount() { componentDidMount() {
this.CheckInbox()
console.log("INI BASE_URL : " + this.props.BASE_URL) console.log("INI BASE_URL : " + this.props.BASE_URL)
const screenWidth = Math.round(Dimensions.get('window').width); const screenWidth = Math.round(Dimensions.get('window').width);
this.setState({ this.setState({
...@@ -58,6 +60,7 @@ class Home extends React.Component { ...@@ -58,6 +60,7 @@ class Home extends React.Component {
this._renderCarousell() this._renderCarousell()
this._unsubscribe = this.props.navigation.addListener('focus', () => { this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.CheckInbox()
this.setState({ this.setState({
indicator: true, indicator: true,
indicatorProfileCard: true indicatorProfileCard: true
...@@ -76,6 +79,24 @@ class Home extends React.Component { ...@@ -76,6 +79,24 @@ class Home extends React.Component {
}); });
} }
CheckInbox() {
let params = {
session_id: this.props.session_id
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/inbox/unread_count', params).then(respon => {
let res = respon.data.unread_count
this.setState({
inbox: res.toString()
})
}).catch(error => {
let response = error.response.data;
// console.log(response.msg)
Alert.alert('', response.msg);
})
}
componentWillUnmount() { componentWillUnmount() {
this._unsubscribe(); this._unsubscribe();
} }
...@@ -117,7 +138,7 @@ class Home extends React.Component { ...@@ -117,7 +138,7 @@ class Home extends React.Component {
this._getOutletClosest(); this._getOutletClosest();
} }
_renderCarousell() { _renderCarousell() {
Axios.get(this.props.BASE_URL+'cms/v2/list/promotions-carousel').then(respon => { Axios.get(this.props.BASE_URL + 'cms/v2/list/promotions-carousel').then(respon => {
const dataCarousell = respon.data.contents; const dataCarousell = respon.data.contents;
let imageLink = [] let imageLink = []
let slugs = [] let slugs = []
...@@ -145,7 +166,7 @@ class Home extends React.Component { ...@@ -145,7 +166,7 @@ class Home extends React.Component {
session_id: this.props.session_id, session_id: this.props.session_id,
} }
// console.log(params); // console.log(params);
Axios.post(this.props.BASE_URL+'crm/v2/member/get_profile', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/member/get_profile', params).then(res => {
const dataCard = res.data const dataCard = res.data
let point = dataCard.kaspro_point let point = dataCard.kaspro_point
...@@ -174,7 +195,7 @@ class Home extends React.Component { ...@@ -174,7 +195,7 @@ class Home extends React.Component {
long: this.state.my_long long: this.state.my_long
} }
// console.log(params); // console.log(params);
Axios.post(this.props.BASE_URL+'crm/v2/outlet/get_closest', params).then(res => { Axios.post(this.props.BASE_URL + 'crm/v2/outlet/get_closest', params).then(res => {
// console.log(res.data.data) // console.log(res.data.data)
let outletId = res.data.data.outlet_id let outletId = res.data.data.outlet_id
...@@ -241,6 +262,14 @@ class Home extends React.Component { ...@@ -241,6 +262,14 @@ class Home extends React.Component {
<View style={{ margin: 15, flex: 0.15, alignItems: 'flex-end' }}> <View style={{ margin: 15, flex: 0.15, alignItems: 'flex-end' }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Inbox List')}> <TouchableOpacity onPress={() => this.props.navigation.navigate('Inbox List')}>
<SimpleLineIcons name="bell" size={24} color="white" /> <SimpleLineIcons name="bell" size={24} color="white" />
{
this.state.inbox == '0' ? (
null
) : (
<Badge value={this.state.inbox} status="error" containerStyle={{ position: 'absolute', top: -4, right: -4 }} />
)
}
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</View> </View>
...@@ -348,8 +377,8 @@ class Home extends React.Component { ...@@ -348,8 +377,8 @@ class Home extends React.Component {
{i18n.t('orderInfo')} {i18n.t('orderInfo')}
</Text> */} </Text> */}
<Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: '#838383' }}> <Text style={{ textAlign: 'center', fontSize: 12, fontFamily: 'Gotham-Black', color: '#838383' }}>
{i18n.t('deliveryinfo')} {i18n.t('deliveryinfo')}
</Text> </Text>
{this.state.indicator == true ? ( {this.state.indicator == true ? (
<ActivityIndicator size="small" color="#c9af6d" /> <ActivityIndicator size="small" color="#c9af6d" />
) : ( ) : (
......
import React from 'react'; import React from 'react';
import { View, Text, StyleSheet, Alert} from 'react-native'; import { View, Text, StyleSheet, Alert, BackHandler } from 'react-native';
import { Image } from 'react-native-elements'; import { Image } from 'react-native-elements';
import Axios from 'axios'; import Axios from 'axios';
import { TouchableOpacity, ScrollView } from 'react-native-gesture-handler'; import { TouchableOpacity, ScrollView } from 'react-native-gesture-handler';
...@@ -12,6 +12,7 @@ import Toast from 'react-native-tiny-toast'; ...@@ -12,6 +12,7 @@ import Toast from 'react-native-tiny-toast';
class InboxDetail extends React.Component { class InboxDetail extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.handleBackButtonClick = this.handleBackButtonClick.bind(this)
this.state = { this.state = {
title: '', title: '',
subtitle: '', subtitle: '',
...@@ -23,9 +24,19 @@ class InboxDetail extends React.Component { ...@@ -23,9 +24,19 @@ class InboxDetail extends React.Component {
} }
componentDidMount() { componentDidMount() {
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
this.getInboxDetail() this.getInboxDetail()
} }
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
}
handleBackButtonClick() {
this.props.navigation.navigate('Inbox List');
return true;
}
getInboxDetail() { getInboxDetail() {
let params = { let params = {
session_id: this.props.session_id, session_id: this.props.session_id,
...@@ -57,7 +68,7 @@ class InboxDetail extends React.Component { ...@@ -57,7 +68,7 @@ class InboxDetail extends React.Component {
}) })
} }
handleDeleteInbox(){ handleDeleteInbox() {
Alert.alert( Alert.alert(
"", "",
"Are you sure want to delete this message ?", "Are you sure want to delete this message ?",
...@@ -105,7 +116,7 @@ class InboxDetail extends React.Component { ...@@ -105,7 +116,7 @@ class InboxDetail extends React.Component {
<View style={styles.container}> <View style={styles.container}>
<View style={styles.header}> <View style={styles.header}>
<View style={{ margin: 15, flex: 0.1, alignItems: 'flex-start' }}> <View style={{ margin: 15, flex: 0.1, alignItems: 'flex-start' }}>
<TouchableOpacity onPress={() => this.props.navigation.goBack()}> <TouchableOpacity onPress={() => this.props.navigation.navigate('Inbox List')}>
<AntDesign name="arrowleft" size={22} color="white" /> <AntDesign name="arrowleft" size={22} color="white" />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
......
import React from 'react'; import React from 'react';
import { View, Text, TextInput, StyleSheet, ScrollView, Alert, TouchableOpacity, ActivityIndicator } from 'react-native'; import { View, Text, BackHandler, StyleSheet, ScrollView, Alert, TouchableOpacity, ActivityIndicator } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Axios from 'axios'; import Axios from 'axios';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
...@@ -10,6 +10,7 @@ class InboxList extends React.Component { ...@@ -10,6 +10,7 @@ class InboxList extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.handleBackButtonClick = this.handleBackButtonClick.bind(this)
this.state = { this.state = {
inbox_list: [], inbox_list: [],
indicator: true indicator: true
...@@ -17,6 +18,7 @@ class InboxList extends React.Component { ...@@ -17,6 +18,7 @@ class InboxList extends React.Component {
} }
componentDidMount() { componentDidMount() {
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
this.getInbox() this.getInbox()
this._unsubscribe = this.props.navigation.addListener('focus', () => { this._unsubscribe = this.props.navigation.addListener('focus', () => {
...@@ -28,9 +30,15 @@ class InboxList extends React.Component { ...@@ -28,9 +30,15 @@ class InboxList extends React.Component {
} }
componentWillUnmount() { componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
this._unsubscribe() this._unsubscribe()
} }
handleBackButtonClick() {
this.props.navigation.navigate('Home', { screen: 'HOME' })
return true;
}
getInbox() { getInbox() {
let params = { let params = {
session_id: this.props.session_id session_id: this.props.session_id
...@@ -61,17 +69,32 @@ class InboxList extends React.Component { ...@@ -61,17 +69,32 @@ class InboxList extends React.Component {
this.state.indicator ? (<ActivityIndicator style={{ justifyContent: "center", marginTop: 100 }} size="large" color="#c9af6d" />) : this.state.indicator ? (<ActivityIndicator style={{ justifyContent: "center", marginTop: 100 }} size="large" color="#c9af6d" />) :
this.state.inbox_list.length ? ( this.state.inbox_list.length ? (
this.state.inbox_list.map((item, key) => ( this.state.inbox_list.map((item, key) => (
<TouchableOpacity key={key} onPress={() => this.props.navigation.navigate('Inbox Detail', { idInbox: item.id })}> item.read !== 0 ? (
<View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between', borderBottomWidth: 1, borderColor: '#838383', padding: 15 }} key={key}> <TouchableOpacity key={key} onPress={() => this.props.navigation.navigate('Inbox Detail', { idInbox: item.id })}>
<View style={{ flex: 0.7 }}> <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between', borderBottomWidth: 1, borderColor: '#838383', padding: 15 }} key={key}>
<Text style={{ textAlign: 'left', fontSize: 18, fontFamily: 'Gotham-Black', color: 'grey' }}>{item.message.title}</Text> <View style={{ flex: 0.7 }}>
<Text style={{ textAlign: 'left', fontSize: 14, fontFamily: 'Gotham-Black', color: 'grey' }}>{item.message.subtitle}</Text> <Text style={{ textAlign: 'left', fontSize: 18, fontFamily: 'Gotham-Light', color: 'grey' }}>{item.message.title}</Text>
<Text style={{ textAlign: 'left', fontSize: 14, fontFamily: 'Gotham-Light', color: 'grey' }}>{item.message.subtitle}</Text>
</View>
<View style={{ flex: 0.3, justifyContent: 'center', alignItems: 'flex-end' }}>
<Text style={{ fontFamily: 'Gotham-Light', color: 'grey', fontSize: 18 }}>{moment(item.sent_time).format("DD MMM")}</Text>
</View>
</View> </View>
<View style={{ flex: 0.3, justifyContent:'center', alignItems:'flex-end' }}> </TouchableOpacity>
<Text style={{ fontFamily: 'Gotham-Black', color: 'grey', fontSize: 18}}>{moment(item.sent_time).format("DD MMM")}</Text> ) : (
</View> <TouchableOpacity key={key} onPress={() => this.props.navigation.navigate('Inbox Detail', { idInbox: item.id })}>
</View> <View style={{ flex: 1, flexDirection: 'row', justifyContent: 'space-between', borderBottomWidth: 1, borderColor: '#838383', padding: 15 }} key={key}>
</TouchableOpacity> <View style={{ flex: 0.7 }}>
<Text style={{ textAlign: 'left', fontSize: 18, fontFamily: 'Gotham-Black', color: 'grey' }}>{item.message.title}</Text>
<Text style={{ textAlign: 'left', fontSize: 14, fontFamily: 'Gotham-Black', color: 'grey' }}>{item.message.subtitle}</Text>
</View>
<View style={{ flex: 0.3, justifyContent: 'center', alignItems: 'flex-end' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'grey', fontSize: 18 }}>{moment(item.sent_time).format("DD MMM")}</Text>
</View>
</View>
</TouchableOpacity>
)
)) ))
) : ( ) : (
<View style={{ justifyContent: 'center', alignItems: 'center', marginTop: 100 }}> <View style={{ justifyContent: 'center', alignItems: 'center', marginTop: 100 }}>
......
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