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,
android: {
channelId,
smallIcon: 'ic_launcher'
smallIcon: 'ic_splash'
},
ios: {
foregroundPresentationOptions: {
@ -119,8 +119,6 @@ class App extends Component {
if (!apnsToken) {
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))
}
}
// เพิ่ม notification listeners
this.setupNotificationListeners();
} catch (error) {
console.log('initNotification error:', error);
}
@ -175,7 +169,6 @@ class App extends Component {
this.initNotification()
} else {
this.setPermission()
this.setupNotificationListeners()
}
console.log('app state', appState, device)

Binary file not shown.

View File

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

View File

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

View File

@ -121,13 +121,12 @@ export default class RepairHistoryDetail extends Component {
getRepairData(){
this.setState({
isLoading: true
})
}, () => {
getRepairById(this.state.project_id, this.state.repair_id)
.then(res => {
console.log('repair data -------------> ',res.data.data)
this.setState({
repair: res.data.data,
order_list: res.data.data.services,
repair: res.data,
order_list: res.data.material_list || [],
isLoading: false
})
@ -147,12 +146,13 @@ export default class RepairHistoryDetail extends Component {
isLoading: false
})
})
})
}
renderItem = (item) => {
return <View style={{ flexDirection: 'row', marginVertical:3, justifyContent:'space-between'}}>
<Text style={{ fontSize: 14, color: '#000000' }}>{item.name}</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={{ 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.total_cost || 0} {t('baht')}</Text>
</View>
}
@ -161,14 +161,18 @@ export default class RepairHistoryDetail extends Component {
convertStatus(statusName){
switch(statusName){
case 'Pending':
case '1':
return t('request_repair');
case 'InProgress':
case '2':
return 'ยืนยันนัด';
case 'NewAppointment':
return t('repair_re_appoint');
case 'Cancel':
case '4':
return t('cancel');
case 'Success':
case '3':
return t('repair_success');
default:
return t('pending')
@ -178,15 +182,19 @@ export default class RepairHistoryDetail extends Component {
convertColorStatus(statusName){
switch(statusName){
case 'Pending':
case '1':
return '#FF9500';
case 'InProgress':
case '2':
// return '#FFCC00'
return '#007AFF';
case 'NewAppointment':
return '#145EB3';
case 'Cancel':
case '4':
return '#666666';
case 'Success':
case '3':
return '#2C7C0B';
default:
return '#C4C4C4';
@ -200,7 +208,7 @@ export default class RepairHistoryDetail extends Component {
<LinearGradient colors={['#4BAF3B', '#0E5E29']} style={{borderRadius:5, padding:16}}>
<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={{ 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>
<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>
@ -211,14 +219,13 @@ export default class RepairHistoryDetail extends Component {
<View style={{ flexDirection: 'row',}}>
{
this.state.repair && this.state.repair.status ?
this.state.repair.status === 'Pending'
&& (this.state.repair.date === null || this.state.repair.time === null || this.state.repair.date === '' || this.state.repair.time === '')
this.state.repair.status === '1' && !this.state.repair.work_date
? <Text style={{ fontSize: 14, color: '#000000', paddingRight: 10,}}>กรณารอการนดหมายใหมจากเจาหนาท</Text>
: <View style={{flexDirection: 'row'}}>
<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: '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.work_date) || '' }</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>*/}
</View>
: <Text/>
}
@ -226,7 +233,8 @@ export default class RepairHistoryDetail extends Component {
<View style={{ flexDirection: 'row',alignItems:'center',marginVertical:3}}>
<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}}/>
<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>
@ -243,6 +251,11 @@ export default class RepairHistoryDetail extends Component {
pagingEnabled={true}
extraData={this.state}
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>
</View>
@ -251,12 +264,19 @@ export default class RepairHistoryDetail extends Component {
<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={[{ 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>
{
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>
<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}]}
onPress={() => {
this.props.navigation.navigate('RepairDetail', {