Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import {StyleSheet, View, Text, TextInput, ActivityIndicator, Image, ScrollView } from 'react-native';
- import AsyncStorage from '@react-native-community/async-storage';
- import { Button, CardItem, Card } from 'native-base'
- import Axios from 'axios';
- class Promotions extends Component {
- constructor(props) {
- super(props);
- this.state = {
- id:'',
- treatment_id: '',
- title: '',
- desc: '',
- image:'',
- status:'',
- token: '',
- promotionsSource: []
- }
- }
- async componentDidMount () {
- const token = await AsyncStorage.getItem('token')
- Axios({
- method: 'get',
- url: 'http://192.168.56.1/vzuu/public/api/promotions',
- dataType: 'json',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- 'Authorization': 'Bearer ' + token,
- },
- })
- .then(response => {
- var promotion = [];
- for (var i = 0; i < response.data.results.promotions.length; i++) {
- promotion.push([
- response.data.results.promotions[i].id,
- response.data.results.promotions[i].treatment_id,
- response.data.results.promotions[i].title,
- response.data.results.promotions[i].desc,
- response.data.results.promotions[i].image,
- response.data.results.promotions[i].status,
- response.data
- ]);
- }
- this.setState({
- promotionsSource: promotions,
- })
- });
- console.log(this.state.data);
- Axios({
- method: 'get',
- url: 'http://192.168.56.1/vzuu/public/api/treatments',
- dataType: 'json',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json',
- // 'Authorization': 'Bearer ' + token,
- },
- })
- .then(response => {
- this.setState({ promotionsSource: response.data.results.treatments });
- });
- console.log(this.state.data);
- }
- render() {
- return(
- <ScrollView>
- <View style={{ padding: 14, }}>
- <Card>
- <Image style={styles.img} source={require('../../asset/images/diskon.png')} />
- <Text
- style={styles.text}>
- {this.props.name}
- </Text>
- </Card>
- <Card>
- <Image style={styles.img} source={require('../../asset/images/diskon.png')} />
- <Text
- style={styles.text}>
- Get Promotion Discount Treatment Up 50%
- </Text>
- </Card>
- </View>
- </ScrollView>
- )
- }
- }
- export default Promotions;
- const styles = StyleSheet.create({
- container: { flex: 1, justifyContent: 'center', alignItems: 'center' },
- img: {width: 370, height: 200},
- text: { fontSize: 18, fontWeight: 'bold', color: '#E91E63', alignItems: 'center', justifyContent: 'center' }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement