@@ -113,7 +113,7 @@ export default class RewardDetailScreen extends Component {
bounces={true}
// dataDetectorTypes={['link', 'phoneNumber']}
originWhitelist={['*']}
- source={{ baseUrl: '', html: ` ${this.state.product.style} `+this.state.product.description+'
' }}
+ source={{ baseUrl: '', html: ` ${this.state.product && this.state.product.style ? this.state.product.style : '' } ${this.state.product && this.state.product.description ? this.state.product.description : ''}
` }}
injectedJavaScript={injectScript}
onMessage={this.onMessage}
/>
diff --git a/src/screens/room/CustomDatePicker.js b/src/screens/room/CustomDatePicker.js
index f4dcf7a..ef35295 100644
--- a/src/screens/room/CustomDatePicker.js
+++ b/src/screens/room/CustomDatePicker.js
@@ -1,9 +1,9 @@
import React, { Component } from 'react';
-import { View, TouchableOpacity } from 'react-native';
+import { View, TouchableOpacity, Appearance } from 'react-native';
import Text from '../../components/Text';
import DateTimePicker from "react-native-modal-datetime-picker";
import Icon from 'src/components/Icon'
-import { Appearance } from 'react-native-appearance';
+// import { Appearance } from 'react-native-appearance';
import { t } from '../../utils/i18n'
const colorScheme = Appearance.getColorScheme();
diff --git a/src/screens/room/RoomDetail.js b/src/screens/room/RoomDetail.js
index a12adf0..c641023 100644
--- a/src/screens/room/RoomDetail.js
+++ b/src/screens/room/RoomDetail.js
@@ -203,7 +203,7 @@ class RoomDetailScreen extends Component {
originWhitelist={['*']}
source={{
baseUrl: '',
- html: `` + this.state.room_detail.detail + '
'
+ html: ` ${this.state.room_detail.detail}
`
}}
injectedJavaScript={injectScript}
diff --git a/src/screens/service/QuestionScreen.js b/src/screens/service/QuestionScreen.js
index 096c268..16f1955 100644
--- a/src/screens/service/QuestionScreen.js
+++ b/src/screens/service/QuestionScreen.js
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
-import { View, TouchableOpacity, KeyboardAvoidingView, FlatList, StyleSheet, TextInput, Alert , Image } from 'react-native';
+import {View, TouchableOpacity, KeyboardAvoidingView, FlatList, StyleSheet, TextInput, Alert, Image, Platform, Keyboard} from 'react-native';
import Text from '../../components/Text';
import moment from "moment";
import Color from '../../../src/color';
@@ -7,6 +7,7 @@ import {Button} from "native-base";
import {getConversation, postConversation} from '../../api/UserApi';
import IndicatorLoading from '../../components/IndicatorLoading';
import { t } from '../../utils/i18n';
+import ImageView from 'react-native-image-view';
// import 'moment/locale/th';
//moment.locale('th');
@@ -16,20 +17,42 @@ export default class QuestionScreen extends Component {
this.state = {
isLoading: false,
message_list:[],
- text_input:''
+ text_input:'',
+ isSending: false,
+ keyboardAndroidOffset: 0,
+ isImageViewVisible: false,
+ media_url: null
};
this.sendQuestion = this.sendQuestion.bind(this)
this.getMessageList = this.getMessageList.bind(this)
}
+ componentWillUnmount = () => {
+ if(this.props && this.props.navigation && this.props.navigation.state && this.props.navigation.state.params && this.props.navigation.state.params.getNotification){
+ this.props.navigation.state.params.getNotification()
+ }
+ }
+
componentDidMount = () => {
this.props.navigation.setParams({onRefreshMessage: this.getMessageList})
this.getMessageList()
+ // Keyboard.addListener('keyboardDidShow', this._keyboardDidShow)
};
- getMessageList(){
+ componentWillUnmount() {
+ if(this.props && this.props.navigation && this.props.navigation.state && this.props.navigation.state.params && this.props.navigation.state.params.getNotification){
+ this.props.navigation.state.params.getNotification()
+ }
+ }
+ /*_keyboardDidShow = (e) => {
this.setState({
- isLoading: true
+ keyboardAndroidOffset: parseInt(e.endCoordinates.height)
+ })
+ };*/
+
+ getMessageList(loading = true){
+ this.setState({
+ isLoading: loading
})
getConversation()
.then(res => {
@@ -43,54 +66,81 @@ export default class QuestionScreen extends Component {
}
this.setState({
- isLoading: false
+ isLoading: false,
})
})
}
sendQuestion(){
- this.setState({
- isLoading: true
- })
- let param = {
- message: this.state.text_input
- }
- postConversation(param)
- .then(res => {
- if(res.ok){
- Alert.alert('รับคำถามเรียบร้อย', 'ทางเราได้รับคำถามของคุณแล้ว ขอบคุณค่ะ',[{text: t('ok'), onPress: () => this.getMessageList()}])
- this.setState({
- text_input: ''
- })
- }else{
- Alert.alert('เกิดข้อผิดพลาด', 'กรุณาลองอีกครั้ง')
- }
+ if(this.state.text_input !== ''){
this.setState({
- isLoading: false
+ // isLoading: true
+ isSending: true
+ }, () => {
+ let param = {
+ message: this.state.text_input
+ }
+ postConversation(param)
+ .then(res => {
+ if(res.ok){
+ // Alert.alert('รับคำถามเรียบร้อย', 'ทางเราได้รับคำถามของคุณแล้ว ขอบคุณค่ะ',[{text: t('ok'), onPress: () => this.getMessageList()}])
+ this.setState({
+ text_input: ''
+ }, () => {
+ this.getMessageList(false)
+ let _this = this;
+ setTimeout(function () {
+ _this.setState({
+ isSending: false
+ })
+ }, 1000)
+ })
+ }else{
+ Alert.alert('เกิดข้อผิดพลาด', 'กรุณาลองอีกครั้ง')
+ this.setState({
+ isSending: false
+ })
+ }
+
+ console.log('check data ============== ',res);
+ })
+
})
- console.log('check data ============== ',res);
- })
+ }
+
}
_keyExtractor = (item, index) => 'nessage_item_'+index;
_renderItem = ({item}) => (
-
-
- {item.sender_type == 'admin' ? t('project') : t('me')}
- {moment(item.created_at).format('DD MMMM YYYY, HH:mmน.')}
-
- {item.content}
- {item.media != null ? : null}
+
+ {moment(item.created_at).format('DD MMMM YYYY, HH:mmน.')}
+ {item.sender_type == 'admin' ? t('project') : t('me')}
+ {item.content}
+ {
+ item.media != null ?
+ {this.setState({isImageViewVisible: true, media_url: item.media.url})}}>
+
+
+ : null
+ }
);
render() {
return (
- {
- this.scrollView = view;
- }}>
+ {this.scrollView = view;}}
+ >
+ {this.setState({isImageViewVisible: false, media_url: null})}}
+ />
this._flatlistRef = c}
data={this.state.message_list}
@@ -109,7 +159,7 @@ export default class QuestionScreen extends Component {
}}
style={{}}/>
-
+
this.setState({text_input: text})}/>
-
diff --git a/src/screens/service/Service.js b/src/screens/service/Service.js
index 81857b4..07f7f74 100644
--- a/src/screens/service/Service.js
+++ b/src/screens/service/Service.js
@@ -14,7 +14,7 @@ import {connect} from 'react-redux'
import {clearToken} from "../../api/api";
import DeviceInfo from 'react-native-device-info';
import { t } from 'src/utils/i18n'
-import {getUserProfile} from "../../api/UserApi";
+import {getUserProfile, logout} from "../../api/UserApi";
const buildVersion = DeviceInfo.getVersion()
const buildNumber = DeviceInfo.getBuildNumber()
@@ -44,14 +44,17 @@ class ServiceScreen extends Component {
fb_is_link: false,
user: {
point: 0
- }
+ },
+ profileImage : require('../../../assets/images/praw.png')
}
}
componentDidMount() {
- this.onLoad()
+ if (this.props.token != null && this.props.user != null) {
+ this.onLoad()
+ this.getUserData()
+ }
this.initData()
- this.getUserData()
}
onLoad = () => {
@@ -76,27 +79,46 @@ class ServiceScreen extends Component {
}
_logout() {
- clearToken()
- this.props.appCleanUser()
- this.props.appCleanToken()
- this.props.appCleanProjectID()
- this.setState({
- auth: false
- })
- this.props.navigation.navigate('HomeScreen',{isLogin:true})
+ logout()
+ .then(res => {
+ console.log('response >>> ', res.data);
+ if(res.data && res.data.status === 'success'){
+ clearToken();
+
+ setTimeout(() => {
+ this.props.appCleanUser();
+ this.props.appCleanToken();
+ this.props.appCleanProjectID();
+ this.setState({
+ auth: false
+ }, () => {
+ this.props.navigation.navigate('HomeScreen',{isLogin:true})
+ })
+ }, 500)
+ }else {
+ Alert.alert('Logout unsuccessfully');
+ }
+ })
+
}
getUserData(){
getUserProfile()
.then(res => {
if(res.ok){
+ let image = require('../../../assets/images/praw.png')
+ if (res.data.user && res.data.user.image){
+ image = {
+ uri: res.data.user.image.url
+ }
+ }
console.log('Service: getUserData:')
- console.log(res.data.user)
+ console.log('Service: ---- >',res.data.user)
this.state.user = res.data.user
- this.state.fb_is_link = res.data.user.fb_is_link
- // this.setState({
- // user: res.data.user,
- // })
+ this.state.fb_is_link = (res.data.user.fb_is_link === null || !res.data.user.fb_is_link) ? false : res.data.fb_is_link
+ this.setState({
+ profileImage: image,
+ })
}
})
}
@@ -119,7 +141,7 @@ class ServiceScreen extends Component {
{this.state.auth == true ?
-
+
@@ -151,7 +173,9 @@ class ServiceScreen extends Component {
}
{
this.props.token != null &&
- this.props.navigation.navigate('Object')}/>
+ this.props.navigation.navigate('Object',{
+ user:this.props.user
+ })}/>
}
{
this.props.token != null &&
diff --git a/src/screens/service/SettingNotification.js b/src/screens/service/SettingNotification.js
index 05977b4..0f62cd8 100644
--- a/src/screens/service/SettingNotification.js
+++ b/src/screens/service/SettingNotification.js
@@ -9,6 +9,7 @@ import { bindActionCreators } from 'redux'
import { appCleanToken, appCleanUser } from '../../redux/app/action'
import { connect } from 'react-redux'
import { getSubscription, postSubscription } from "../../api/UserApi";
+import { t } from '../../utils/i18n';
class SettingsNotificationScreen extends Component {
diff --git a/src/screens/service/Suggestion.js b/src/screens/service/Suggestion.js
index afc037d..64d5ce4 100644
--- a/src/screens/service/Suggestion.js
+++ b/src/screens/service/Suggestion.js
@@ -12,7 +12,7 @@ import ImagePicker from 'react-native-image-crop-picker'
import {postSuggestion, postSuggestionLogin} from '../../api/UserApi';
import { connect } from "react-redux";
import { t } from 'src/utils/i18n'
-
+import IndicatorLoading from '../../components/IndicatorLoading';
let ACTIONSHEET_BUTTONS = [
'ถ่ายรูป',
'รูปจากแกลอรี่',
@@ -29,7 +29,9 @@ class SuggestionScreen extends Component {
suggestionText: null,
image_list: [],
isShowAddBtn: true,
- image_selected: {}
+ image_selected: {},
+ isLoading: false,
+ suggestionTitle: null
};
this.onImagePick = this.onImagePick.bind(this)
this.onTakeCamera = this.onTakeCamera.bind(this)
@@ -37,27 +39,50 @@ class SuggestionScreen extends Component {
}
sendDataSuggestion() {
- let param = {
- message: this.state.suggestionText,
- image: this.state.image_selected
- }
- console.log("param",param);
- if(this.props.user == null && param.message != null){
- postSuggestion(param)
- .then(res => {
- console.log('check response suggestion -----------> ',res)
- Alert.alert('รับข้อเสนอแนะเรียบร้อย', 'ทางเราได้รับคำแนะนำและเรื่องไว้พิจารณาแล้ว ขอบคุณสำหรับความร่วมมือคะ',[{text: t('ok'), onPress:() => {this.props.navigation.goBack()}}])
- })
- }else if(this.props.user != null && param.message != null){
- postSuggestionLogin(param)
- .then(res => {
- console.log('check response suggestion -----------> ',res)
- Alert.alert('รับข้อเสนอแนะเรียบร้อย', 'ทางเราได้รับคำแนะนำและเรื่องไว้พิจารณาแล้ว ขอบคุณสำหรับความร่วมมือคะ',[{text: t('ok'), onPress:() => {this.props.navigation.goBack()}}])
- })
- }else{
- console.log('suggestion fails')
- Alert.alert('ส่งข้อเสนอแนะไม่สำเร็จ', 'กรุณากรอกข้อเสนอแนะ ขอบคุณสำหรับความร่วมมือคะ',[{text: t('ok')}])
- }
+ this.setState({
+ isLoading: true
+ }, () => {
+ let param = {
+ message: this.state.suggestionText,
+ image: this.state.image_selected,
+ title: this.state.suggestionTitle
+ }
+ console.log("param",param);
+ if(this.props.user == null && param.message != null && param.title != null && param.title.trim() !== ""){
+ postSuggestion(param)
+ .then(res => {
+ console.log('check response suggestion -----------> ',res)
+
+ Alert.alert('รับข้อเสนอแนะเรียบร้อย', 'ทางเราได้รับคำแนะนำและเรื่องไว้พิจารณาแล้ว ขอบคุณสำหรับความร่วมมือค่ะ',[{text: t('ok'), onPress:() => {
+ this.setState({
+ isLoading: false
+ }, () => {
+ this.props.navigation.goBack()
+ })
+ }}])
+ })
+ }else if(this.props.user != null && param.message != null && param.title != null && param.title.trim() !== ""){
+ postSuggestionLogin(param)
+ .then(res => {
+ console.log('check response suggestion -----------> ',res)
+ Alert.alert('รับข้อเสนอแนะเรียบร้อย', 'ทางเราได้รับคำแนะนำและเรื่องไว้พิจารณาแล้ว ขอบคุณสำหรับความร่วมมือค่ะ',[{text: t('ok'), onPress:() => {
+ this.setState({
+ isLoading: false
+ }, () => {
+ this.props.navigation.goBack()
+ })
+ }}])
+ })
+ }else{
+ console.log('suggestion fails')
+ this.setState({
+ isLoading: false
+ }, () => {
+ Alert.alert('ส่งข้อเสนอแนะไม่สำเร็จ', 'กรุณากรอกข้อมูลให้ครบถ้วน',[{text: t('ok')}])
+ })
+ }
+ })
+
}
onImagePick() {
@@ -83,7 +108,9 @@ class SuggestionScreen extends Component {
isShowAddBtn: false
})
})
- }).catch(e => alert(e))
+ }).catch(e => {
+ // alert(e)
+ })
}
onTakeCamera() {
@@ -109,7 +136,9 @@ class SuggestionScreen extends Component {
isShowAddBtn: false
})
})
- }).catch(e => alert(e))
+ }).catch(e => {
+ // alert(e)
+ })
}
render() {
@@ -124,6 +153,14 @@ class SuggestionScreen extends Component {
+
+ {t('title')}
+ this.setState({suggestionTitle: text})}
+ value={this.state.suggestionTitle}/>
+
{t('suggestion')}
+