@@ -6,87 +6,133 @@ import {
6
6
SafeAreaView ,
7
7
FlatList ,
8
8
TouchableOpacity ,
9
+ Alert ,
9
10
} from 'react-native' ;
10
11
import moment from 'moment' ;
11
12
import Icon from 'react-native-vector-icons/FontAwesome5' ;
12
13
import Entypo from 'react-native-vector-icons/Entypo' ;
13
14
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons' ;
14
- import { URL , getAllComplains } from '../../config/const' ;
15
+ import { URL , getAllComplains , blockSeller } from '../../config/const' ;
15
16
import axios from 'axios' ;
16
17
import { connect } from 'react-redux' ;
17
18
18
- const Item = ( { item} ) => (
19
- < View style = { styles . complains } >
20
- < View style = { styles . details } >
21
- < Text style = { { fontSize : 16 , fontWeight : '700' } } >
22
- Complain No:{ ' ' }
23
- { item . _id . substring ( item . _id . length - 10 , item . _id . length - 3 ) }
24
- </ Text >
25
- </ View >
26
- < View style = { styles . BuyerDetails } >
27
- < View style = { styles . userdetails } >
28
- < View style = { { flexDirection : 'row' , alignItems : 'baseline' } } >
29
- < Icon
30
- name = "user-alt"
31
- color = "black"
32
- size = { 20 }
33
- style = { { marginRight : 10 } }
34
- />
35
- < Text style = { { fontSize : 18 , color : '#000' , fontWeight : '400' } } >
36
- { item . buyer . name }
37
- </ Text >
38
- </ View >
19
+ const ComplainScreen = ( props ) => {
20
+ const renderItem = ( { item} ) => < Item item = { item } /> ;
39
21
40
- < TouchableOpacity style = { styles . update } >
41
- < Text
42
- style = { {
43
- color : '#fff' ,
44
- } } >
45
- Block Seller
46
- </ Text >
47
- </ TouchableOpacity >
22
+ const Item = ( { item} ) => (
23
+ < View style = { styles . complains } >
24
+ < View style = { styles . details } >
25
+ < Text style = { { fontSize : 16 , fontWeight : '700' } } >
26
+ Complain No:{ ' ' }
27
+ { item . _id . substring ( item . _id . length - 10 , item . _id . length - 3 ) }
28
+ </ Text >
48
29
</ View >
49
- </ View >
50
- < View style = { styles . sellerDetails } >
51
- < View style = { styles . userdetails } >
52
- < View style = { { flexDirection : 'row' , alignItems : 'baseline' } } >
53
- < Entypo
54
- name = "smashing"
55
- color = "black"
56
- size = { 20 }
57
- style = { { marginRight : 10 } }
58
- />
59
- < Text style = { { fontSize : 18 , fontWeight : '400' , color : 'black' } } >
60
- { item . seller . name }
61
- </ Text >
30
+ < View style = { styles . BuyerDetails } >
31
+ < View style = { styles . userdetails } >
32
+ < View style = { { flexDirection : 'row' , alignItems : 'baseline' } } >
33
+ < Icon
34
+ name = "user-alt"
35
+ color = "black"
36
+ size = { 20 }
37
+ style = { { marginRight : 10 } }
38
+ />
39
+ < Text style = { { fontSize : 18 , color : '#000' , fontWeight : '400' } } >
40
+ { item . buyer . name }
41
+ </ Text >
42
+ </ View >
43
+
44
+ < TouchableOpacity
45
+ style = { styles . update }
46
+ onPress = { ( ) => onPressBlockSeller ( item . seller . _id ) } >
47
+ < Text
48
+ style = { {
49
+ color : '#fff' ,
50
+ } } >
51
+ Block Seller
52
+ </ Text >
53
+ </ TouchableOpacity >
62
54
</ View >
55
+ </ View >
56
+ < View style = { styles . sellerDetails } >
57
+ < View style = { styles . userdetails } >
58
+ < View style = { { flexDirection : 'row' , alignItems : 'baseline' } } >
59
+ < Entypo
60
+ name = "smashing"
61
+ color = "black"
62
+ size = { 20 }
63
+ style = { { marginRight : 10 } }
64
+ />
65
+ < Text style = { { fontSize : 18 , fontWeight : '400' , color : 'black' } } >
66
+ { item . seller . name }
67
+ </ Text >
68
+ </ View >
63
69
64
- < View style = { styles . update1 } >
65
- < MaterialCommunityIcons
66
- name = "message-text-outline"
67
- size = { 20 }
68
- color = "white"
69
- />
70
+ < View style = { styles . update1 } >
71
+ < MaterialCommunityIcons
72
+ name = "message-text-outline"
73
+ size = { 20 }
74
+ color = "white"
75
+ />
76
+ </ View >
70
77
</ View >
71
78
</ View >
79
+ < View style = { styles . descriptionRow } >
80
+ < Text style = { { fontWeight : '700' } } > Description : </ Text >
81
+ < Text
82
+ style = { {
83
+ flexWrap : 'wrap' ,
84
+ flex : 1 ,
85
+ } } >
86
+ { item . description }
87
+ </ Text >
88
+ </ View >
72
89
</ View >
73
- < View style = { styles . descriptionRow } >
74
- < Text style = { { fontWeight : '700' } } > Description : </ Text >
75
- < Text
76
- style = { {
77
- flexWrap : 'wrap' ,
78
- flex : 1 ,
79
- } } >
80
- { item . description }
81
- </ Text >
82
- </ View >
83
- </ View >
84
- ) ;
85
- const ComplainScreen = ( props ) => {
86
- const renderItem = ( { item} ) => < Item item = { item } /> ;
90
+ ) ;
87
91
88
92
const [ complains , setComplains ] = useState ( [ ] ) ;
89
93
94
+ const onPressBlockSeller = async ( id ) => {
95
+ console . log ( 'in block seller' , props . token , id ) ;
96
+ try {
97
+ let response = await axios . put (
98
+ `${ URL } ${ blockSeller } ${ id } ` ,
99
+ { } ,
100
+ {
101
+ headers : {
102
+ Authorization : `Bearer ${ props . token } ` ,
103
+ } ,
104
+ } ,
105
+ ) ;
106
+ console . log ( 'in blockseller' , response . data . result ) ;
107
+ Alert . alert (
108
+ 'Seller Blocked' ,
109
+ 'This seller has been blocked.' ,
110
+ [
111
+ // {
112
+ // text: 'Cancel',
113
+ // onPress: () => console.log('Cancel Pressed'),
114
+ // style: 'cancel',
115
+ // },
116
+ {
117
+ text : 'Continue' ,
118
+ onPress : ( ) => allComplains ( ) ,
119
+ color : 'green' ,
120
+ } ,
121
+ ] ,
122
+ {
123
+ cancelable : true ,
124
+ } ,
125
+ ) ;
126
+ return response . data . result ;
127
+ } catch ( error ) {
128
+ console . log ( 'error' , error . message ) ;
129
+ if ( error ?. response ?. data ?. result ) {
130
+ console . log ( 'error' , error . response . data ) ;
131
+ return { error : error . response . data . result } ;
132
+ }
133
+ }
134
+ } ;
135
+
90
136
const allComplains = async ( ) => {
91
137
try {
92
138
let response = await axios . get ( `${ URL } ${ getAllComplains } ` , {
@@ -167,7 +213,7 @@ const styles = StyleSheet.create({
167
213
marginBottom : 5 ,
168
214
} ,
169
215
update : {
170
- backgroundColor : '#43c58d ' ,
216
+ backgroundColor : 'red ' ,
171
217
shadowColor : '#000' ,
172
218
shadowOffset : {
173
219
width : 0 ,
0 commit comments