fix show detail of repair history

This commit is contained in:
kanyanat 2025-12-04 16:55:52 +07:00
parent 247afc982d
commit 5cf82358ad
5 changed files with 59 additions and 46 deletions

9
App.js
View File

@ -90,7 +90,7 @@ class App extends Component {
body: remoteMessage.notification.body, body: remoteMessage.notification.body,
android: { android: {
channelId, channelId,
smallIcon: 'ic_launcher' smallIcon: 'ic_splash'
}, },
ios: { ios: {
foregroundPresentationOptions: { foregroundPresentationOptions: {
@ -119,8 +119,6 @@ class App extends Component {
if (!apnsToken) { if (!apnsToken) {
console.log('Failed to get APNs token after retries'); console.log('Failed to get APNs token after retries');
// Decide if we want to return here or try anyway.
// Usually if APNs is missing, getToken will fail.
} }
} }
@ -136,10 +134,6 @@ class App extends Component {
store.dispatch(appSetDevice(resultSendDevice.data.device)) store.dispatch(appSetDevice(resultSendDevice.data.device))
} }
} }
// เพิ่ม notification listeners
this.setupNotificationListeners();
} catch (error) { } catch (error) {
console.log('initNotification error:', error); console.log('initNotification error:', error);
} }
@ -175,7 +169,6 @@ class App extends Component {
this.initNotification() this.initNotification()
} else { } else {
this.setPermission() this.setPermission()
this.setupNotificationListeners()
} }
console.log('app state', appState, device) console.log('app state', appState, device)

Binary file not shown.

View File

@ -47,11 +47,11 @@ class NotificationScreen extends Component {
getContentId(item) { getContentId(item) {
let data = item.data; let data = item.data;
let dataJson = JSON.parse(data); let dataJson = (data && JSON.parse(data)) || null;
if(dataJson.id){ if(dataJson && dataJson.id){
return dataJson.id; return dataJson.id;
}else { }else {
return null; return item.source_id || null;
} }
} }

View File

@ -116,7 +116,7 @@ class RepairHistory extends Component {
</View> </View>
<View style={{flexDirection:'row',justifyContent:'space-between',marginVertical:5}}> <View style={{flexDirection:'row',justifyContent:'space-between',marginVertical:5}}>
<Text style={{fontSize:14}}>{item.name}</Text> <Text style={{fontSize:14}}>{item.name}</Text>
<Text style={{fontSize:14}}>#{item.id}</Text> <Text style={{fontSize:14}}>#{item.code}</Text>
</View> </View>
<View style={{flexDirection:'row',justifyContent:'space-between'}}> <View style={{flexDirection:'row',justifyContent:'space-between'}}>
<View style={{flexDirection:'row',alignItems:'center'}}> <View style={{flexDirection:'row',alignItems:'center'}}>

View File

@ -121,13 +121,12 @@ export default class RepairHistoryDetail extends Component {
getRepairData(){ getRepairData(){
this.setState({ this.setState({
isLoading: true isLoading: true
}) }, () => {
getRepairById(this.state.project_id, this.state.repair_id) getRepairById(this.state.project_id, this.state.repair_id)
.then(res => { .then(res => {
console.log('repair data -------------> ',res.data.data)
this.setState({ this.setState({
repair: res.data.data, repair: res.data,
order_list: res.data.data.services, order_list: res.data.material_list || [],
isLoading: false isLoading: false
}) })
@ -147,12 +146,13 @@ export default class RepairHistoryDetail extends Component {
isLoading: false isLoading: false
}) })
}) })
})
} }
renderItem = (item) => { renderItem = (item) => {
return <View style={{ flexDirection: 'row', marginVertical:3, justifyContent:'space-between'}}> return <View style={{ flexDirection: 'row', marginVertical:3, justifyContent:'space-between'}}>
<Text style={{ fontSize: 14, color: '#000000' }}>{item.name}</Text> <Text style={{ fontSize: 14, color: '#000000' }}>{item.name_th}</Text>
<Text style={{ textAlign: 'right', fontSize: 14, color: this.state.type === 'effect_responsible' ? 'red' : '#7CBB33' }}>{this.state.repair.status === 'Cancel' ? 0: item.service_fee} {t('baht')}</Text> <Text style={{ textAlign: 'right', fontSize: 14, color: this.state.type === 'effect_responsible' ? 'red' : '#7CBB33' }}>{this.state.repair.status === 'Cancel' ? 0 : item.total_cost || 0} {t('baht')}</Text>
</View> </View>
} }
@ -161,14 +161,18 @@ export default class RepairHistoryDetail extends Component {
convertStatus(statusName){ convertStatus(statusName){
switch(statusName){ switch(statusName){
case 'Pending': case 'Pending':
case '1':
return t('request_repair'); return t('request_repair');
case 'InProgress': case 'InProgress':
case '2':
return 'ยืนยันนัด'; return 'ยืนยันนัด';
case 'NewAppointment': case 'NewAppointment':
return t('repair_re_appoint'); return t('repair_re_appoint');
case 'Cancel': case 'Cancel':
case '4':
return t('cancel'); return t('cancel');
case 'Success': case 'Success':
case '3':
return t('repair_success'); return t('repair_success');
default: default:
return t('pending') return t('pending')
@ -178,15 +182,19 @@ export default class RepairHistoryDetail extends Component {
convertColorStatus(statusName){ convertColorStatus(statusName){
switch(statusName){ switch(statusName){
case 'Pending': case 'Pending':
case '1':
return '#FF9500'; return '#FF9500';
case 'InProgress': case 'InProgress':
case '2':
// return '#FFCC00' // return '#FFCC00'
return '#007AFF'; return '#007AFF';
case 'NewAppointment': case 'NewAppointment':
return '#145EB3'; return '#145EB3';
case 'Cancel': case 'Cancel':
case '4':
return '#666666'; return '#666666';
case 'Success': case 'Success':
case '3':
return '#2C7C0B'; return '#2C7C0B';
default: default:
return '#C4C4C4'; return '#C4C4C4';
@ -200,7 +208,7 @@ export default class RepairHistoryDetail extends Component {
<LinearGradient colors={['#4BAF3B', '#0E5E29']} style={{borderRadius:5, padding:16}}> <LinearGradient colors={['#4BAF3B', '#0E5E29']} style={{borderRadius:5, padding:16}}>
<View style={{flexDirection:'row',justifyContent:'space-between'}}> <View style={{flexDirection:'row',justifyContent:'space-between'}}>
<Text style={{ fontSize: 18, color: '#FFFFFF'}} >{t('room')} {this.state.repair && this.state.repair.room_no ? this.state.repair.room_no : ''}</Text> <Text style={{ fontSize: 18, color: '#FFFFFF'}} >{t('room')} {this.state.repair && this.state.repair.room_no ? this.state.repair.room_no : ''}</Text>
<Text style={{ textAlign:'right', fontSize: 18, color: '#FFFFFF', }} >#{this.state.repair && this.state.repair.id ? this.state.repair.id : ''}</Text> <Text style={{ textAlign:'right', fontSize: 18, color: '#FFFFFF', }} >#{this.state.repair && this.state.repair.code ? this.state.repair.code : ''}</Text>
</View> </View>
<Text style={{ fontSize: 14, color: 'rgba(255, 255, 255, 0.65)', }}>{this.state.repair && this.state.repair.project_name ? this.state.repair.project_name : '' }</Text> <Text style={{ fontSize: 14, color: 'rgba(255, 255, 255, 0.65)', }}>{this.state.repair && this.state.repair.project_name ? this.state.repair.project_name : '' }</Text>
</LinearGradient> </LinearGradient>
@ -211,14 +219,13 @@ export default class RepairHistoryDetail extends Component {
<View style={{ flexDirection: 'row',}}> <View style={{ flexDirection: 'row',}}>
{ {
this.state.repair && this.state.repair.status ? this.state.repair && this.state.repair.status ?
this.state.repair.status === 'Pending' this.state.repair.status === '1' && !this.state.repair.work_date
&& (this.state.repair.date === null || this.state.repair.time === null || this.state.repair.date === '' || this.state.repair.time === '')
? <Text style={{ fontSize: 14, color: '#000000', paddingRight: 10,}}>กรณารอการนดหมายใหมจากเจาหนาท</Text> ? <Text style={{ fontSize: 14, color: '#000000', paddingRight: 10,}}>กรณารอการนดหมายใหมจากเจาหนาท</Text>
: <View style={{flexDirection: 'row'}}> : <View style={{flexDirection: 'row'}}>
<Text style={{ fontSize: 14, color: 'rgba(0, 0, 0, 0.5)' }}>{t('date')}</Text> <Text style={{ fontSize: 14, color: 'rgba(0, 0, 0, 0.5)' }}>{t('date')}</Text>
<Text style={{ fontSize: 14, color: '#000000', paddingHorizontal: 10,}}>{this.state.repair && this.state.repair.date ? moment(this.state.repair.date, 'YYYY-MM-DD').format('DD-MM-YYYY') : '' }</Text> <Text style={{ fontSize: 14, color: '#000000', paddingHorizontal: 10,}}>{(this.state.repair && this.state.repair.work_date) || '' }</Text>
<Text style={{ fontSize: 14, color: 'rgba(0, 0, 0, 0.5)' }}>เวลา</Text> {/*<Text style={{ fontSize: 14, color: 'rgba(0, 0, 0, 0.5)' }}></Text>
<Text style={{ fontSize: 14, color: '#000000', paddingHorizontal: 10,}}>{this.state.repair && this.state.repair.time ? moment(this.state.repair.time, 'HH:mm:ss').format('HH:mm') + ' น.' : '' }</Text> <Text style={{ fontSize: 14, color: '#000000', paddingHorizontal: 10,}}>{this.state.repair && this.state.repair.time ? moment(this.state.repair.time, 'HH:mm:ss').format('HH:mm') + ' น.' : '' }</Text>*/}
</View> </View>
: <Text/> : <Text/>
} }
@ -226,7 +233,8 @@ export default class RepairHistoryDetail extends Component {
<View style={{ flexDirection: 'row',alignItems:'center',marginVertical:3}}> <View style={{ flexDirection: 'row',alignItems:'center',marginVertical:3}}>
<Text style={{ fontSize: 14, color: 'rgba(0, 0, 0, 0.5)'}}>{t('status')}</Text> <Text style={{ fontSize: 14, color: 'rgba(0, 0, 0, 0.5)'}}>{t('status')}</Text>
<View style={{backgroundColor:this.convertColorStatus(this.state.repair.status),height: 10,width: 10,borderRadius:5, marginHorizontal:10}}/> <View style={{backgroundColor:this.convertColorStatus(this.state.repair.status),height: 10,width: 10,borderRadius:5, marginHorizontal:10}}/>
<Text style={{ fontSize: 14, color:this.convertColorStatus(this.state.repair.status)}}>{this.state.repair && this.state.repair.status ? this.convertStatus(this.state.repair.status) : ''}</Text> <Text style={{ fontSize: 14, color:this.convertColorStatus(this.state.repair.status)}}>{(this.state.repair && this.state.repair.status_name) || ''}</Text>
{/*<Text style={{ fontSize: 14, color:this.convertColorStatus(this.state.repair.status)}}>{this.state.repair && this.state.repair.status ? this.convertStatus(this.state.repair.status) : ''}</Text>*/}
</View> </View>
</View> </View>
@ -243,6 +251,11 @@ export default class RepairHistoryDetail extends Component {
pagingEnabled={true} pagingEnabled={true}
extraData={this.state} extraData={this.state}
keyExtractor={this._keyExtractor} keyExtractor={this._keyExtractor}
ListEmptyComponent={() =>
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center', margin: 16,padding:16,borderRadius:5,backgroundColor:'white'}}>
<Text style={{fontSize: 16}}> ไมพบรายการขอม </Text>
</View>
}
/> />
</ScrollView> </ScrollView>
</View> </View>
@ -251,12 +264,19 @@ export default class RepairHistoryDetail extends Component {
<View style={{ flexDirection:'row',justifyContent:'space-between'}}> <View style={{ flexDirection:'row',justifyContent:'space-between'}}>
<Text style={[{ fontSize: 14}, this.state.type === 'effect_responsible' ? {color: '#FF3B30'} : {color: Color.green_title}]}>{t('estimate_charge')}</Text> <Text style={[{ fontSize: 14}, this.state.type === 'effect_responsible' ? {color: '#FF3B30'} : {color: Color.green_title}]}>{t('estimate_charge')}</Text>
<Text style={[{ textAlign: 'right', fontSize: 14, color: '#7CBB33'}, this.state.type === 'effect_responsible' ? {color: '#FF3B30'} : {color: Color.green_title}]}>{this.state.repair.status === 'Cancel' ? 0 : this.state.repair && this.state.repair.total ? this.state.repair.total : 0} {t('baht')}</Text> <Text style={[{ textAlign: 'right', fontSize: 14, color: '#7CBB33'}, this.state.type === 'effect_responsible' ? {color: '#FF3B30'} : {color: Color.green_title}]}>
{
this.state.repair.status === 'Cancel'
? 0
: this.state.repair && this.state.repair.total_payment_amount
? this.state.repair.total_payment_amount : 0
} {t('baht')}
</Text>
</View> </View>
</View> </View>
{ {
this.state.repair.status === 'Success' && this.state.repair.points && this.state.repair.status === '3' && this.state.repair.points &&
<View style={{marginTop: 16, backgroundColor: '#FFFFFF',borderRadius:5, paddingVertical: 16}}> <View style={{marginTop: 16, backgroundColor: '#FFFFFF',borderRadius:5, paddingVertical: 16}}>
<View> <View>
<Text style={{ fontSize: 14, color: Color.green_title, textAlign: 'center'}} >คะแนนการประเม</Text> <Text style={{ fontSize: 14, color: Color.green_title, textAlign: 'center'}} >คะแนนการประเม</Text>
@ -290,7 +310,7 @@ export default class RepairHistoryDetail extends Component {
} }
{ {
!this.state.repair.points && this.state.repair.status === 'Success' && !this.state.repair.points && this.state.repair.status === '3' &&
<CustomButton style={[styles.button_style, {backgroundColor: '#269A21', marginTop: 16}]} <CustomButton style={[styles.button_style, {backgroundColor: '#269A21', marginTop: 16}]}
onPress={() => { onPress={() => {
this.props.navigation.navigate('RepairDetail', { this.props.navigation.navigate('RepairDetail', {