diff --git a/android/app/release/app-release.apk b/android/app/release/app-release.apk index b9e2dcc..299d1e3 100644 Binary files a/android/app/release/app-release.apk and b/android/app/release/app-release.apk differ diff --git a/android/app/release/output-metadata.json b/android/app/release/output-metadata.json index 5d1009b..d360afa 100644 --- a/android/app/release/output-metadata.json +++ b/android/app/release/output-metadata.json @@ -17,4 +17,4 @@ } ], "elementType": "File" -} +} \ No newline at end of file diff --git a/src/api/UserApi.js b/src/api/UserApi.js index 9c986a5..b0c1afa 100644 --- a/src/api/UserApi.js +++ b/src/api/UserApi.js @@ -162,12 +162,12 @@ export const getServicesDetail = (service_id) => { return Api.get('/service/'+service_id); } -export const getRepairList = (service_id) => { - return Api.get('/repair'); +export const getRepairList = (project_id) => { + return Api.get(`/api/project/${project_id}/maintenance`); } -export const getRepairById = (repair_id, type = '') => { - return Api.get(`/repair/${repair_id}?self_room=${(type === 'effect_responsible' ? 'true' : 'false')}`); +export const getRepairById = (project_id, id) => { + return Api.get(`/api/project/${project_id}/maintenance/${id}`); } export const postRepair = (param) => { @@ -380,4 +380,4 @@ export function getPointExpire(){ } export function requestDeleteAccount() { return Api.get('/me/request_delete') -} \ No newline at end of file +} diff --git a/src/navigation/AppStack.js b/src/navigation/AppStack.js index a3a2940..d865ccb 100644 --- a/src/navigation/AppStack.js +++ b/src/navigation/AppStack.js @@ -363,7 +363,7 @@ const MainHeader = ({ navigation }) => { }, []) return ({ title: t('repair_history_detail'), @@ -772,7 +776,7 @@ const AppStack = createStackNavigator({ ) }) - }, + },*/ //Reward Reward: screenConfig(RewardScreen, 'redeem_reward'), RewardDetailScreen: screenConfig(RewardDetailScreen, 'product_detail'), diff --git a/src/screens/login/Login.js b/src/screens/login/Login.js index b17a515..e93ed33 100644 --- a/src/screens/login/Login.js +++ b/src/screens/login/Login.js @@ -36,7 +36,7 @@ class LoginScreen extends Component { async componentDidMount() { await messaging().deleteToken() console.log('deletetoken'); - + } async _login () { @@ -74,7 +74,7 @@ class LoginScreen extends Component { // const fcmToken = await messaging().getAPNSToken() console.log('await messaging().getAPNSToken() <<<<<< ', fcmToken) - + let params = { // mobile: this.state.username, @@ -114,7 +114,7 @@ class LoginScreen extends Component { this.setState({ isLoading: false }) } }) - + }; render() { @@ -149,7 +149,7 @@ class LoginScreen extends Component { { this.setState({ diff --git a/src/screens/repair/RepairHistory.js b/src/screens/repair/RepairHistory.js index a965fd9..4b9018f 100644 --- a/src/screens/repair/RepairHistory.js +++ b/src/screens/repair/RepairHistory.js @@ -23,36 +23,16 @@ import {getRepairList} from '../../api/UserApi'; import IndicatorLoading from '../../components/IndicatorLoading'; import { t } from '../../utils/i18n' import moment from "moment"; +import {connect} from "react-redux"; -export default class RepairHistory extends Component { +class RepairHistory extends Component { constructor(props) { super(props) this.state = { isLoading: false, - history_list:[ - // { - // title: 'A1-1', - // status: 'รอดำเนินการ', - // tag: '#124456' - // }, - // { - // title: 'A1-2', - // status: 'แจ้งซ่อม', - // tag: '#546315' - // }, - // { - // title: 'A1-2', - // status: 'เสร็จสิ้น', - // tag: '#148521' - // }, - // { - // title: 'A1-2', - // status: 'เสร็จสิ้น', - // tag: '#986521' - // }, - ] + history_list:[] } this.onRefresh = this.onRefresh.bind(this) this.convertStatus = this.convertStatus.bind(this) @@ -66,50 +46,53 @@ export default class RepairHistory extends Component { getRepairHistoryList(){ this.setState({ isLoading: true - }) - getRepairList() - .then(res => { - if(res.ok){ - console.log('check data response ----------> ',res.data.data); + }, () => { + let project_id = this.props.user && this.props.user.project_id; + getRepairList(project_id) + .then(res => { + if(res.ok){ + console.log('check data response ----------> ',res.data.data); + this.setState({ + history_list: res.data.data, + }) + } + }).finally(() => { this.setState({ - history_list: res.data.data, + isLoading: false }) - } - this.setState({ - isLoading: false }) }) } convertStatus(statusName){ switch(statusName){ - case 'Pending': - return t('request_repair') - case 'InProgress': - return 'ยืนยันนัด' + case '1': + return 'รอซ่อม' + case '2': + return 'กำลังซ่อม' case 'NewAppointment': return 'นัดหมายใหม่' - case 'Cancel': + case '4': return t('cancel') - case 'Success': - return 'ซ่อมสำเร็จ' + case '3': + return 'เสร็จสิ้น' default: return t('request_repair') } } - convertColorStatus(statusName){ - switch(statusName){ - case 'Pending': + convertColorStatus(statusCode){ + switch(statusCode){ + case '1': //รอซ่อม return '#FF9500' - case 'InProgress': + case '2': //กำลังซ่อม return '#007AFF' // return '#FFCC00' case 'NewAppointment': return '#145EB3' - case 'Cancel': + case '4': //ยกเลิก return '#666666' - case 'Success': + case '3': //เสร็จสิ้น return '#2C7C0B' default: return '#C4C4C4' @@ -120,28 +103,26 @@ export default class RepairHistory extends Component { return {this.props.navigation.navigate('RepairHistoryDetail',{ repair_id:item.id, + project_id: this.props.user && this.props.user.project_id, getRepairHistoryList: () => {this.getRepairHistoryList()} })}}> - {t('room')} {item.room_no} + {t('room')} {item.room_sap_code} {this.convertStatus(item.status)} - {item.services_name} + {item.name} #{item.id} - { item.date ? - `${moment(item.date).format('DD-MM-YYYY')}, ${item.time.slice(0,-3)}` - : item.status === 'Cancel' ? '-' : 'รอการนัดหมายใหม่' - } + { item.date ? item.date : item.status_name } {item.status === 'Success' && item.points ? item.points + ' คะแนน' : ''} @@ -183,3 +164,11 @@ export default class RepairHistory extends Component { ) } } + +const mapStateToProps = state => { + return { + user: state.app.user + } +} + +export default connect(mapStateToProps)(RepairHistory) diff --git a/src/screens/repair/RepairHistoryDetail.js b/src/screens/repair/RepairHistoryDetail.js index 39db4e5..64bbead 100644 --- a/src/screens/repair/RepairHistoryDetail.js +++ b/src/screens/repair/RepairHistoryDetail.js @@ -53,6 +53,7 @@ export default class RepairHistoryDetail extends Component { isLoading: false, repair_id: this.props.navigation.getParam('repair_id','NO_ITEM'), type: this.props.navigation.getParam('type','NO_ITEM'), //params from Notification.js + project_id: this.props.navigation.getParam('project_id',null), repair:{}, visibleCancel: false, rating_point: [0,0,0,0,0], @@ -121,7 +122,7 @@ export default class RepairHistoryDetail extends Component { this.setState({ isLoading: true }) - getRepairById(this.state.repair_id, this.state.type) + getRepairById(this.state.project_id, this.state.repair_id) .then(res => { console.log('repair data -------------> ',res.data.data) this.setState({ diff --git a/src/screens/repair/RepairIndex.js b/src/screens/repair/RepairIndex.js index 3bab082..03b9856 100644 --- a/src/screens/repair/RepairIndex.js +++ b/src/screens/repair/RepairIndex.js @@ -1,5 +1,5 @@ import React, {Component} from 'react' -import {Alert, Platform, ScrollView, TextInput, TouchableOpacity, View} from "react-native"; +import {Alert, KeyboardAvoidingView, Platform, ScrollView, TextInput, TouchableOpacity, View} from "react-native"; import {t} from "../../utils/i18n"; import Select2 from "react-select2-native"; import Text from "../../components/Text"; @@ -45,10 +45,10 @@ class RepairIndex extends Component { super(props); this.state = { data: { - repair_list: [ - {name: '', material: '', value: 0} - ], - maintenanceList: [], + // repair_list: [ + // {name: '', material: '', value: 0} + // ], + // maintenanceList: [], work_date: moment(new Date()).format('DD-MM-YYYY'), details: '' }, @@ -94,7 +94,7 @@ class RepairIndex extends Component { let data = this.state.data; if(data.header_dropdown_id && data.room_id - && data.group_dropdown_id + // && data.group_dropdown_id // && data.details && data.work_date && data.work_time @@ -322,7 +322,7 @@ class RepairIndex extends Component { width: null, height: null, backgroundColor: '#EAEAF4', - padding: 16 + padding: 16, }}> - this.setOpen(open, 'openRoom')} - value={data && data.room_id ? data.room_id : ''} - setValue={(callback) => this.setRepairData(callback(this), 'room_id')} - placeholder={t('select_room')} - viewStyle={isIos ? {zIndex: 4} : {}} - zIndex={4} - /> + this.setOpen(open, 'openRoom')} + value={data && data.room_id ? data.room_id : ''} + setValue={(callback) => this.setRepairData(callback(this), 'room_id')} + placeholder={t('select_room')} + viewStyle={isIos ? {zIndex: 4} : {}} + zIndex={4} + /> - + />*/} - - {t('repair_detail')} - - this.setRepairData(text, 'details')} - value={data && data.details ? data.details : ''} - multiline={true} - numberOfLines={4} - textAlignVertical={'top'} - /> + + {t('repair_detail')} + + this.setRepairData(text, 'details')} + value={data && data.details ? data.details : ''} + multiline={true} + numberOfLines={4} + textAlignVertical={'top'} + /> + - - - {t('repair_date')} - - this.setState({visibleDate: true})}> - - {moment(this.state.select_date).format('DD/MM/YYYY')} - - - - - + + {t('repair_date')} + + this.setState({visibleDate: true})}> + + {moment(this.state.select_date).format('DD/MM/YYYY')} + + + + + + - - this.setOpen(open, 'openRepairType')} - value={data && data.work_time ? data.work_time : ''} - setValue={(callback) => this.setRepairData(callback(this), 'work_time')} - placeholder={t('period')} - viewStyle={isIos ? {zIndex: 2} : {}} - zIndex={2} - /> + this.setOpen(open, 'openRepairType')} + value={data && data.work_time ? data.work_time : ''} + setValue={(callback) => this.setRepairData(callback(this), 'work_time')} + placeholder={t('period')} + viewStyle={isIos ? {zIndex: 3} : {paddingBottom: 100}} + zIndex={3} + /> - {/*{ + {/*{ data.repair_list.map((repair, index) => this.addRepairList()}> + {/* this.addRepairList()}> + {t('add_list')} */} - {