1
- import React , { useState , useEffect } from 'react' ;
1
+ import React , { useState , useEffect } from 'react' ;
2
2
import {
3
3
StyleSheet ,
4
4
View ,
@@ -10,18 +10,31 @@ import {
10
10
SafeAreaView ,
11
11
Modal ,
12
12
Alert ,
13
+ RefreshControl ,
13
14
} from 'react-native' ;
14
- import { StackActions } from '@react-navigation/native' ;
15
+ import { StackActions } from '@react-navigation/native' ;
15
16
import MainCard from '../../shared/MainCard' ;
16
17
import MaterialIcons from 'react-native-vector-icons/FontAwesome' ;
17
- import { TouchableOpacity } from 'react-native' ;
18
+ import { TouchableOpacity } from 'react-native' ;
18
19
import axios from 'axios' ;
19
- import { connect } from 'react-redux' ;
20
- import { URL , getBidsByOrder , confirmOrder } from '../../config/const' ;
20
+ import { connect } from 'react-redux' ;
21
+ import { URL , getBidsByOrder , confirmOrder } from '../../config/const' ;
21
22
22
23
const BidsOnBuyerRequests = ( props ) => {
23
24
const [ Bids , setBids ] = useState ( [ ] ) ;
24
25
const [ isVisible , setIsVisible ] = useState ( false ) ;
26
+ const [ refreshing , setRefreshing ] = useState ( false ) ;
27
+ const onRefresh = ( ) => {
28
+ setRefreshing ( true ) ;
29
+ setTimeout ( ( ) => {
30
+ setRefreshing ( false ) ;
31
+ Refresh ( ) ;
32
+ } , 2000 ) ;
33
+ } ;
34
+
35
+ const Refresh = ( ) => {
36
+ getAllBidsByOrder ( ) ;
37
+ } ;
25
38
26
39
const getAllBidsByOrder = async ( ) => {
27
40
try {
@@ -34,10 +47,11 @@ const BidsOnBuyerRequests = (props) => {
34
47
} ,
35
48
) ;
36
49
setBids ( response . data . result ) ;
50
+ console . log ( 'response of getallbids' , response . data . result ) ;
37
51
return response . data . result ;
38
52
} catch ( error ) {
39
53
if ( error ?. response ?. data ?. result ) {
40
- return { error : error . response . data . result } ;
54
+ return { error : error . response . data . result } ;
41
55
}
42
56
}
43
57
} ;
@@ -67,35 +81,32 @@ const BidsOnBuyerRequests = (props) => {
67
81
if ( error ?. response ?. data ?. result ) {
68
82
console . log ( 'propss in AcceptBid' , error ) ;
69
83
console . log ( 'error123 AcceptBid : ' , error . response . data ) ;
70
- return { error : error . response . data . result } ;
84
+ return { error : error . response . data . result } ;
71
85
}
72
86
}
73
87
} ;
74
88
75
89
useEffect ( ( ) => {
76
90
getAllBidsByOrder ( ) ;
77
- } , [ ] ) ;
91
+ } , [ props ] ) ;
78
92
79
93
const displayModal = ( show ) => {
80
94
setIsVisible ( show ) ;
81
95
setTimeout ( ( ) => {
82
96
setIsVisible ( false ) ;
83
97
props . navigation . dispatch ( StackActions . pop ( 0 ) ) ;
84
98
} , 2000 ) ;
85
- // props.navigation.navigate('Home', {
86
- // ...props.route.params,
87
- // });
88
99
} ;
89
100
90
- const renderItem = ( { item } ) => (
101
+ const renderItem = ( { item} ) => (
91
102
< Item
92
103
description = { item . description }
93
104
seller = { item . seller }
94
105
budget = { item . budget }
95
106
_id = { item . _id }
96
107
/>
97
108
) ;
98
- const Item = ( { description, seller, budget, _id } ) => (
109
+ const Item = ( { description, seller, budget, _id} ) => (
99
110
< View
100
111
style = { {
101
112
margin : 5 ,
@@ -109,7 +120,7 @@ const BidsOnBuyerRequests = (props) => {
109
120
shadowOpacity : 0.5 ,
110
121
shadowRadius : 5 ,
111
122
elevation : 13 ,
112
- marginHorizontal : 30
123
+ marginHorizontal : 30 ,
113
124
} } >
114
125
< View
115
126
style = { {
@@ -137,8 +148,8 @@ const BidsOnBuyerRequests = (props) => {
137
148
paddingTop : 5 ,
138
149
paddingHorizontal : 8 ,
139
150
} } >
140
- < Text style = { { fontSize : 15 } } >
141
- < MaterialIcons name = "female" size = { 18 } style = { { color : 'black' } } />
151
+ < Text style = { { fontSize : 15 } } >
152
+ < MaterialIcons name = "female" size = { 18 } style = { { color : 'black' } } />
142
153
{ seller != undefined ? ' ' + seller . name : ' TBD' }
143
154
</ Text >
144
155
< Text
@@ -157,22 +168,22 @@ const BidsOnBuyerRequests = (props) => {
157
168
flexDirection : 'row' ,
158
169
paddingTop : 5 ,
159
170
} } >
160
- < Text style = { { paddingLeft : 8 , fontWeight : 'bold' , fontSize : 12 } } >
171
+ < Text style = { { paddingLeft : 8 , fontWeight : 'bold' , fontSize : 12 } } >
161
172
Description:{ ' ' }
162
173
</ Text >
163
- < Text style = { { fontSize : 12 , textAlign : 'justify' } } > { description } </ Text >
174
+ < Text style = { { fontSize : 12 , textAlign : 'justify' } } > { description } </ Text >
164
175
</ View >
165
176
< View
166
177
style = { {
167
178
flexDirection : 'row' ,
168
179
justifyContent : 'space-between' ,
169
180
paddingVertical : 5 ,
170
181
} } >
171
- < View style = { { flexDirection : 'row' } } >
172
- < Text style = { { paddingLeft : 8 , fontWeight : 'bold' , fontSize : 12 } } >
182
+ < View style = { { flexDirection : 'row' } } >
183
+ < Text style = { { paddingLeft : 8 , fontWeight : 'bold' , fontSize : 12 } } >
173
184
Budget:{ ' ' }
174
185
</ Text >
175
- < Text style = { { fontSize : 12 , textAlign : 'justify' } } >
186
+ < Text style = { { fontSize : 12 , textAlign : 'justify' } } >
176
187
{ 'Rs. ' + budget }
177
188
</ Text >
178
189
</ View >
@@ -226,7 +237,7 @@ const BidsOnBuyerRequests = (props) => {
226
237
color : '#AD379D' ,
227
238
} }
228
239
/>
229
- < Text style = { { textAlign : 'center' , fontSize : 30 } } >
240
+ < Text style = { { textAlign : 'center' , fontSize : 30 } } >
230
241
Bid Accepted!
231
242
</ Text >
232
243
</ View >
@@ -253,16 +264,22 @@ const BidsOnBuyerRequests = (props) => {
253
264
</ Text >
254
265
</ View >
255
266
< MainCard requests = { true } >
256
- < ScrollView >
257
- < SafeAreaView style = { styles . container } >
258
- < FlatList
259
- data = { Bids }
260
- renderItem = { renderItem }
261
- keyExtractor = { ( item ) => item . key }
262
- style = { { borderRadius : 20 } }
263
- />
264
- </ SafeAreaView >
265
- </ ScrollView >
267
+ < SafeAreaView style = { styles . container } >
268
+ < FlatList
269
+ refreshControl = {
270
+ < RefreshControl
271
+ refreshing = { refreshing }
272
+ onRefresh = { onRefresh }
273
+ colors = { [ '#F4F9FE' ] }
274
+ progressBackgroundColor = { '#B0389F' }
275
+ />
276
+ }
277
+ data = { Bids }
278
+ renderItem = { renderItem }
279
+ keyExtractor = { ( item ) => item . key }
280
+ // style={{borderRadius: 20}}
281
+ />
282
+ </ SafeAreaView >
266
283
</ MainCard >
267
284
</ View >
268
285
</ TouchableWithoutFeedback >
@@ -280,8 +297,9 @@ const styles = StyleSheet.create({
280
297
borderRadius : 50 ,
281
298
} ,
282
299
container : {
283
- borderRadius : 20 ,
284
- marginVertical : 30
300
+ // flex: 1,
301
+ marginTop : 25 ,
302
+ paddingBottom : 200 ,
285
303
} ,
286
304
title : {
287
305
fontSize : 32 ,
@@ -318,7 +336,6 @@ const styles = StyleSheet.create({
318
336
color : 'white' ,
319
337
fontSize : 12 ,
320
338
textAlign : 'center' ,
321
-
322
339
} ,
323
340
} ) ;
324
341
0 commit comments