Advertisement
rizkyalviandra

react native condition

Sep 16th, 2019
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export default class Ini extends Component(){
  2. deleteTrancation = (valueArticle, valueSales) => {
  3.    
  4.     title = 'Delete';
  5.     body = 'Are You Sure Delete';
  6.     Alert.alert(
  7.       title,
  8.       body,
  9.       [
  10.         {
  11.           text: 'Cancel',
  12.           onPress: () => console.log('Cancel Pressed'),
  13.           style: 'cancel',
  14.         },
  15.         {text: 'OK', onPress: () => this.delTrans(valueArticle, valueSales)},
  16.       ],
  17.       {cancelable: false},
  18.     )
  19.    
  20.   }
  21.  
  22.   delTrans = (valueArticle, valueSales) => {
  23.     const { user,role } = this.props;
  24.     axios({
  25.       method: 'post',
  26.       url: DELETE_TRASACTION_HEADER_URL,
  27.       headers: {
  28.         Authorization: `Bearer ${user}`,
  29.       },
  30.       data: {
  31.         header: {
  32.           id: 0,
  33.           page: 1,
  34.           sort: "ASC"
  35.         },
  36.         body: {
  37.           sales_id: valueSales,
  38.           article_id: valueArticle,
  39.         },
  40.       },
  41.     }).then((response) => {
  42.       if (response.data.header.response_code == 99) {
  43.         console.log(response.data.header.response_description);
  44.         // alert("sucess delete transaction");
  45.         this.props.onFetch();
  46.        
  47.       } else {
  48.         console.log(response.data.body);
  49.         console.log(response.data.header.response_description);
  50.         // alert('failed delete' + value);
  51.       }
  52.     });
  53.   }
  54.  
  55. render(){
  56. const { data } = this.props;
  57.     console.log(data)
  58.     return (
  59.       <View style={styles.itemCardContainer}>
  60.         <View>
  61.           {/* <Text>{`No Urut: ${data.no_urut}`}</Text> */}
  62.           <View style={[utility.flexRow, { justifyContent: 'space-between' }]}>
  63.               {/* <TouchableOpacity
  64.                     onPress = {() => this.deleteTrancation(data.id, data.sales_id)}
  65.                     style={[styles.icons, common.backgroundWarn]}>
  66.                     <Icon name="clear" size={18} color={color.colorOff} />
  67.               </TouchableOpacity> */} //comment
  68.  
  69.                 {data.is_approved === '0' ? (
  70.                   <TouchableOpacity
  71.                       onPress = {() => this.deleteTrancation(data.id, data.sales_id)}
  72.                       style={[styles.icons, common.backgroundWarn]}>
  73.                     <Icon name="clear" size={18} color={color.colorOff} />
  74.                   </TouchableOpacity>
  75.                   ) : (
  76.                     <Text style={[common.textValid]}></Text>
  77.                   )}
  78.           </View>
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement