ReviewItem.js 3.12 KB

import { useState } from 'react';
import {post} from 'axios'
import {Dimensions, View,Text,Image,StyleSheet,TouchableOpacity,Modal,TouchableHighlight,Alert} from 'react-native'
import * as React from 'react'
import Star from './Star'
import moment from 'moment'
import {get} from 'axios'
import { SERVER } from '../common/servername';
import Camera from '../assets/Camera_big.svg'
import AsyncStorage from '@react-native-community/async-storage';
export default ({ item,navigation,user,store}) => {
    const [User,setUser] = React.useState({})
    React.useEffect(() => {
        AsyncStorage.getItem('user',(err,res) => {
            if(res ) {
                setUser(JSON.parse(res))
            }
        })
    },[])
    return (
        <View style={{backgroundColor:"white",marginBottom:16}}>
            <View style={{flexDirection:"row"}}>
                <Image style={{width:30,height:30,borderRadius:100}} source={item.name?{uri:item.image}:{uri:item.profile}}/>
                <View style={{justifyContent:"center",marginLeft:8}}>
                    <Text style={{fontSize:12,color:"#615F5F"}}> {item.name?item.name:item.reviewWriter}</Text>
                </View>
                {item.UserId === User.id?
                <TouchableOpacity style={{marginLeft:"auto"}}>
                    <Text style={{color:"#615F5F",fontSize:12,fontWeight:"bold",borderBottomColor:"#615F5F",borderBottomWidth:1}}>
                        삭제
                    </Text>
                </TouchableOpacity>:undefined}
            </View>
            
            <View style={{flexDirection:"row",marginTop:8,marginBottom:4.3}}>
                <Star item={item.reviewGrade} style={{flexDirection:"row"}}/>
                <View>
                    <Text style={{fontSize:9,color:"#979292"}}>
                        {moment(item.updatedAt).format("MM월 DD일")}
                    </Text>
                </View>
            </View>
            <View style={{marginTop:7.9}}>
                <Text>
                    {item.reviewContent}
                </Text>
            </View>
            {store && item.comment?
            <View>
            <View style={{marginTop:7.9,backgroundColor:"#F1F1F1",paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16,flexDirection:"row"}}>
                
            {store&& store.profile===null?
                <View style={{padding:3,borderColor:"#615F5F",borderWidth:1,backgroundColor:"white",marginRight:10}}>
                <Camera width={30} height={25} style={{}}/>
                </View>:<Image style={{width:70,height:60,marginRight:10}} source={{uri:item.profile}}/>}
                <Text style={{fontSize:12,color:"#615F5F",alignSelf:"center"}}>
                    {store.name}
                </Text>
            </View>
            <View style={{backgroundColor:"#F1F1F1",paddingBottom:16,paddingLeft:16,paddingRight:16,}}>
                <Text>
                    {item.comment}

                </Text>
                </View>
            </View>:undefined}
        </View>
    )
}

const style = StyleSheet.create({
    text:{
        color:"#707070",
        fontSize:11,
        fontWeight:"900"
    }
})