Skip to content

Commit 95e4aee

Browse files
Added refreshable components
1 parent 66459c3 commit 95e4aee

23 files changed

+648
-487
lines changed

screens/buyer/AllService.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const AllServices = (props) => {
9797
};
9898

9999
const OnPressService = (id, name) => {
100-
props.navigation.navigate('ServiceJobs', {
100+
props.navigation.navigate('ServiceSeller', {
101101
...props.route.params,
102102
id,
103103
name,

screens/buyer/AvailableSellers.js

+69-41
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, {useState, useEffect} from 'react';
22
import {
33
StyleSheet,
44
View,
@@ -12,19 +12,34 @@ import {
1212
FlatList,
1313
SafeAreaView,
1414
TouchableOpacity,
15+
RefreshControl,
1516
} from 'react-native';
1617
import Header from '../../shared/Header2';
1718
import Card from '../../shared/AppStackCard';
1819
import MaterialIcons from 'react-native-vector-icons/FontAwesome';
1920
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
2021
import axios from 'axios';
21-
import { connect } from 'react-redux';
22-
import { URL, getUserByType } from '../../config/const';
22+
import {connect} from 'react-redux';
23+
import {URL, getUserByType} from '../../config/const';
2324

2425
const AvailableSellers = (props) => {
2526
const [Sellers, setSellers] = useState([]);
27+
28+
const [refreshing, setRefreshing] = useState(false);
29+
const onRefresh = () => {
30+
setRefreshing(true);
31+
setTimeout(() => {
32+
setRefreshing(false);
33+
Refresh();
34+
}, 2000);
35+
};
36+
37+
const Refresh = () => {
38+
getAllSellers();
39+
};
40+
2641
const renderAvailableSellers = (item) => <ItemRecom item={item.item} />;
27-
const ItemRecom = ({ item }) => (
42+
const ItemRecom = ({item}) => (
2843
<TouchableOpacity
2944
onPress={() => {
3045
OnPressSeller(item);
@@ -38,24 +53,29 @@ const AvailableSellers = (props) => {
3853
paddingHorizontal: 8,
3954
marginBottom: 10,
4055
}}>
41-
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
42-
<View style={{ flexDirection: 'row' }}>
56+
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
57+
<View style={{flexDirection: 'row'}}>
4358
<Image
44-
source={{ uri: item.profileImage }}
59+
source={{uri: item.profileImage}}
4560
style={styles.headerImage}
4661
/>
47-
<View style={{ paddingHorizontal: 7, paddingTop: 6 }}>
48-
<Text style={{ fontSize: 16, fontWeight: 'bold', marginTop: 6 }}>
62+
<View style={{paddingHorizontal: 7, paddingTop: 6}}>
63+
<Text style={{fontSize: 16, fontWeight: 'bold', marginTop: 6}}>
4964
{item.name}
5065
</Text>
5166
<Text
52-
style={{ fontSize: 10, color: '#A28FA1', fontWeight: 'bold' }}>
67+
style={{fontSize: 10, color: '#A28FA1', fontWeight: 'bold'}}>
5368
{item.title}
5469
</Text>
55-
<Text style={{ fontSize: 10, color: '#FFB266' }}>
56-
<MaterialIcons name="star" size={10} />
57-
{' ' + item.rating.toFixed(1)}
58-
</Text>
70+
<View style={{flexDirection: 'row'}}>
71+
<Text style={{fontSize: 10, color: '#FFB266'}}>
72+
<MaterialIcons name="star" size={10} />
73+
{' ' + item.rating.toFixed(1)}
74+
</Text>
75+
<Text style={{fontSize: 10, color: '#291F28', opacity: 0.6}}>
76+
{' (' + item.ratingCount + ') '}
77+
</Text>
78+
</View>
5979
</View>
6080
</View>
6181
<View>
@@ -101,7 +121,7 @@ const AvailableSellers = (props) => {
101121
return response.data.result;
102122
} catch (error) {
103123
if (error?.response?.data?.result) {
104-
return { error: error.response.data.result };
124+
return {error: error.response.data.result};
105125
}
106126
}
107127
};
@@ -115,36 +135,42 @@ const AvailableSellers = (props) => {
115135

116136
useEffect(() => {
117137
getAllSellers();
118-
}, []);
138+
}, [props]);
119139

120140
return (
121141
<TouchableWithoutFeedback
122142
onPress={() => {
123143
Keyboard.dismiss();
124144
}}>
125-
<ScrollView>
126-
<View style={styles.back}>
127-
<Header />
128-
<Card>
129-
<View style={{ flexDirection: 'row' }}>
130-
<Text
131-
style={{
132-
fontWeight: 'bold',
133-
fontSize: 25,
134-
}}>
135-
Available Sellers
136-
</Text>
137-
</View>
138-
<SafeAreaView style={styles.container}>
139-
<FlatList
140-
data={Sellers}
141-
renderItem={renderAvailableSellers}
142-
keyExtractor={(item) => item._id}
143-
/>
144-
</SafeAreaView>
145-
</Card>
146-
</View>
147-
</ScrollView>
145+
<View style={styles.back}>
146+
<Header />
147+
<Card>
148+
<View style={{flexDirection: 'row'}}>
149+
<Text
150+
style={{
151+
fontWeight: 'bold',
152+
fontSize: 25,
153+
}}>
154+
Available Sellers
155+
</Text>
156+
</View>
157+
<SafeAreaView style={styles.container}>
158+
<FlatList
159+
refreshControl={
160+
<RefreshControl
161+
refreshing={refreshing}
162+
onRefresh={onRefresh}
163+
colors={['#F4F9FE']}
164+
progressBackgroundColor={'#B0389F'}
165+
/>
166+
}
167+
data={Sellers}
168+
renderItem={renderAvailableSellers}
169+
keyExtractor={(item) => item._id}
170+
/>
171+
</SafeAreaView>
172+
</Card>
173+
</View>
148174
</TouchableWithoutFeedback>
149175
);
150176
};
@@ -160,8 +186,10 @@ const styles = StyleSheet.create({
160186
borderRadius: 50,
161187
},
162188
container: {
163-
borderRadius: 20,
164-
marginVertical: 30,
189+
// flex: 1,
190+
marginTop: 25,
191+
paddingBottom: 200,
192+
// backgroundColor: 'red',
165193
},
166194
});
167195
const mapStateToProps = (state) => ({

screens/buyer/BidsOnBuyerRequests.js

+52-35
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from 'react';
1+
import React, {useState, useEffect} from 'react';
22
import {
33
StyleSheet,
44
View,
@@ -10,18 +10,31 @@ import {
1010
SafeAreaView,
1111
Modal,
1212
Alert,
13+
RefreshControl,
1314
} from 'react-native';
14-
import { StackActions } from '@react-navigation/native';
15+
import {StackActions} from '@react-navigation/native';
1516
import MainCard from '../../shared/MainCard';
1617
import MaterialIcons from 'react-native-vector-icons/FontAwesome';
17-
import { TouchableOpacity } from 'react-native';
18+
import {TouchableOpacity} from 'react-native';
1819
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';
2122

2223
const BidsOnBuyerRequests = (props) => {
2324
const [Bids, setBids] = useState([]);
2425
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+
};
2538

2639
const getAllBidsByOrder = async () => {
2740
try {
@@ -34,10 +47,11 @@ const BidsOnBuyerRequests = (props) => {
3447
},
3548
);
3649
setBids(response.data.result);
50+
console.log('response of getallbids', response.data.result);
3751
return response.data.result;
3852
} catch (error) {
3953
if (error?.response?.data?.result) {
40-
return { error: error.response.data.result };
54+
return {error: error.response.data.result};
4155
}
4256
}
4357
};
@@ -67,35 +81,32 @@ const BidsOnBuyerRequests = (props) => {
6781
if (error?.response?.data?.result) {
6882
console.log('propss in AcceptBid', error);
6983
console.log('error123 AcceptBid : ', error.response.data);
70-
return { error: error.response.data.result };
84+
return {error: error.response.data.result};
7185
}
7286
}
7387
};
7488

7589
useEffect(() => {
7690
getAllBidsByOrder();
77-
}, []);
91+
}, [props]);
7892

7993
const displayModal = (show) => {
8094
setIsVisible(show);
8195
setTimeout(() => {
8296
setIsVisible(false);
8397
props.navigation.dispatch(StackActions.pop(0));
8498
}, 2000);
85-
// props.navigation.navigate('Home', {
86-
// ...props.route.params,
87-
// });
8899
};
89100

90-
const renderItem = ({ item }) => (
101+
const renderItem = ({item}) => (
91102
<Item
92103
description={item.description}
93104
seller={item.seller}
94105
budget={item.budget}
95106
_id={item._id}
96107
/>
97108
);
98-
const Item = ({ description, seller, budget, _id }) => (
109+
const Item = ({description, seller, budget, _id}) => (
99110
<View
100111
style={{
101112
margin: 5,
@@ -109,7 +120,7 @@ const BidsOnBuyerRequests = (props) => {
109120
shadowOpacity: 0.5,
110121
shadowRadius: 5,
111122
elevation: 13,
112-
marginHorizontal: 30
123+
marginHorizontal: 30,
113124
}}>
114125
<View
115126
style={{
@@ -137,8 +148,8 @@ const BidsOnBuyerRequests = (props) => {
137148
paddingTop: 5,
138149
paddingHorizontal: 8,
139150
}}>
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'}} />
142153
{seller != undefined ? ' ' + seller.name : ' TBD'}
143154
</Text>
144155
<Text
@@ -157,22 +168,22 @@ const BidsOnBuyerRequests = (props) => {
157168
flexDirection: 'row',
158169
paddingTop: 5,
159170
}}>
160-
<Text style={{ paddingLeft: 8, fontWeight: 'bold', fontSize: 12 }}>
171+
<Text style={{paddingLeft: 8, fontWeight: 'bold', fontSize: 12}}>
161172
Description:{' '}
162173
</Text>
163-
<Text style={{ fontSize: 12, textAlign: 'justify' }}>{description}</Text>
174+
<Text style={{fontSize: 12, textAlign: 'justify'}}>{description}</Text>
164175
</View>
165176
<View
166177
style={{
167178
flexDirection: 'row',
168179
justifyContent: 'space-between',
169180
paddingVertical: 5,
170181
}}>
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}}>
173184
Budget:{' '}
174185
</Text>
175-
<Text style={{ fontSize: 12, textAlign: 'justify' }}>
186+
<Text style={{fontSize: 12, textAlign: 'justify'}}>
176187
{'Rs. ' + budget}
177188
</Text>
178189
</View>
@@ -226,7 +237,7 @@ const BidsOnBuyerRequests = (props) => {
226237
color: '#AD379D',
227238
}}
228239
/>
229-
<Text style={{ textAlign: 'center', fontSize: 30 }}>
240+
<Text style={{textAlign: 'center', fontSize: 30}}>
230241
Bid Accepted!
231242
</Text>
232243
</View>
@@ -253,16 +264,22 @@ const BidsOnBuyerRequests = (props) => {
253264
</Text>
254265
</View>
255266
<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>
266283
</MainCard>
267284
</View>
268285
</TouchableWithoutFeedback>
@@ -280,8 +297,9 @@ const styles = StyleSheet.create({
280297
borderRadius: 50,
281298
},
282299
container: {
283-
borderRadius: 20,
284-
marginVertical: 30
300+
// flex: 1,
301+
marginTop: 25,
302+
paddingBottom: 200,
285303
},
286304
title: {
287305
fontSize: 32,
@@ -318,7 +336,6 @@ const styles = StyleSheet.create({
318336
color: 'white',
319337
fontSize: 12,
320338
textAlign: 'center',
321-
322339
},
323340
});
324341

0 commit comments

Comments
 (0)