Store_detail.js
17.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
import React, { Component } from 'react';
import {Image, View, Text, StyleSheet,ScrollView,TouchableOpacity } from 'react-native';
import CouponeItem from '../CouponItem'
import StampItem from '../StampItem'
import Birthday from '../../assets/birthday.svg'
import Star from '../Star'
import AsyncStorage from '@react-native-community/async-storage';
import {get,put,all,post} from 'axios'
import { SERVER } from '../../common/servername';
import Modal from 'react-native-modal'
import moment from 'moment'
import { TextInput } from 'react-native-gesture-handler';
export default class AddTab extends Component {
static navigationOptions = {
headerShown: false
}
state = {
current:1,
Coupon:[
{
title:"네네치킨 송도신도시점",
left:130,
use:"공용",
discount:1000,
datetime:new Date(),
condition:["네네 송도신도시점 한정","10,000원이상 결제시 사용가능","중복사용 가능"],
},
{
title:"네네치킨 송도신도시점",
left:130,
use:"공용",
discount:1000,
datetime:new Date(),
condition:["네네 송도신도시점 한정","10,000원이상 결제시 사용가능","중복사용 가능"],
},
{
title:"네네치킨 송도신도시점",
left:130,
use:"공용",
discount:1000,
datetime:new Date(),
condition:["네네 송도신도시점 한정","10,000원이상 결제시 사용가능","중복사용 가능"],
}
],
Stamp:[
{
title:"네네치킨 송도신도시점",
contents:"스탬프 10개를 모으면 아메리카노 (hot,ice) 1잔 무료제공!",
stamp:[
{
contents:"1",
datetime:new Date()
},
{
contents:"1",
datetime:new Date()
},
{
contents:"1",
datetime:new Date()
},
{
contents:"1",
datetime:new Date()
},
{
contents:"1",
datetime:new Date()
},
{
contents:"1",
datetime:new Date()
},
{
contents:"1",
datetime:new Date()
},
{
contents:"1",
datetime:new Date()
},
{
contents:"1",
datetime:new Date()
},
{
contents:"1",
datetime:new Date()
}
],
},
],
user:{},
likes:[],
reviews:[],
menuModal:false,
comment:""
}
constructor(props) {
super(props)
}
componentDidMount() {
if(this.props.navigation.state.params ) {
this.setState({
current:this.props.navigation.state.params.current
})
}
AsyncStorage.getItem("user",(err,res) => {
if(res) {
this.setState({
user:JSON.parse(res)
})
get(`http://${SERVER}/stores/managerRead/${JSON.parse(res).id}`).then(res => {
this.setState({
store:res.data.data
})
all(res.data.data.map((e,i) => get(`http://${SERVER}/reviews/${e.id}`))).then(ress => {
ress.forEach((e,i) => {
this.setState(prev => ({
reviews:prev.reviews.concat(e.data.data.map((e,i) => e)),
loading:false
}),() => {
console.log(this.state.reviews)
})
})
})
all(res.data.data.map((e,i) => get(`http://${SERVER}/likes/${e.id}`))).then(ress => {
ress.forEach((e,i) => {
this.setState(prev => ({
likes:prev.likes.concat(e.data.data.map((e,i) => e)),
loading:false
}),() => {
console.log(this.state.likes)
})
})
})
})
}
})
}
onComment = (id) => {
if(!this.state.comment) return alert("내용을 입력해주세요.")
put(`http://${SERVER}/reviews/comment`,{review_id:id,comment:this.state.comment}).then(res => {
if(res.data.success) {
alert("답글이 등록되었습니다.")
}
this.setState({
menuModal:false
})
})
}
render() {
return (
<View style={{width:"100%",height:"100%"}}>
<View style={{width:"100%",flexDirection:"row",paddingTop:16,paddingBottom:16,paddingLeft:16,backgroundColor:"#615F5F"}}>
<TouchableOpacity onPress={() => this.props.navigation.goBack(null)}>
<Image source={require('../../assets/back.png')}/>
</TouchableOpacity>
<Text style={{color:"white",fontSize:16,marginLeft:16}}>
스토어
</Text>
</View>
<ScrollView style={{backgroundColor:"white"}}>
<View style={{
width:"100%",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
backgroundColor:"white",
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,}}>
<View style={{flex:1,flexDirection:"row", }}>
<TouchableOpacity onPress={() => this.setState({current:1})} style={{width:"50%",paddingTop:8.9, paddingBottom:11.1,}}>
<Text style={[{textAlign:"center",borderRightColor:"#615F5F",borderRightWidth:1},this.state.current==1?{color:"#615F5F"}:{color:"#BDBCBC"}]}>
찜한 고객 리스트({this.state.likes.length})
</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.setState({current:2})} style={{width:"50%",paddingTop:8.9, paddingBottom:11.1}}>
<Text style={[{textAlign:"center"},this.state.current==2?{color:"#615F5F"}:{color:"#BDBCBC"}]}>
리뷰 고객 리스트({this.state.reviews.length})
</Text>
</TouchableOpacity>
</View>
</View>
{this.state.current==1?
this.state.likes.map((e,i) => {
return (
<View style={{flexDirection:"row",justifyContent:"space-between",paddingTop:16,paddingLeft:16,paddingRight:16,paddingBottom:16}}>
<View style={{flexDirection:"row"}}>
<Birthday style={{alignSelf:"center"}}/>
<View style={{marginLeft:9}}>
<Text style={{color:"#615F5F",fontSize:12,fontWeight:"bold"}}>
{e.nickname}
</Text>
<Text style={{color:"#615F5F",fontSize:11,fontWeight:"bold"}}>
010-1234-1234
</Text>
</View>
</View>
<View>
<Text style={{color:"#615F5F",fontSize:12}}>
찜한 날 : {moment(e.createdAt).format("YYYY.MM.DD")}
</Text>
<Text style={{color:"#615F5F",fontSize:12}}>
채팅 : 2020.13
</Text>
</View>
<View>
<Text style={{fontSize:12,color:"#615F5F"}}>
{`[쿠폰${e.Coupons}] [스탬프${e.Stamps}]`}
</Text>
<Text style={{fontSize:12,color:"#615F5F"}}>
{`[리뷰3] [구매자0]`}
</Text>
</View>
</View>
)
}):
<View style={{paddingLeft:16,paddingRight:16,paddingTop:16,paddingBottom:16}}>
<View style={{flexDirection:"row"}}>
<View style={{justifyContent:"center",width:"18%",borderRightColor:"#BDBCBC",borderRightWidth:1,borderBottomColor:"#BDBCBC",borderBottomWidth:1,height:45.6}}>
<Text style={{textAlign:"center",alignSelf:"center",textAlignVertical:"center",color:"#615F5F",fontSize:14,fontWeight:"bold"}}>
이름
</Text>
</View>
<View style={{justifyContent:"center",width:"50%",borderRightColor:"#BDBCBC",borderRightWidth:1,borderBottomColor:"#BDBCBC",borderBottomWidth:1,height:45.6}}>
<Text style={{textAlign:"center",alignSelf:"center",textAlignVertical:"center",color:"#615F5F",fontSize:14,fontWeight:"bold"}}>
내용
</Text>
</View>
<View style={{justifyContent:"center",width:"16%",borderRightColor:"#BDBCBC",borderRightWidth:1,borderBottomColor:"#BDBCBC",borderBottomWidth:1,height:45.6}}>
<Text style={{textAlign:"center",alignSelf:"center",textAlignVertical:"center",color:"#615F5F",fontSize:14,fontWeight:"bold"}}>
평점
</Text>
</View>
<View style={{justifyContent:"center",width:"16%",borderBottomColor:"#BDBCBC",borderBottomWidth:1,height:45.6}}>
<Text style={{textAlign:"center",alignSelf:"center",textAlignVertical:"center",color:"#615F5F",fontSize:14,fontWeight:"bold"}}>
등록일
</Text>
<Text style={{textAlign:"center",alignSelf:"center",textAlignVertical:"center",color:"#615F5F",fontSize:14,fontWeight:"bold"}}>
수정일
</Text>
</View>
</View>
{
this.state.reviews.map((e,i) => {
return (
<View style={{flexDirection:"row"}}>
<Modal isVisible={this.state.menuModal} onBackButtonPress={() => this.setState({menuModal:false})} >
<View style={{backgroundColor:"white",alignSelf:"center",width:"90%",paddingLeft:16,paddingTop:16,paddingRight:16,paddingBottom:16}}>
<TextInput value={this.state.comment} onChangeText={e => this.setState({comment:e})} style={{fontSize:15,fontWeight:"bold",}} multiline={true} placeholder="답글을 입력해주세요."/>
</View>
<TouchableOpacity onPress={() => this.onComment(e.id)} style={{backgroundColor:"#FFD63A",fontSize:15,fontWeight:"bold",alignSelf:"center",width:"90%",paddingLeft:16,paddingTop:16,paddingRight:16,paddingBottom:16}}>
<Text style={{textAlign:"center",fontSize:15,fontWeight:"bold",}}>
등록
</Text>
</TouchableOpacity>
</Modal>
<View style={{justifyContent:"center",width:"18%",borderRightColor:"#BDBCBC",borderRightWidth:1,borderBottomColor:"#BDBCBC",borderBottomWidth:1}}>
<Text style={{marginTop:8.4,textAlign:"center",alignSelf:"center",textAlignVertical:"center",color:"#615F5F",fontSize:12}}>
{e.reviewWriter}
</Text>
<TouchableOpacity style={{alignSelf:"center",borderWidth:1,borderColor:"#FFD63A",paddingLeft:9,paddingRight:9,marginTop:9,marginBottom:7.5}}>
<Text style={{fontSize:13,lineHeight:19,color:"#FFD63A"}}>
쿠폰
</Text>
<Text style={{fontSize:13,lineHeight:19,color:"#FFD63A"}}>
발송
</Text>
</TouchableOpacity>
</View>
<View style={{justifyContent:"center",width:"50%",borderRightColor:"#BDBCBC",borderRightWidth:1,borderBottomColor:"#BDBCBC",borderBottomWidth:1}}>
<Text style={{textAlign:"center",alignSelf:"center",textAlignVertical:"center",color:"#615F5F",fontSize:12}}>
{e.reviewContent}
</Text>
<TouchableOpacity onPress={() => this.setState({menuModal:true})} style={{alignSelf:"center",borderWidth:1,borderColor:"#FFD63A",paddingLeft:9,paddingRight:9,marginTop:9,marginBottom:7.5}}>
<Text style={{fontSize:13,lineHeight:19,color:"#FFD63A"}}>
댓글쓰기
</Text>
</TouchableOpacity>
</View>
<View style={{justifyContent:"center",width:"16%",borderRightColor:"#BDBCBC",borderRightWidth:1,borderBottomColor:"#BDBCBC",borderBottomWidth:1}}>
<Text style={{textAlign:"center",alignSelf:"center",textAlignVertical:"center",color:"#615F5F",fontSize:12}}>
{e.reviewGrade}
</Text>
<Star width={7} height={7} margin={2.5} style={{flexDirection:"row",justifyContent:"center",marginTop:5,marginBottom:4.3}} navigation={this.props.navigation}
item={e.reviewGrade} />
</View>
<View style={{justifyContent:"center",width:"16%",borderBottomColor:"#BDBCBC",borderBottomWidth:1}}>
<Text style={{textAlign:"center",alignSelf:"center",textAlignVertical:"center",color:"#615F5F",fontSize:10}}>
{moment(e.createdAt).format("YYYY.M.D")}
</Text>
<Text style={{textAlign:"center",alignSelf:"center",textAlignVertical:"center",color:"#615F5F",fontSize:10}}>
{moment(e.updatedAt).format("YYYY.M.D")}
</Text>
<TouchableOpacity style={{alignSelf:"center",borderWidth:1,borderColor:"#FFD63A",paddingLeft:7.5,paddingRight:7.5,marginTop:9,marginBottom:7.5}}>
<Text style={{fontSize:13,lineHeight:19,color:"#FFD63A"}}>
숨기기
</Text>
</TouchableOpacity>
</View>
</View>
)
})}
</View>
}
</ScrollView>
<View style={{zIndex:10,position:"absolute",bottom:0,width:"100%"}}>
<TouchableOpacity onPress={() => this.props.navigation.navigate("Add_Store")} style={{backgroundColor:"#f4cd37",padding:20}}>
<Text style={{textAlign:"center",fontSize:15,fontWeight:"bold",color:"black"}}>
스토어(상점) 추가 등록 +
</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
const style = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});